Update build process, Go glue builds now.
This commit is contained in:
parent
ed2024285d
commit
e0ddbc2f28
7 changed files with 70 additions and 153 deletions
|
@ -124,6 +124,7 @@ static int ZT_GoNode_VirtualNetworkConfigFunction(
|
|||
if (cfg)
|
||||
ev.data.nconf.conf = *cfg;
|
||||
reinterpret_cast<ZT_GoNode *>(uptr)->eq.post(ev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ZT_GoNode_VirtualNetworkFrameFunction(
|
||||
|
@ -218,7 +219,7 @@ static ZT_ALWAYS_INLINE void doUdpSend(ZT_SOCKET sock,const struct sockaddr_stor
|
|||
}
|
||||
}
|
||||
|
||||
static void ZT_GoNode_WirePacketSendFunction(
|
||||
static int ZT_GoNode_WirePacketSendFunction(
|
||||
ZT_Node *node,
|
||||
void *uptr,
|
||||
void *tptr,
|
||||
|
@ -242,6 +243,7 @@ static void ZT_GoNode_WirePacketSendFunction(
|
|||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ZT_GoNode_PathCheckFunction(
|
||||
|
@ -291,14 +293,15 @@ extern "C" ZT_GoNode *ZT_GoNode_new(
|
|||
{
|
||||
try {
|
||||
struct ZT_Node_Callbacks cb;
|
||||
cb.virtualNetworkConfigFunction = &ZT_GoNode_VirtualNetworkConfigFunction;
|
||||
cb.virtualNetworkFrameFunction = &ZT_GoNode_VirtualNetworkFrameFunction;
|
||||
cb.eventCallback = &ZT_GoNode_EventCallback;
|
||||
cb.statePutFunction = &ZT_GoNode_StatePutFunction;
|
||||
cb.stateGetFunction = &ZT_GoNode_StateGetFunction;
|
||||
cb.wirePacketSendFunction = &ZT_GoNode_WirePacketSendFunction;
|
||||
cb.virtualNetworkFrameFunction = &ZT_GoNode_VirtualNetworkFrameFunction;
|
||||
cb.virtualNetworkConfigFunction = &ZT_GoNode_VirtualNetworkConfigFunction;
|
||||
cb.eventCallback = &ZT_GoNode_EventCallback;
|
||||
cb.dnsResolver = &ZT_GoNode_DNSResolver;
|
||||
cb.pathCheckFunction = &ZT_GoNode_PathCheckFunction;
|
||||
cb.pathLookupFunction = &ZT_GoNode_PathLookupFunction;
|
||||
cb.dnsResolver = &ZT_GoNode_DNSResolver;
|
||||
|
||||
ZT_GoNode_Impl *gn = new ZT_GoNode_Impl;
|
||||
const int64_t now = OSUtils::now();
|
||||
|
@ -334,17 +337,14 @@ extern "C" void ZT_GoNode_delete(ZT_GoNode *gn)
|
|||
sd.type = ZT_GONODE_EVENT_SHUTDOWN;
|
||||
gn->eq.post(sd);
|
||||
|
||||
std::vector<std::thread> th;
|
||||
gn->threads_l.lock();
|
||||
for(auto t=gn->threads.begin();t!=gn->threads.end();++t) {
|
||||
t->second.run = false;
|
||||
shutdown(t->first,SHUT_RDWR);
|
||||
close(t->first);
|
||||
th.emplace_back(t->second.thr);
|
||||
t->second.thr.join();
|
||||
}
|
||||
gn->threads_l.unlock();
|
||||
for(auto t=th.begin();t!=th.end();++t)
|
||||
t->join();
|
||||
|
||||
gn->taps_l.lock();
|
||||
for(auto t=gn->taps.begin();t!=gn->taps.end();++t)
|
||||
|
@ -518,9 +518,10 @@ extern "C" int ZT_GoNode_phyStopListen(ZT_GoNode *gn,const char *dev,const char
|
|||
} else ++t;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int ZT_GoNode_waitForEvent(ZT_GoNode *gn,ZT_GoNodeEvent *ev)
|
||||
extern "C" void ZT_GoNode_waitForEvent(ZT_GoNode *gn,ZT_GoNodeEvent *ev)
|
||||
{
|
||||
gn->eq.get(*ev);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ struct ZT_GoNodeEvent_Impl
|
|||
{
|
||||
#ifdef __cplusplus
|
||||
inline ZT_GoNodeEvent_Impl() { memset(reinterpret_cast<void *>(this),0,sizeof(ZT_GoNodeEvent_Impl)); }
|
||||
inline ZT_GoNodeEvent_Impl(const ZT_GoNodeEvent &ev) { memcpy(reinterpret_cast<void *>(this),reinterpret_cast<const void *>(&ev),sizeof(ZT_GoNodeEvent_Impl)); }
|
||||
inline ZT_GoNodeEvent_Impl(const ZT_GoNodeEvent_Impl &ev) { memcpy(reinterpret_cast<void *>(this),reinterpret_cast<const void *>(&ev),sizeof(ZT_GoNodeEvent_Impl)); }
|
||||
inline ZT_GoNodeEvent_Impl &operator=(const ZT_GoNodeEvent_Impl &ev) { memcpy(reinterpret_cast<void *>(this),reinterpret_cast<const void *>(&ev),sizeof(ZT_GoNodeEvent_Impl)); return *this; }
|
||||
#endif
|
||||
|
||||
|
@ -106,7 +106,7 @@ int ZT_GoNode_phyStartListen(ZT_GoNode *gn,const char *dev,const char *ip,const
|
|||
/* Close all listener threads for a given local IP and port */
|
||||
int ZT_GoNode_phyStopListen(ZT_GoNode *gn,const char *dev,const char *ip,const int port);
|
||||
|
||||
int ZT_GoNode_waitForEvent(ZT_GoNode *gn,ZT_GoNodeEvent *ev);
|
||||
void ZT_GoNode_waitForEvent(ZT_GoNode *gn,ZT_GoNodeEvent *ev);
|
||||
|
||||
ZT_GoTap *ZT_GoNode_join(ZT_GoNode *gn,uint64_t nwid);
|
||||
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
package ztnode
|
||||
|
||||
//#cgo CFLAGS: -O3
|
||||
//#cgo LDFLAGS: ${SRCDIR}/../../../build/node/libzt_core.a -lc++
|
||||
//#cgo LDFLAGS: ${SRCDIR}/../../../build/node/libzt_core.a ${SRCDIR}/../../../build/go/native/libzt_go_native.a -lc++
|
||||
//#define ZT_CGO 1
|
||||
//#include <stdint.h>
|
||||
//#include "../../../include/ZeroTierCore.h"
|
||||
//#include "../../native/GoGlue.h"
|
||||
//#if __has_include("../../../version.h")
|
||||
//#include "../../../version.h"
|
||||
//#else
|
||||
|
@ -27,6 +27,7 @@ package ztnode
|
|||
//#define ZEROTIER_ONE_VERSION_BUILD 255
|
||||
//#endif
|
||||
import "C"
|
||||
import "sync"
|
||||
|
||||
const (
|
||||
// CoreVersionMajor is the major version of the ZeroTier core
|
||||
|
@ -44,5 +45,11 @@ const (
|
|||
|
||||
// Node is an instance of a ZeroTier node
|
||||
type Node struct {
|
||||
node *C.ZT_Node
|
||||
gn *C.ZT_GoNode
|
||||
zn *C.ZT_Node
|
||||
}
|
||||
|
||||
var (
|
||||
nodesByUserPtr map[uintptr]*Node
|
||||
nodesByUserPtrLock sync.Mutex
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue