Skip to content

Commit

Permalink
lock masquerade during json.Marshal
Browse files Browse the repository at this point in the history
  • Loading branch information
atavism committed Aug 12, 2024
1 parent 9369ca3 commit 32cdfc3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions masquerade.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fronted

import (
"encoding/json"
"fmt"
"hash/crc32"
"net"
Expand Down Expand Up @@ -48,6 +49,18 @@ type masquerade struct {
mx sync.RWMutex
}

func (m *masquerade) MarshalJSON() ([]byte, error) {
m.mx.RLock()
defer m.mx.RUnlock()
// Type alias for masquerade
type Alias masquerade
return json.Marshal(&struct {
*Alias
}{
Alias: (*Alias)(m),
})
}

func (m *masquerade) lastSucceeded() time.Time {
m.mx.RLock()
defer m.mx.RUnlock()
Expand Down

0 comments on commit 32cdfc3

Please sign in to comment.