changed NetworkDomain.Prefix format from []byte to string for more conveniant input

This commit is contained in:
vadym 2022-12-09 13:51:21 +02:00
parent f84f0a5f19
commit 3e72a57ec5
9 changed files with 34 additions and 27 deletions

View file

@ -43,15 +43,15 @@ type NodeConfig struct {
} }
type MulticastInterfaceConfig struct { type MulticastInterfaceConfig struct {
Regex string Regex string
Beacon bool Beacon bool
Listen bool Listen bool
Port uint16 Port uint16
Priority uint64 // really uint8, but gobind won't export it Priority uint64 // really uint8, but gobind won't export it
} }
type NetworkDomainConfig struct { type NetworkDomainConfig struct {
Prefix [1]byte Prefix string
} }
// NewSigningKeys replaces the signing keypair in the NodeConfig with a new // NewSigningKeys replaces the signing keypair in the NodeConfig with a new

View file

@ -4,6 +4,7 @@ package core
import ( import (
"crypto/ed25519" "crypto/ed25519"
"encoding/hex"
) )
// Address represents an IPv6 address in the mesh address range. // 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). // 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. // 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 { 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. // IsValid returns true if an address falls within the range used by nodes in the network.

View file

@ -35,7 +35,7 @@ type Peer struct {
type NodeInfo map[string]interface{} type NodeInfo map[string]interface{}
type NodeInfoPrivacy bool type NodeInfoPrivacy bool
type NetworkDomain struct { type NetworkDomain struct {
Prefix [1]byte Prefix string
} }
type AllowedPublicKey ed25519.PublicKey type AllowedPublicKey ed25519.PublicKey

View file

@ -20,9 +20,9 @@ func getDefaults() platformDefaultParameters {
}, },
// Network domain // Network domain
DefaultNetworkDomain: NetworkDomainConfig{ DefaultNetworkDomain: NetworkDomainConfig{
Prefix: [...]byte{0xfc}, Prefix: "fc",
}, },
// TUN // TUN
MaximumIfMTU: 65535, MaximumIfMTU: 65535,

View file

@ -18,10 +18,10 @@ func getDefaults() platformDefaultParameters {
{Regex: ".*", Beacon: true, Listen: true}, {Regex: ".*", Beacon: true, Listen: true},
}, },
// Network domain // Network domain
DefaultNetworkDomain: NetworkDomainConfig{ DefaultNetworkDomain: NetworkDomainConfig{
Prefix: [...]byte{0xfc}, Prefix: "fc",
}, },
// TUN // TUN
MaximumIfMTU: 32767, MaximumIfMTU: 32767,

View file

@ -18,10 +18,10 @@ func getDefaults() platformDefaultParameters {
{Regex: ".*", Beacon: true, Listen: true}, {Regex: ".*", Beacon: true, Listen: true},
}, },
// Network domain // Network domain
DefaultNetworkDomain: NetworkDomainConfig{ DefaultNetworkDomain: NetworkDomainConfig{
Prefix: [...]byte{0xfc}, Prefix: "fc",
}, },
// TUN // TUN
MaximumIfMTU: 65535, MaximumIfMTU: 65535,

View file

@ -18,10 +18,10 @@ func getDefaults() platformDefaultParameters {
{Regex: ".*", Beacon: true, Listen: true}, {Regex: ".*", Beacon: true, Listen: true},
}, },
// Network domain // Network domain
DefaultNetworkDomain: NetworkDomainConfig{ DefaultNetworkDomain: NetworkDomainConfig{
Prefix: [...]byte{0xfc}, Prefix: "fc",
}, },
// TUN // TUN
MaximumIfMTU: 16384, MaximumIfMTU: 16384,

View file

@ -18,10 +18,10 @@ func getDefaults() platformDefaultParameters {
{Regex: ".*", Beacon: true, Listen: true}, {Regex: ".*", Beacon: true, Listen: true},
}, },
// Network domain // Network domain
DefaultNetworkDomain: NetworkDomainConfig{ DefaultNetworkDomain: NetworkDomainConfig{
Prefix: [...]byte{0xfc}, Prefix: "fc",
}, },
// TUN // TUN
MaximumIfMTU: 65535, MaximumIfMTU: 65535,

View file

@ -20,7 +20,7 @@ func getDefaults() platformDefaultParameters {
// Network domain // Network domain
DefaultNetworkDomain: NetworkDomainConfig{ DefaultNetworkDomain: NetworkDomainConfig{
Prefix: [...]byte{0xfc}, Prefix: "fc",
}, },
// TUN // TUN