diff --git a/masquerade.go b/masquerade.go index 0abade8..686ff93 100644 --- a/masquerade.go +++ b/masquerade.go @@ -1,6 +1,7 @@ package fronted import ( + "encoding/json" "fmt" "hash/crc32" "net" @@ -48,6 +49,15 @@ type masquerade struct { mx sync.RWMutex } +// MarshalJSON marshals masquerade into json +func (m *masquerade) MarshalJSON() ([]byte, error) { + m.mx.RLock() + defer m.mx.RUnlock() + // Type alias for masquerade so that we don't infinitely recurse when marshaling the struct + type alias masquerade + return json.Marshal((*alias)(m)) +} + func (m *masquerade) lastSucceeded() time.Time { m.mx.RLock() defer m.mx.RUnlock()