Everything but root builds now. Back to testing.

This commit is contained in:
Adam Ierymenko 2020-03-18 07:20:04 -07:00
parent 83f830618f
commit 2da096944d
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
8 changed files with 33 additions and 27 deletions

View file

@ -105,7 +105,7 @@ endif()
add_subdirectory(node)
add_subdirectory(controller)
add_subdirectory(osdep)
add_subdirectory(root)
#add_subdirectory(root)
add_subdirectory(go/native)
#if(BUILD_CENTRAL_CONTROLLER)

View file

@ -99,7 +99,7 @@ LFDB::LFDB(const Identity &myId,const char *path,const char *lfOwnerPrivate,cons
selectors.push_back(selector1);
newrec["Selectors"] = selectors;
const uint8_t *const rawip = (const uint8_t *)ms->second.lastOnlineAddress.rawIpData();
switch(ms->second.lastOnlineAddress.ss_family) {
switch(ms->second.lastOnlineAddress.family()) {
case AF_INET:
for(int j=0;j<4;++j)
ip.push_back((unsigned int)rawip[j]);

View file

@ -21,7 +21,6 @@ import "C"
import (
"bytes"
"encoding/hex"
"errors"
"fmt"
"io"
@ -71,15 +70,15 @@ var (
nodesByUserPtrCtr = uintptr(0)
nodesByUserPtrLock sync.RWMutex
CoreVersionMajor int
CoreVersionMinor int
CoreVersionMajor int
CoreVersionMinor int
CoreVersionRevision int
CoreVersionBuild int
CoreVersionBuild int
)
func init() {
var vMaj,vMin,vRev,vBuild C.int
C.ZT_version(&vMaj,&vMin,&vRev,&vBuild)
var vMaj, vMin, vRev, vBuild C.int
C.ZT_version(&vMaj, &vMin, &vRev, &vBuild)
CoreVersionMajor = int(vMaj)
CoreVersionMinor = int(vMin)
CoreVersionRevision = int(vRev)
@ -122,7 +121,7 @@ type Node struct {
gn *C.ZT_GoNode
// zn is the underlying instance of the ZeroTier core
zn *C.ZT_Node
zn unsafe.Pointer
// id is the identity of this node
id *Identity
@ -263,8 +262,8 @@ func NewNode(basePath string) (n *Node, err error) {
nodesByUserPtrLock.Unlock()
return nil, ErrNodeInitFailed
}
n.zn = (*C.ZT_Node)(C.ZT_GoNode_getNode(n.gn))
n.id, err = newIdentityFromCIdentity(C.ZT_Node_identity(unsafe.Pointer(n.zn)))
n.zn = unsafe.Pointer(C.ZT_GoNode_getNode(n.gn))
n.id, err = newIdentityFromCIdentity(C.ZT_Node_identity(n.zn))
if err != nil {
n.infoLog.Printf("FATAL: error obtaining node's identity")
nodesByUserPtrLock.Lock()
@ -393,9 +392,9 @@ func NewNode(basePath string) (n *Node, err error) {
}
cAddrCount++
}
C.ZT_Node_setInterfaceAddresses(unsafe.Pointer(n.zn), &cAddrs[0], C.uint(cAddrCount))
C.ZT_Node_setInterfaceAddresses(n.zn, &cAddrs[0], C.uint(cAddrCount))
} else {
C.ZT_Node_setInterfaceAddresses(unsafe.Pointer(n.zn), nil, 0)
C.ZT_Node_setInterfaceAddresses(n.zn, nil, 0)
}
}
@ -597,14 +596,14 @@ func (n *Node) Networks() []*Network {
// Peers retrieves a list of current peers
func (n *Node) Peers() []*Peer {
var peers []*Peer
pl := C.ZT_Node_peers(unsafe.Pointer(n.zn))
pl := C.ZT_Node_peers(n.zn)
if pl != nil {
for i := uintptr(0); i < uintptr(pl.peerCount); i++ {
p := (*C.ZT_Peer)(unsafe.Pointer(uintptr(unsafe.Pointer(pl.peers)) + (i * C.sizeof_ZT_Peer)))
p2 := new(Peer)
p2.Address = Address(p.address)
p2.Identity, _ = newIdentityFromCIdentity(unsafe.Pointer(p.identity))
p2.IdentityHash = hex.EncodeToString((*[48]byte)(unsafe.Pointer(&p.identityHash[0]))[:])
p2.Fingerprint = C.GoBytes(unsafe.Pointer(&p.fingerprint.hash[0]), 48)
p2.Version = [3]int{int(p.versionMajor), int(p.versionMinor), int(p.versionRev)}
p2.Latency = int(p.latency)
p2.Root = p.root != 0
@ -612,7 +611,7 @@ func (n *Node) Peers() []*Peer {
p2.Paths = make([]Path, 0, int(p.pathCount))
for j := 0; j < len(p2.Paths); j++ {
pt := &p.paths[j]
pt := (*C.ZT_PeerPhysicalPath)(unsafe.Pointer(uintptr(unsafe.Pointer(p.paths)) + uintptr(j * C.sizeof_ZT_PeerPhysicalPath)))
if pt.alive != 0 {
a := sockaddrStorageToUDPAddr(&pt.address)
if a != nil {
@ -629,7 +628,7 @@ func (n *Node) Peers() []*Peer {
peers = append(peers, p2)
}
C.ZT_Node_freeQueryResult(unsafe.Pointer(n.zn), unsafe.Pointer(pl))
C.ZT_Node_freeQueryResult(n.zn, unsafe.Pointer(pl))
}
sort.Slice(peers, func(a, b int) bool {
return peers[a].Address < peers[b].Address
@ -640,11 +639,11 @@ func (n *Node) Peers() []*Peer {
// --------------------------------------------------------------------------------------------------------------------
func (n *Node) multicastSubscribe(nwid uint64, mg *MulticastGroup) {
C.ZT_Node_multicastSubscribe(unsafe.Pointer(n.zn), nil, C.uint64_t(nwid), C.uint64_t(mg.MAC), C.ulong(mg.ADI))
C.ZT_Node_multicastSubscribe(n.zn, nil, C.uint64_t(nwid), C.uint64_t(mg.MAC), C.ulong(mg.ADI))
}
func (n *Node) multicastUnsubscribe(nwid uint64, mg *MulticastGroup) {
C.ZT_Node_multicastUnsubscribe(unsafe.Pointer(n.zn), C.uint64_t(nwid), C.uint64_t(mg.MAC), C.ulong(mg.ADI))
C.ZT_Node_multicastUnsubscribe(n.zn, C.uint64_t(nwid), C.uint64_t(mg.MAC), C.ulong(mg.ADI))
}
func (n *Node) pathCheck(ip net.IP) bool {

View file

@ -17,7 +17,7 @@ package zerotier
type Peer struct {
Address Address `json:"address"`
Identity *Identity `json:"identity"`
IdentityHash string `json:"identityHash"`
Fingerprint []byte `json:"fingerprint"`
Version [3]int `json:"version"`
Latency int `json:"latency"`
Root bool `json:"root"`

View file

@ -1361,6 +1361,11 @@ typedef struct
*/
const ZT_Identity *identity;
/**
* SHA-384 of identity public key(s)
*/
ZT_Fingerprint fingerprint;
/**
* Remote major version or -1 if not known
*/

View file

@ -483,6 +483,8 @@ ZT_PeerList *Node::peers() const
p->address = (*pi)->address().toInt();
identities[pl->peerCount] = (*pi)->identity(); // need to make a copy in case peer gets deleted
p->identity = &identities[pl->peerCount];
p->fingerprint.address = p->address;
memcpy(p->fingerprint.hash,(*pi)->identity().fingerprint().hash(),ZT_IDENTITY_HASH_SIZE);
if ((*pi)->remoteVersionKnown()) {
p->versionMajor = (int)(*pi)->remoteVersionMajor();
p->versionMinor = (int)(*pi)->remoteVersionMinor();

View file

@ -308,7 +308,7 @@ int main(int argc,char **argv)
return ZT_MACETHERNETTAPAGENT_EXIT_CODE_UNABLE_TO_CREATE;
}
fprintf(stderr,"I %s %s %d.%d.%d.%d\n",s_deviceName,s_peerDeviceName,ZEROTIER_ONE_VERSION_MAJOR,ZEROTIER_ONE_VERSION_MINOR,ZEROTIER_ONE_VERSION_REVISION,ZEROTIER_ONE_VERSION_BUILD);
fprintf(stderr,"I %s %s %d.%d.%d.%d\n",s_deviceName,s_peerDeviceName,ZEROTIER_VERSION_MAJOR,ZEROTIER_VERSION_MINOR,ZEROTIER_VERSION_REVISION,ZEROTIER_VERSION_BUILD);
FD_ZERO(&rfds);
FD_ZERO(&wfds);

View file

@ -74,7 +74,7 @@
#include <json.hpp>
#include <httplib.h>
#include <Packet.hpp>
#include <Protocol.hpp>
#include <Utils.hpp>
#include <Address.hpp>
#include <Identity.hpp>
@ -140,7 +140,7 @@ struct RootPeer
int vProto; // Protocol version or -1 if unknown
int vMajor,vMinor,vRev; // Peer version or -1,-1,-1 if unknown
Atomic __refCount;
std::atomic<int> __refCount;
};
// Hashers for std::unordered_map
@ -191,10 +191,10 @@ static std::map< std::pair< uint32_t,uint32_t >,std::pair< float,float > > s_geo
static std::map< std::pair< std::array< uint64_t,2 >,std::array< uint64_t,2 > >,std::pair< float,float > > s_geoIp6;
// Rate meters for statistical purposes (locks are internal to Meter)
static Meter s_inputRate;
static Meter s_outputRate;
static Meter s_forwardRate;
static Meter s_discardedForwardRate;
static Meter<> s_inputRate;
static Meter<> s_outputRate;
static Meter<> s_forwardRate;
static Meter<> s_discardedForwardRate;
// These fields are locked using mutexes below as they're modified during runtime
static std::string s_planet;