mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-20 08:50:49 +00:00
.
This commit is contained in:
parent
9c37fc1a5f
commit
570032484f
131
.gitignore
vendored
131
.gitignore
vendored
@ -1,19 +1,56 @@
|
||||
# Main binaries created in *nix builds
|
||||
/zerotier-one
|
||||
/zerotier-idtool
|
||||
/zerotier-cli
|
||||
/zerotier-selftest
|
||||
/zerotier
|
||||
/nltest
|
||||
|
||||
# OS-created garbage files from various platforms
|
||||
build/
|
||||
/version.h
|
||||
.DS_Store
|
||||
.Trashes
|
||||
*.swp
|
||||
._*
|
||||
*~
|
||||
*~.nib
|
||||
.Apple*
|
||||
Thumbs.db
|
||||
@eaDir
|
||||
._*
|
||||
DerivedData/
|
||||
*.pbxuser
|
||||
*.mode1v3
|
||||
*.mode2v3
|
||||
*.perspectivev3
|
||||
!default.pbxuser
|
||||
!default.mode1v3
|
||||
!default.mode2v3
|
||||
!default.perspectivev3
|
||||
*.xccheckout
|
||||
xcuserdata/
|
||||
.vscode
|
||||
__pycache__
|
||||
attic/world/*.c25519
|
||||
attic/world/mkworld
|
||||
*.log
|
||||
*.opensdf
|
||||
*.user
|
||||
*.cache
|
||||
*.obj
|
||||
*.tlog
|
||||
*.pid
|
||||
*.pkg
|
||||
*.o
|
||||
*.o-*
|
||||
*.core
|
||||
*.deb
|
||||
*.rpm
|
||||
*.autosave
|
||||
*.tmp
|
||||
.depend
|
||||
node_modules
|
||||
debian/files
|
||||
debian/zerotier-one
|
||||
debian/zerotier-one*.debhelper
|
||||
debian/*.log
|
||||
debian/zerotier-one.substvars
|
||||
root/identity.*
|
||||
root/config.*
|
||||
/ext/installfiles/windows/chocolatey/zerotier-one/*.nupkg
|
||||
/go/zerotier
|
||||
|
||||
# Windows build droppings
|
||||
/windows/ZeroTierOne.sdf
|
||||
/windows/ZeroTierOne.v11.suo
|
||||
/windows/x64
|
||||
@ -32,7 +69,7 @@ Thumbs.db
|
||||
/ext/installfiles/windows/ZeroTier One-SetupFiles
|
||||
/ext/installfiles/windows/Prerequisites
|
||||
/ext/installfiles/windows/*-cache
|
||||
/ZeroTier One.msi
|
||||
/*.msi
|
||||
/windows/.vs
|
||||
*.vcxproj.backup
|
||||
/windows/TapDriver6/Win7Debug
|
||||
@ -43,50 +80,6 @@ enc_temp_folder
|
||||
/windows/copyutil/bin
|
||||
/windows/copyutil/obj
|
||||
|
||||
# *nix/Mac build droppings
|
||||
/build-*
|
||||
/ZeroTierOneInstaller-*
|
||||
/examples/docker/zerotier-one
|
||||
/examples/docker/test-*.env
|
||||
/world/mkworld
|
||||
/world/*.c25519
|
||||
zt1-src.tar.gz
|
||||
/MacEthernetTapAgent
|
||||
|
||||
# Miscellaneous temporaries, build files, etc.
|
||||
*.log
|
||||
*.opensdf
|
||||
*.user
|
||||
*.cache
|
||||
*.obj
|
||||
*.tlog
|
||||
*.pid
|
||||
*.pkg
|
||||
*.o
|
||||
/*.a
|
||||
*.dylib
|
||||
*.so
|
||||
*.so.*
|
||||
*.o-*
|
||||
*.core
|
||||
*.deb
|
||||
*.rpm
|
||||
*.autosave
|
||||
*.tmp
|
||||
.depend
|
||||
node_modules
|
||||
zt1_update_*
|
||||
debian/files
|
||||
debian/zerotier-one
|
||||
debian/zerotier-one*.debhelper
|
||||
debian/*.log
|
||||
debian/zerotier-one.substvars
|
||||
root-watcher/config.json
|
||||
root/identity.*
|
||||
root/zerotier-root
|
||||
root/config.*
|
||||
|
||||
# Java/Android/JNI build droppings
|
||||
java/obj/
|
||||
java/libs/
|
||||
java/bin/
|
||||
@ -98,29 +91,3 @@ java/build_win32/
|
||||
windows/WinUI/obj/
|
||||
windows/WinUI/bin/
|
||||
windows/ZeroTierOne/Debug/
|
||||
/ext/installfiles/windows/chocolatey/zerotier-one/*.nupkg
|
||||
|
||||
# Miscellaneous mac/Xcode droppings
|
||||
.DS_Store
|
||||
.Trashes
|
||||
*.swp
|
||||
*~.nib
|
||||
DerivedData/
|
||||
build/
|
||||
*.pbxuser
|
||||
*.mode1v3
|
||||
*.mode2v3
|
||||
*.perspectivev3
|
||||
!default.pbxuser
|
||||
!default.mode1v3
|
||||
!default.mode2v3
|
||||
!default.perspectivev3
|
||||
*.xccheckout
|
||||
xcuserdata/
|
||||
ext/librethinkdbxx/build
|
||||
.vscode
|
||||
__pycache__
|
||||
*~
|
||||
attic/world/*.c25519
|
||||
attic/world/mkworld
|
||||
/version.h
|
||||
|
2
go/Makefile
Normal file
2
go/Makefile
Normal file
@ -0,0 +1,2 @@
|
||||
all:
|
||||
go build -o zerotier cmd/zerotier/zerotier.go
|
@ -37,9 +37,7 @@ func Service(basePath, authToken string, args []string) {
|
||||
osSignalChannel := make(chan os.Signal, 2)
|
||||
signal.Notify(osSignalChannel, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGINT, syscall.SIGBUS)
|
||||
signal.Ignore(syscall.SIGUSR1, syscall.SIGUSR2)
|
||||
go func() {
|
||||
<-osSignalChannel
|
||||
node.Close()
|
||||
os.Exit(0)
|
||||
}()
|
||||
<-osSignalChannel
|
||||
node.Close()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
@ -54,6 +54,13 @@ func readAuthToken(basePath string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func authTokenRequired(authToken string) {
|
||||
if len(authToken) == 0 {
|
||||
fmt.Println("FATAL: unable to read API authorization token from service path or user home ('sudo' may be needed)")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
globalOpts := flag.NewFlagSet("global", flag.ContinueOnError)
|
||||
hflag := globalOpts.Bool("h", false, "") // support -h to be canonical with other Unix utilities
|
||||
@ -81,16 +88,13 @@ func main() {
|
||||
if len(*pflag) > 0 {
|
||||
basePath = *pflag
|
||||
}
|
||||
|
||||
var authToken string
|
||||
if len(*tflag) > 0 {
|
||||
authToken = *tflag
|
||||
} else {
|
||||
authToken = readAuthToken(basePath)
|
||||
}
|
||||
if len(authToken) == 0 {
|
||||
fmt.Println("FATAL: unable to read API authorization token from service path or user home ('sudo' may be needed)")
|
||||
os.Exit(1)
|
||||
}
|
||||
authToken = strings.TrimSpace(authToken)
|
||||
|
||||
switch args[0] {
|
||||
@ -103,24 +107,34 @@ func main() {
|
||||
case "service":
|
||||
cli.Service(basePath, authToken, cmdArgs)
|
||||
case "status":
|
||||
authTokenRequired(authToken)
|
||||
cli.Status(basePath, authToken, cmdArgs, *jflag)
|
||||
case "peers":
|
||||
authTokenRequired(authToken)
|
||||
cli.Peers(basePath, authToken, cmdArgs)
|
||||
case "roots":
|
||||
authTokenRequired(authToken)
|
||||
cli.Roots(basePath, authToken, cmdArgs)
|
||||
case "addroot":
|
||||
authTokenRequired(authToken)
|
||||
cli.AddRoot(basePath, authToken, cmdArgs)
|
||||
case "removeroot":
|
||||
authTokenRequired(authToken)
|
||||
cli.RemoveRoot(basePath, authToken, cmdArgs)
|
||||
case "networks":
|
||||
authTokenRequired(authToken)
|
||||
cli.Networks(basePath, authToken, cmdArgs)
|
||||
case "join":
|
||||
authTokenRequired(authToken)
|
||||
cli.Join(basePath, authToken, cmdArgs)
|
||||
case "leave":
|
||||
authTokenRequired(authToken)
|
||||
cli.Leave(basePath, authToken, cmdArgs)
|
||||
case "show":
|
||||
authTokenRequired(authToken)
|
||||
cli.Show(basePath, authToken, cmdArgs)
|
||||
case "set":
|
||||
authTokenRequired(authToken)
|
||||
cli.Set(basePath, authToken, cmdArgs)
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "../../node/Address.hpp"
|
||||
#include "../../osdep/OSUtils.hpp"
|
||||
#include "../../osdep/EthernetTap.hpp"
|
||||
#include "../../osdep/ManagedRoute.hpp"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
@ -102,7 +103,7 @@ struct ZT_GoNode_Impl
|
||||
};
|
||||
|
||||
static const std::string defaultHomePath(OSUtils::platformDefaultHomePath());
|
||||
extern "C" const char *ZT_PLATFORM_DEFAULT_HOMEPATH = defaultHomePath.c_str();
|
||||
const char *ZT_PLATFORM_DEFAULT_HOMEPATH = defaultHomePath.c_str();
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
@ -108,7 +108,7 @@ func (lc *LocalConfig) Read(p string, saveDefaultsIfNotExist bool) error {
|
||||
|
||||
data, err := ioutil.ReadFile(p)
|
||||
if err != nil {
|
||||
if err != os.ErrNotExist {
|
||||
if !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
if saveDefaultsIfNotExist {
|
||||
|
@ -328,7 +328,7 @@ func (n *Network) updateConfig(nc *NetworkConfig, ls *NetworkLocalSettings) {
|
||||
k := r.key()
|
||||
wantManagedRoutes[k] = true
|
||||
if _, have := haveManagedRoutes[k]; !have {
|
||||
n.node.log.Printf("%.16x adding managed route %s", n.ID, r.Target.String())
|
||||
n.node.log.Printf("%.16x adding managed route %s", n.ID, r.String())
|
||||
n.tap.AddRoute(&r)
|
||||
}
|
||||
}
|
||||
@ -336,7 +336,7 @@ func (n *Network) updateConfig(nc *NetworkConfig, ls *NetworkLocalSettings) {
|
||||
}
|
||||
for k, r := range haveManagedRoutes {
|
||||
if _, want := wantManagedRoutes[k]; !want {
|
||||
n.node.log.Printf("%.16x removing managed route %s", n.ID, r.Target.String())
|
||||
n.node.log.Printf("%.16x removing managed route %s", n.ID, r.String())
|
||||
n.tap.RemoveRoute(r)
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ package zerotier
|
||||
// and generally contains all the other CGO stuff.
|
||||
|
||||
//#cgo CFLAGS: -O3
|
||||
//#cgo LDFLAGS: ${SRCDIR}/../../../build/node/libzt_core.a ${SRCDIR}/../../../build/osdep/libzt_osdep.a ${SRCDIR}/../../../build/go/native/libzt_go_native.a -lc++ -lpthread
|
||||
//#define ZT_CGO 1
|
||||
//#cgo darwin LDFLAGS: ${SRCDIR}/../../../build/go/native/libzt_go_native.a ${SRCDIR}/../../../build/node/libzt_core.a ${SRCDIR}/../../../build/osdep/libzt_osdep.a -lc++ -lpthread
|
||||
//#cgo linux android LDFLAGS: ${SRCDIR}/../../../build/go/native/libzt_go_native.a ${SRCDIR}/../../../build/node/libzt_core.a ${SRCDIR}/../../../build/osdep/libzt_osdep.a -lstdc++ -lpthread -lm
|
||||
//#include "../../native/GoGlue.h"
|
||||
import "C"
|
||||
|
||||
@ -68,9 +68,6 @@ const (
|
||||
// CoreVersionBuild is the build version of the ZeroTier core
|
||||
CoreVersionBuild int = C.ZEROTIER_ONE_VERSION_BUILD
|
||||
|
||||
// PlatformDefaultHomePath is the default location of ZeroTier's working path on this system
|
||||
PlatformDefaultHomePath string = C.GoString(C.ZT_PLATFORM_DEFAULT_HOMEPATH)
|
||||
|
||||
// AFInet is the address family for IPv4
|
||||
AFInet = C.AF_INET
|
||||
|
||||
@ -81,7 +78,10 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
nodesByUserPtr map[uintptr]*Node
|
||||
// PlatformDefaultHomePath is the default location of ZeroTier's working path on this system
|
||||
PlatformDefaultHomePath string = C.GoString(C.ZT_PLATFORM_DEFAULT_HOMEPATH)
|
||||
|
||||
nodesByUserPtr = make(map[uintptr]*Node)
|
||||
nodesByUserPtrLock sync.RWMutex
|
||||
)
|
||||
|
||||
@ -862,7 +862,7 @@ func goVirtualNetworkConfigFunc(gn, tapP unsafe.Pointer, nwid C.uint64_t, op C.i
|
||||
return
|
||||
}
|
||||
node.networksLock.RLock()
|
||||
network := node.networks[uint64(nwid)]
|
||||
network := node.networks[NetworkID(nwid)]
|
||||
node.networksLock.RUnlock()
|
||||
if network != nil {
|
||||
ncc := (*C.ZT_VirtualNetworkConfig)(conf)
|
||||
@ -1124,7 +1124,7 @@ func handleTapMulticastGroupChange(gn unsafe.Pointer, nwid, mac C.uint64_t, adi
|
||||
return
|
||||
}
|
||||
node.networksLock.RLock()
|
||||
network := node.networks[uint64(nwid)]
|
||||
network := node.networks[NetworkID(nwid)]
|
||||
node.networksLock.RUnlock()
|
||||
if network != nil {
|
||||
tap, _ := network.tap.(*nativeTap)
|
||||
|
@ -33,6 +33,14 @@ type Route struct {
|
||||
Metric uint16
|
||||
}
|
||||
|
||||
// String returns a string representation of this route
|
||||
func (r *Route) String() string {
|
||||
if len(r.Via) == 0 {
|
||||
return r.Target.String() + "->LAN"
|
||||
}
|
||||
return r.Target.String() + "->" + r.Via.String()
|
||||
}
|
||||
|
||||
// key generates a key suitable for a map[] from this route
|
||||
func (r *Route) key() (k [6]uint64) {
|
||||
copy(((*[16]byte)(unsafe.Pointer(&k[0])))[:], r.Target.IP)
|
||||
|
Loading…
x
Reference in New Issue
Block a user