.
This commit is contained in:
parent
47a08ccbd4
commit
6db2b8c66d
4 changed files with 8 additions and 15 deletions
|
@ -170,23 +170,24 @@ func (l *Locator) MakeTXTRecords(key *LocatorDNSSigningKey) ([]string, error) {
|
|||
return nil, ErrInternal
|
||||
}
|
||||
|
||||
// MarshalJSON marshals this Locator as its byte encoding
|
||||
func (l *Locator) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(l)
|
||||
type locatorForUnmarshal struct {
|
||||
Bytes []byte
|
||||
}
|
||||
|
||||
// UnmarshalJSON unmarshals this Locator from a byte array in JSON.
|
||||
func (l *Locator) UnmarshalJSON(j []byte) error {
|
||||
err := json.Unmarshal(j, l)
|
||||
var bytes locatorForUnmarshal
|
||||
err := json.Unmarshal(j, &bytes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tmp, err := NewLocatorFromBytes(l.Bytes)
|
||||
tmp, err := NewLocatorFromBytes(bytes.Bytes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
l.Identity = tmp.Identity
|
||||
l.Physical = tmp.Physical
|
||||
l.Virtual = tmp.Virtual
|
||||
l.Bytes = bytes.Bytes
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue