This commit is contained in:
Adam Ierymenko 2019-09-22 19:25:40 -07:00
parent 90d4d79828
commit 70d5da1e2a
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
5 changed files with 86 additions and 6 deletions

View file

@ -100,6 +100,9 @@ struct ZT_GoNode_Impl
std::thread backgroundTaskThread;
};
static const std::string defaultHomePath(OSUtils::platformDefaultHomePath());
extern "C" const char *ZT_PLATFORM_DEFAULT_HOMEPATH = defaultHomePath.c_str();
/****************************************************************************/
/* These functions are implemented in Go in pkg/ztnode/node-callbacks.go */

View file

@ -48,6 +48,7 @@ extern "C" {
/****************************************************************************/
const char *ZT_PLATFORM_DEFAULT_HOMEPATH;
/****************************************************************************/

View file

@ -0,0 +1,73 @@
/*
* Copyright (c)2019 ZeroTier, Inc.
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file in the project's root directory.
*
* Change Date: 2023-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/
/****/
package zerotier
import (
"net"
"runtime"
)
// LocalConfigPhysicalPathConfiguration contains settings for physical paths
type LocalConfigPhysicalPathConfiguration struct {
Blacklist bool
TrustedPathID uint64
}
// LocalConfigVirtualAddressConfiguration contains settings for virtual addresses
type LocalConfigVirtualAddressConfiguration struct {
Try []net.Addr
}
// LocalConfigSettings contains node settings
type LocalConfigSettings struct {
PrimaryPort int
SecondaryPort int
TertiaryPort int
PortMappingEnabled bool
MuiltipathMode int
InterfacePrefixBlacklist []string
}
// LocalConfig is the local.conf file and stores local settings for the node.
type LocalConfig struct {
Physical map[string]LocalConfigPhysicalPathConfiguration
Virtual map[Address]LocalConfigVirtualAddressConfiguration
Settings LocalConfigSettings
}
// NewLocalConfig creates a new local.conf file with defaults
func NewLocalConfig() *LocalConfig {
lc := &LocalConfig{
Physical: make(map[string]LocalConfigPhysicalPathConfiguration),
Virtual: make(map[Address]LocalConfigVirtualAddressConfiguration),
Settings: LocalConfigSettings{
PrimaryPort: 9993,
SecondaryPort: 0,
TertiaryPort: 0,
PortMappingEnabled: true,
MuiltipathMode: 0,
},
}
switch runtime.GOOS {
case "darwin":
lc.Settings.InterfacePrefixBlacklist = []string{"utun", "tun", "tap", "feth", "lo", "zt"}
case "linux":
lc.Settings.InterfacePrefixBlacklist = []string{"tun", "tap", "lo", "zt"}
case "freebsd", "openbsd", "netbsd", "illumos", "solaris", "dragonfly":
lc.Settings.InterfacePrefixBlacklist = []string{"tun", "tap", "zt"}
case "android":
lc.Settings.InterfacePrefixBlacklist = []string{"tun", "tap"}
}
return lc
}

View file

@ -56,6 +56,9 @@ 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 = C.AF_INET
afInet6 = C.AF_INET6
)