Various build fixes.

This commit is contained in:
Adam Ierymenko 2020-06-03 22:15:19 -07:00
parent a4ae4941c3
commit 741f7814c2
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
6 changed files with 28 additions and 15 deletions

View file

@ -51,7 +51,7 @@ func Peers(basePath, authToken string, args []string, jsonOutput bool, rootsOnly
if paths.Len() > 0 {
paths.WriteRune(' ')
}
paths.WriteString(fmt.Sprintf("%s/%d", peer.Paths[0].IP.String(), peer.Paths[0].Port))
paths.WriteString(peer.Paths[0].Endpoint.String())
} else {
paths.WriteString("(relayed)")
}

View file

@ -39,7 +39,6 @@ func Status(basePath, authToken string, args []string, jsonOutput bool) {
} else {
fmt.Printf("\tports:\t%d\n", status.Config.Settings.PrimaryPort)
}
fmt.Printf("\tport search:\t%s\n", enabledDisabled(status.Config.Settings.PortSearch))
fmt.Printf("\tport mapping (uPnP/NAT-PMP):\t%s\n", enabledDisabled(status.Config.Settings.PortMapping))
fmt.Printf("\tblacklisted interface prefixes:\t")
for i, bl := range status.Config.Settings.InterfacePrefixBlacklist {

View file

@ -30,13 +30,11 @@
#include <sys/types.h>
#include <sys/ioctl.h>
#include <ifaddrs.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet6/in6_var.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <errno.h>
#ifdef __BSD__
#include <net/if.h>
#endif
#ifdef __LINUX__
#ifndef IPV6_DONTFRAG
#define IPV6_DONTFRAG 62

View file

@ -46,8 +46,7 @@ func NewLocator(ts int64, endpoints []Endpoint, signer *Identity) (*Locator, err
goloc := new(Locator)
goloc.cl = unsafe.Pointer(loc)
goloc.init()
return goloc, nil
return goloc, goloc.init()
}
func NewLocatorFromBytes(lb []byte) (*Locator, error) {
@ -61,8 +60,7 @@ func NewLocatorFromBytes(lb []byte) (*Locator, error) {
goloc := new(Locator)
goloc.cl = unsafe.Pointer(loc)
goloc.init()
return goloc, nil
return goloc, goloc.init()
}
func NewLocatorFromString(s string) (*Locator, error) {
@ -78,8 +76,7 @@ func NewLocatorFromString(s string) (*Locator, error) {
goloc := new(Locator)
goloc.cl = unsafe.Pointer(loc)
goloc.init()
return goloc, nil
return goloc, goloc.init()
}
func (loc *Locator) Validate(id *Identity) bool {
@ -119,7 +116,7 @@ func (loc *Locator) UnmarshalJSON(j []byte) error {
return ErrInvalidParameter
}
loc.cl = cl
loc.init()
return loc.init()
}
func locatorFinalizer(obj interface{}) {

View file

@ -45,7 +45,7 @@ func newPeerFromCPeer(cp *C.ZT_Peer) (p *Peer, err error) {
p.Root = cp.root != 0
p.Paths = make([]Path, int(cp.pathCount))
for i := range p.Paths {
p.Paths[i].setFromCPath(&(cp.paths[i]))
p.Paths[i].setFromCPath((*C.ZT_Path)(unsafe.Pointer(uintptr(unsafe.Pointer(cp.paths)) + (uintptr(C.sizeof_ZT_Path) * uintptr(i)))))
}
p.Locator, err = NewLocatorFromBytes(C.GoBytes(unsafe.Pointer(cp.locator), C.int(cp.locatorSize)))
return

View file

@ -116,7 +116,7 @@ public:
case ZT_ENDPOINT_TYPE_IP:
case ZT_ENDPOINT_TYPE_IP_UDP:
case ZT_ENDPOINT_TYPE_IP_TCP:
case ZT_ENDPOINT_TYPE_IP_HTTP2:
case ZT_ENDPOINT_TYPE_IP_HTTP:
return true;
default:
return false;
@ -179,6 +179,25 @@ public:
ZT_INLINE Fingerprint zt() const noexcept
{ return Fingerprint(this->value.fp); }
ZT_INLINE unsigned long hashCode() const noexcept
{
switch (this->type) {
default:
return 1;
case ZT_ENDPOINT_TYPE_ZEROTIER:
return (unsigned long)this->value.fp.address;
case ZT_ENDPOINT_TYPE_ETHERNET:
case ZT_ENDPOINT_TYPE_WIFI_DIRECT:
case ZT_ENDPOINT_TYPE_BLUETOOTH:
return (unsigned long)Utils::hash64(this->value.mac);
case ZT_ENDPOINT_TYPE_IP:
case ZT_ENDPOINT_TYPE_IP_UDP:
case ZT_ENDPOINT_TYPE_IP_TCP:
case ZT_ENDPOINT_TYPE_IP_HTTP:
return ip().hashCode();
}
}
char *toString(char s[ZT_ENDPOINT_STRING_SIZE_MAX]) const noexcept;
ZT_INLINE String toString() const { char tmp[ZT_ENDPOINT_STRING_SIZE_MAX]; return String(toString(tmp)); }