mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
OMG Windows builds!
This commit is contained in:
parent
a472aafb3e
commit
224c468aa3
6 changed files with 32 additions and 19 deletions
|
@ -61,17 +61,22 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
add_definitions(-DZT_DEBUG)
|
add_definitions(-DZT_DEBUG)
|
||||||
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
|
||||||
set(GOFLAGS
|
|
||||||
-trimpath
|
|
||||||
-buildmode=pie
|
|
||||||
)
|
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
|
||||||
message("++ Setting Windows Compiler Flags ${CMAKE_BUILD_TYPE}")
|
message("++ Setting Windows Compiler Flags ${CMAKE_BUILD_TYPE}")
|
||||||
add_definitions(-DNOMINMAX)
|
add_definitions(-DNOMINMAX)
|
||||||
|
|
||||||
|
set(GOFLAGS
|
||||||
|
-trimpath
|
||||||
|
)
|
||||||
|
|
||||||
else(WIN32)
|
else(WIN32)
|
||||||
|
|
||||||
|
set(GOFLAGS
|
||||||
|
-trimpath
|
||||||
|
-buildmode=pie
|
||||||
|
)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
|
|
||||||
message("++ Setting MacOS Compiler Flags ${CMAKE_BUILD_TYPE}")
|
message("++ Setting MacOS Compiler Flags ${CMAKE_BUILD_TYPE}")
|
||||||
|
@ -183,16 +188,23 @@ file(GLOB go_src
|
||||||
${CMAKE_SOURCE_DIR}/cmd/cmd/*.go
|
${CMAKE_SOURCE_DIR}/cmd/cmd/*.go
|
||||||
${CMAKE_SOURCE_DIR}/pkg/zerotier/*.go)
|
${CMAKE_SOURCE_DIR}/pkg/zerotier/*.go)
|
||||||
|
|
||||||
set(CXX_CORE_LIBRARIES "-lc++")
|
if(WIN32)
|
||||||
|
set(GO_EXE_NAME "zerotier.exe")
|
||||||
|
set(GO_EXTRA_LIBRARIES "-lstdc++ -lwsock32 -lws2_32 -liphlpapi -lole32 -loleaut32 -lrpcrt4 -luuid")
|
||||||
|
else(WIN32)
|
||||||
|
set(GO_EXE_NAME "zerotier")
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
set(CXX_CORE_LIBRARIES "-lstdc++")
|
set(GO_EXTRA_LIBRARIES "-lstdc++")
|
||||||
endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
else()
|
||||||
|
set(GO_EXTRA_LIBRARIES "-lc++")
|
||||||
|
endif()
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
zerotier ALL
|
zerotier ALL
|
||||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/zerotier
|
BYPRODUCTS ${CMAKE_BINARY_DIR}/zerotier
|
||||||
SOURCES ${go_src}
|
SOURCES ${go_src}
|
||||||
COMMAND ${GOARCH} CGO_ENABLED=1 CGO_CFLAGS=\"-O3\" CGO_LDFLAGS=\"$<TARGET_FILE:zt_core> $<TARGET_FILE:zt_controller> $<TARGET_FILE:zt_service_io_core> $<TARGET_FILE:zt_osdep> ${CXX_CORE_LIBRARIES}\" ${GO} build ${GOFLAGS} -o ${CMAKE_BINARY_DIR}/zerotier ${CMAKE_SOURCE_DIR}/cmd/zerotier/zerotier.go
|
COMMAND ${CMAKE_COMMAND} -E env "${GOARCH} CGO_ENABLED=1 CGO_CFLAGS=\"-O3\" CGO_LDFLAGS=\"$<TARGET_FILE:zt_core> $<TARGET_FILE:zt_controller> $<TARGET_FILE:zt_service_io_core> $<TARGET_FILE:zt_osdep> ${GO_EXTRA_LIBRARIES}\"" ${GO} build ${GOFLAGS} -o ${CMAKE_BINARY_DIR}/${GO_EXE_NAME} ${CMAKE_SOURCE_DIR}/cmd/zerotier/zerotier.go
|
||||||
COMMENT "Compiling Go Code..."
|
COMMENT "Compiling Go Code..."
|
||||||
)
|
)
|
||||||
add_dependencies(zerotier zt_osdep zt_core zt_controller zt_service_io_core)
|
add_dependencies(zerotier zt_osdep zt_core zt_controller zt_service_io_core)
|
||||||
|
|
|
@ -2,3 +2,4 @@ echo off
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake .. -G "MinGW Makefiles"
|
cmake .. -G "MinGW Makefiles"
|
||||||
|
make -j4
|
||||||
|
|
|
@ -39,8 +39,7 @@ func Service(basePath, authToken string, args []string) {
|
||||||
fmt.Println("FATAL: error initializing node: " + err.Error())
|
fmt.Println("FATAL: error initializing node: " + err.Error())
|
||||||
} else {
|
} else {
|
||||||
osSignalChannel := make(chan os.Signal, 2)
|
osSignalChannel := make(chan os.Signal, 2)
|
||||||
signal.Notify(osSignalChannel, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGINT, syscall.SIGSTOP)
|
signal.Notify(osSignalChannel, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGINT)
|
||||||
signal.Ignore(syscall.SIGUSR1, syscall.SIGUSR2, syscall.SIGPIPE, syscall.SIGHUP)
|
|
||||||
<-osSignalChannel
|
<-osSignalChannel
|
||||||
node.Close()
|
node.Close()
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,6 @@
|
||||||
#include "EthernetTap.hpp"
|
#include "EthernetTap.hpp"
|
||||||
#include "OSUtils.hpp"
|
#include "OSUtils.hpp"
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#ifdef ZT_SDK
|
#ifdef ZT_SDK
|
||||||
|
|
||||||
#include "../controller/EmbeddedNetworkController.hpp"
|
#include "../controller/EmbeddedNetworkController.hpp"
|
||||||
|
|
|
@ -829,7 +829,8 @@ void WindowsEthernetTap::setFriendlyName(const char *dn)
|
||||||
if (hr != S_OK) return;
|
if (hr != S_OK) return;
|
||||||
|
|
||||||
INetSharingManager *nsm;
|
INetSharingManager *nsm;
|
||||||
hr = CoCreateInstance(__uuidof(NetSharingManager), NULL, CLSCTX_ALL, __uuidof(INetSharingManager), (void**)&nsm);
|
//hr = CoCreateInstance(__uuidof(NetSharingManager), NULL, CLSCTX_ALL, __uuidof(INetSharingManager), (void**)&nsm);
|
||||||
|
hr = CoCreateInstance(CLSID_NetSharingManager, NULL, CLSCTX_ALL, IID_INetSharingManager, (void**)&nsm);
|
||||||
if (hr != S_OK) return;
|
if (hr != S_OK) return;
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
@ -844,7 +845,8 @@ void WindowsEthernetTap::setFriendlyName(const char *dn)
|
||||||
IUnknown *unk = nullptr;
|
IUnknown *unk = nullptr;
|
||||||
hr = nsecc->get__NewEnum(&unk);
|
hr = nsecc->get__NewEnum(&unk);
|
||||||
if (unk) {
|
if (unk) {
|
||||||
hr = unk->QueryInterface(__uuidof(IEnumVARIANT), (void**)&ev);
|
//hr = unk->QueryInterface(__uuidof(IEnumVARIANT), (void**)&ev);
|
||||||
|
hr = unk->QueryInterface(IID_IEnumVARIANT, (void**)&ev);
|
||||||
unk->Release();
|
unk->Release();
|
||||||
}
|
}
|
||||||
if (ev) {
|
if (ev) {
|
||||||
|
@ -854,7 +856,8 @@ void WindowsEthernetTap::setFriendlyName(const char *dn)
|
||||||
while ((S_OK == ev->Next(1, &v, NULL)) && found == FALSE) {
|
while ((S_OK == ev->Next(1, &v, NULL)) && found == FALSE) {
|
||||||
if (V_VT(&v) == VT_UNKNOWN) {
|
if (V_VT(&v) == VT_UNKNOWN) {
|
||||||
INetConnection *nc = nullptr;
|
INetConnection *nc = nullptr;
|
||||||
V_UNKNOWN(&v)->QueryInterface(__uuidof(INetConnection), (void**)&nc);
|
//V_UNKNOWN(&v)->QueryInterface(__uuidof(INetConnection), (void**)&nc);
|
||||||
|
V_UNKNOWN(&v)->QueryInterface(IID_INetConnection, (void**)&nc);
|
||||||
if (nc) {
|
if (nc) {
|
||||||
NETCON_PROPERTIES *ncp = nullptr;
|
NETCON_PROPERTIES *ncp = nullptr;
|
||||||
nc->GetProperties(&ncp);
|
nc->GetProperties(&ncp);
|
||||||
|
|
|
@ -17,6 +17,7 @@ package zerotier
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
winio "github.com/Microsoft/go-winio"
|
winio "github.com/Microsoft/go-winio"
|
||||||
)
|
)
|
||||||
|
@ -24,7 +25,7 @@ import (
|
||||||
const windowsAPISocketPathPrefix = "\\\\.\\pipe\\zerotier_"
|
const windowsAPISocketPathPrefix = "\\\\.\\pipe\\zerotier_"
|
||||||
|
|
||||||
func createNamedSocketListener(basePath, name string) (net.Listener, error) {
|
func createNamedSocketListener(basePath, name string) (net.Listener, error) {
|
||||||
winio.ListenPipe(windowsAPISocketPathPrefix+name, nil)
|
return winio.ListenPipe(windowsAPISocketPathPrefix+name, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNamedSocketHTTPClient(basePath, name string) (*http.Client, error) {
|
func createNamedSocketHTTPClient(basePath, name string) (*http.Client, error) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue