This commit is contained in:
Adam Ierymenko 2019-09-30 20:03:03 -07:00
parent 47a08ccbd4
commit 6db2b8c66d
No known key found for this signature in database
GPG Key ID: C8877CF2D7A5D7F3
4 changed files with 8 additions and 15 deletions

View File

@ -23,15 +23,6 @@ import (
"zerotier/pkg/zerotier"
)
/*
identity <command> [args] Identity management commands
new Create new identity (including secret)
getpublic <identity> Extract only public part of identity
validate <identity> Locally validate an identity
sign <identity> <file> Sign a file with an identity's key
verify <identity> <file> <sig> Verify a signature
*/
// Identity command
func Identity(args []string) {
if len(args) > 0 {

View File

@ -70,6 +70,7 @@ func locatorNew(args []string) {
os.Exit(1)
}
fmt.Println(jsonDump(loc))
os.Exit(0)
}
func locatorNewDNSKey(args []string) {

View File

@ -51,7 +51,7 @@ func NewInetAddressFromString(s string) *InetAddress {
i.IP = i4
}
if len(ss) > 1 {
p64, _ := strconv.ParseUint(s, 10, 64)
p64, _ := strconv.ParseUint(ss[1], 10, 64)
i.Port = int(p64 & 0xffff)
}
}

View File

@ -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
}