From 6db2b8c66d37acb4309a3f338f73af47ceeb4a60 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 30 Sep 2019 20:03:03 -0700 Subject: [PATCH] . --- go/cmd/zerotier/cli/identity.go | 9 --------- go/cmd/zerotier/cli/locator.go | 1 + go/pkg/zerotier/inetaddress.go | 2 +- go/pkg/zerotier/locator.go | 11 ++++++----- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/go/cmd/zerotier/cli/identity.go b/go/cmd/zerotier/cli/identity.go index 716561cfd..f83b6817f 100644 --- a/go/cmd/zerotier/cli/identity.go +++ b/go/cmd/zerotier/cli/identity.go @@ -23,15 +23,6 @@ import ( "zerotier/pkg/zerotier" ) -/* - identity [args] Identity management commands - new Create new identity (including secret) - getpublic Extract only public part of identity - validate Locally validate an identity - sign Sign a file with an identity's key - verify Verify a signature -*/ - // Identity command func Identity(args []string) { if len(args) > 0 { diff --git a/go/cmd/zerotier/cli/locator.go b/go/cmd/zerotier/cli/locator.go index 036d65fff..55be4638f 100644 --- a/go/cmd/zerotier/cli/locator.go +++ b/go/cmd/zerotier/cli/locator.go @@ -70,6 +70,7 @@ func locatorNew(args []string) { os.Exit(1) } fmt.Println(jsonDump(loc)) + os.Exit(0) } func locatorNewDNSKey(args []string) { diff --git a/go/pkg/zerotier/inetaddress.go b/go/pkg/zerotier/inetaddress.go index 0eb8f03cb..96da67058 100644 --- a/go/pkg/zerotier/inetaddress.go +++ b/go/pkg/zerotier/inetaddress.go @@ -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) } } diff --git a/go/pkg/zerotier/locator.go b/go/pkg/zerotier/locator.go index 28458b33e..cec72f223 100644 --- a/go/pkg/zerotier/locator.go +++ b/go/pkg/zerotier/locator.go @@ -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 }