mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-02-02 09:17:57 +00:00
.
This commit is contained in:
parent
47a08ccbd4
commit
6db2b8c66d
@ -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 {
|
||||
|
@ -70,6 +70,7 @@ func locatorNew(args []string) {
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Println(jsonDump(loc))
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func locatorNewDNSKey(args []string) {
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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…
x
Reference in New Issue
Block a user