diff --git a/src/config/config.go b/src/config/config.go index 5c0d5306..72ff6569 100644 --- a/src/config/config.go +++ b/src/config/config.go @@ -43,15 +43,15 @@ type NodeConfig struct { } type MulticastInterfaceConfig struct { - Regex string - Beacon bool - Listen bool - Port uint16 + Regex string + Beacon bool + Listen bool + Port uint16 Priority uint64 // really uint8, but gobind won't export it } type NetworkDomainConfig struct { - Prefix [1]byte + Prefix string } // NewSigningKeys replaces the signing keypair in the NodeConfig with a new diff --git a/src/core/address.go b/src/core/address.go index 713fb920..3e0738db 100644 --- a/src/core/address.go +++ b/src/core/address.go @@ -4,6 +4,7 @@ package core import ( "crypto/ed25519" + "encoding/hex" ) // Address represents an IPv6 address in the mesh address range. @@ -17,7 +18,13 @@ type Subnet [8]byte // The 8th bit of the last byte is used to signal nodes (0) or /64 prefixes (1). // Nodes that configure this differently will be unable to communicate with each other using IP packets, though routing and the DHT machinery *should* still work. func (c *Core) GetPrefix() [1]byte { - return c.config.networkdomain.Prefix + p, err := hex.DecodeString(c.config.networkdomain.Prefix) + if err != nil { + panic(err) + } + var prefix [1]byte + copy(prefix[:], p[:1]) + return prefix } // IsValid returns true if an address falls within the range used by nodes in the network. diff --git a/src/core/options.go b/src/core/options.go index 80c374e8..318cc549 100644 --- a/src/core/options.go +++ b/src/core/options.go @@ -35,7 +35,7 @@ type Peer struct { type NodeInfo map[string]interface{} type NodeInfoPrivacy bool type NetworkDomain struct { - Prefix [1]byte + Prefix string } type AllowedPublicKey ed25519.PublicKey diff --git a/src/defaults/defaults_darwin.go b/src/defaults/defaults_darwin.go index 660d7644..670fca88 100644 --- a/src/defaults/defaults_darwin.go +++ b/src/defaults/defaults_darwin.go @@ -20,9 +20,9 @@ func getDefaults() platformDefaultParameters { }, // Network domain - DefaultNetworkDomain: NetworkDomainConfig{ - Prefix: [...]byte{0xfc}, - }, + DefaultNetworkDomain: NetworkDomainConfig{ + Prefix: "fc", + }, // TUN MaximumIfMTU: 65535, diff --git a/src/defaults/defaults_freebsd.go b/src/defaults/defaults_freebsd.go index 15be4ffe..2a50c25c 100644 --- a/src/defaults/defaults_freebsd.go +++ b/src/defaults/defaults_freebsd.go @@ -18,10 +18,10 @@ func getDefaults() platformDefaultParameters { {Regex: ".*", Beacon: true, Listen: true}, }, - // Network domain - DefaultNetworkDomain: NetworkDomainConfig{ - Prefix: [...]byte{0xfc}, - }, + // Network domain + DefaultNetworkDomain: NetworkDomainConfig{ + Prefix: "fc", + }, // TUN MaximumIfMTU: 32767, diff --git a/src/defaults/defaults_linux.go b/src/defaults/defaults_linux.go index 9fb40565..2c2690c7 100644 --- a/src/defaults/defaults_linux.go +++ b/src/defaults/defaults_linux.go @@ -18,10 +18,10 @@ func getDefaults() platformDefaultParameters { {Regex: ".*", Beacon: true, Listen: true}, }, - // Network domain - DefaultNetworkDomain: NetworkDomainConfig{ - Prefix: [...]byte{0xfc}, - }, + // Network domain + DefaultNetworkDomain: NetworkDomainConfig{ + Prefix: "fc", + }, // TUN MaximumIfMTU: 65535, diff --git a/src/defaults/defaults_openbsd.go b/src/defaults/defaults_openbsd.go index ce5db723..3772d07b 100644 --- a/src/defaults/defaults_openbsd.go +++ b/src/defaults/defaults_openbsd.go @@ -18,10 +18,10 @@ func getDefaults() platformDefaultParameters { {Regex: ".*", Beacon: true, Listen: true}, }, - // Network domain - DefaultNetworkDomain: NetworkDomainConfig{ - Prefix: [...]byte{0xfc}, - }, + // Network domain + DefaultNetworkDomain: NetworkDomainConfig{ + Prefix: "fc", + }, // TUN MaximumIfMTU: 16384, diff --git a/src/defaults/defaults_other.go b/src/defaults/defaults_other.go index 3adb05e7..21c32160 100644 --- a/src/defaults/defaults_other.go +++ b/src/defaults/defaults_other.go @@ -18,10 +18,10 @@ func getDefaults() platformDefaultParameters { {Regex: ".*", Beacon: true, Listen: true}, }, - // Network domain - DefaultNetworkDomain: NetworkDomainConfig{ - Prefix: [...]byte{0xfc}, - }, + // Network domain + DefaultNetworkDomain: NetworkDomainConfig{ + Prefix: "fc", + }, // TUN MaximumIfMTU: 65535, diff --git a/src/defaults/defaults_windows.go b/src/defaults/defaults_windows.go index 79a2815f..95a8cc80 100644 --- a/src/defaults/defaults_windows.go +++ b/src/defaults/defaults_windows.go @@ -20,7 +20,7 @@ func getDefaults() platformDefaultParameters { // Network domain DefaultNetworkDomain: NetworkDomainConfig{ - Prefix: [...]byte{0xfc}, + Prefix: "fc", }, // TUN