diff --git a/core/zerotier.h b/core/zerotier.h index 43997dbd2..140ffbe6d 100644 --- a/core/zerotier.h +++ b/core/zerotier.h @@ -629,15 +629,15 @@ enum ZT_CredentialType */ enum ZT_EndpointType { - ZT_ENDPOINT_TYPE_NIL = 0, // Nil/empty endpoint - ZT_ENDPOINT_TYPE_ZEROTIER = 1, // ZeroTier relaying (address+fingerprint) - ZT_ENDPOINT_TYPE_ETHERNET = 2, // Ethernet with ethertype 0x9993 - ZT_ENDPOINT_TYPE_WIFI_DIRECT = 3, // Ethernet using WiFi direct - ZT_ENDPOINT_TYPE_BLUETOOTH = 4, // Bluetooth (same address type as Ethernet) - ZT_ENDPOINT_TYPE_IP = 5, // Naked IP (protocol 193) - ZT_ENDPOINT_TYPE_IP_UDP = 6, // IP/UDP - ZT_ENDPOINT_TYPE_IP_TCP = 7, // IP/TCP - ZT_ENDPOINT_TYPE_IP_HTTP = 8 // IP/HTTP encapsulation + ZT_ENDPOINT_TYPE_NIL = 0, /* Nil/empty endpoint */ + ZT_ENDPOINT_TYPE_ZEROTIER = 1, /* ZeroTier relaying (address+fingerprint) */ + ZT_ENDPOINT_TYPE_ETHERNET = 2, /* Ethernet with ethertype 0x9993 */ + ZT_ENDPOINT_TYPE_WIFI_DIRECT = 3, /* Ethernet using WiFi direct */ + ZT_ENDPOINT_TYPE_BLUETOOTH = 4, /* Bluetooth (same address type as Ethernet) */ + ZT_ENDPOINT_TYPE_IP = 5, /* Naked IP (protocol 193) */ + ZT_ENDPOINT_TYPE_IP_UDP = 6, /* IP/UDP */ + ZT_ENDPOINT_TYPE_IP_TCP = 7, /* IP/TCP */ + ZT_ENDPOINT_TYPE_IP_HTTP = 8 /* IP/HTTP encapsulation */ }; /** @@ -877,7 +877,7 @@ enum ZT_Event */ ZT_EVENT_DOWN = 3, - // 4 once signaled identity collision but this is no longer an error + /* 4 once signaled identity collision but this is no longer an error */ /** * Trace (debugging) message @@ -1030,7 +1030,7 @@ enum ZT_VirtualNetworkType */ enum ZT_VirtualNetworkRuleType { - // 0 to 15 reserved for actions + /* 0 to 15 reserved for actions */ /** * Drop frame @@ -1163,10 +1163,10 @@ typedef struct * bytes and doesn't enlarge the overall size of this union. */ struct { - uint64_t start; // integer range start - uint32_t end; // end of integer range (relative to start, inclusive, 0 for equality w/start) - uint16_t idx; // index in packet of integer - uint8_t format; // bits in integer (range 1-64, ((format&63)+1)) and endianness (MSB 1 for little, 0 for big) + uint64_t start; /* integer range start */ + uint32_t end; /* end of integer range (relative to start, inclusive, 0 for equality w/start) */ + uint16_t idx; /* index in packet of integer */ + uint8_t format; /* bits in integer (range 1-64, ((format&63)+1)) and endianness (MSB 1 for little, 0 for big) */ } intRange; /** @@ -1236,9 +1236,9 @@ typedef struct * ICMP type and code */ struct { - uint8_t type; // ICMP type, always matched - uint8_t code; // ICMP code if matched - uint8_t flags; // flag 0x01 means also match code, otherwise only match type + uint8_t type; /* ICMP type, always matched */ + uint8_t code; /* ICMP code if matched */ + uint8_t flags; /* flag 0x01 means also match code, otherwise only match type */ } icmp; /** diff --git a/pkg/zerotier/certificate.go b/pkg/zerotier/certificate.go index 6d3f0a2e9..b4578afa1 100644 --- a/pkg/zerotier/certificate.go +++ b/pkg/zerotier/certificate.go @@ -122,7 +122,7 @@ func NewCertificateFromCCertificate(ccptr unsafe.Pointer) *Certificate { } var loc *Locator if cid.locator != nil { - loc, err = newLocatorFromCLocator(cid.locator) + loc, err = newLocatorFromCLocator(cid.locator, false) if err != nil { return nil } diff --git a/pkg/zerotier/fingerprint.go b/pkg/zerotier/fingerprint.go index e16138208..f846bfe9f 100644 --- a/pkg/zerotier/fingerprint.go +++ b/pkg/zerotier/fingerprint.go @@ -29,8 +29,8 @@ const FingerprintHashSize = 48 // Fingerprint bundles an address with an optional SHA384 full hash of the identity's key(s). type Fingerprint struct { - Address Address - Hash []byte + Address Address `json:"address"` + Hash []byte `json:"hash"` } // NewFingerprintFromString decodes a string-format fingerprint. diff --git a/pkg/zerotier/inetaddress.go b/pkg/zerotier/inetaddress.go index bb48c377b..88c9f579f 100644 --- a/pkg/zerotier/inetaddress.go +++ b/pkg/zerotier/inetaddress.go @@ -20,7 +20,6 @@ import ( "bytes" "encoding/binary" "encoding/json" - "errors" "net" "strconv" "strings" @@ -97,8 +96,6 @@ func makeSockaddrStorage(ip net.IP, port int, ss *C.struct_sockaddr_storage) boo return false } -var ErrInvalidInetAddress = errors.New("invalid marshaled InetAddress object") - // InetAddress implements net.Addr but has a ZeroTier-like string representation type InetAddress struct { IP net.IP diff --git a/pkg/zerotier/locator.go b/pkg/zerotier/locator.go index 8932bcbdf..c03d19b04 100644 --- a/pkg/zerotier/locator.go +++ b/pkg/zerotier/locator.go @@ -30,10 +30,10 @@ type Locator struct { cl unsafe.Pointer } -func newLocatorFromCLocator(cl unsafe.Pointer) (*Locator, error) { +func newLocatorFromCLocator(cl unsafe.Pointer, requiresDeletion bool) (*Locator, error) { loc := new(Locator) loc.cl = cl - err := loc.init(false) + err := loc.init(requiresDeletion) if err != nil { return nil, err } diff --git a/pkg/zerotier/nativetap.go b/pkg/zerotier/nativetap.go index 1efe6c0ca..90cdf9238 100644 --- a/pkg/zerotier/nativetap.go +++ b/pkg/zerotier/nativetap.go @@ -15,7 +15,6 @@ package zerotier -//#cgo CFLAGS: -O3 //#include "../../serviceiocore/GoGlue.h" import "C"