Adam Ierymenko 5 years ago
parent
commit
6db2b8c66d

+ 0 - 9
go/cmd/zerotier/cli/identity.go

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

+ 1 - 0
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) {

+ 1 - 1
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)
 		}
 	}

+ 6 - 5
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
 }