diff --git a/cmd/mesh/main.go b/cmd/mesh/main.go index 5a70b9d7..1b2a67b0 100644 --- a/cmd/mesh/main.go +++ b/cmd/mesh/main.go @@ -31,7 +31,7 @@ import ( "github.com/RiV-chain/RiV-mesh/src/defaults" "github.com/RiV-chain/RiV-mesh/src/core" - "github.com/RiV-chain/RiV-mesh/src/ipv6rwc" + //"github.com/RiV-chain/RiV-mesh/src/ipv6rwc" "github.com/RiV-chain/RiV-mesh/src/multicast" "github.com/RiV-chain/RiV-mesh/src/tun" "github.com/RiV-chain/RiV-mesh/src/version" @@ -301,6 +301,7 @@ func run(args yggArgs, ctx context.Context) { options := []core.SetupOption{ core.NodeInfo(cfg.NodeInfo), core.NodeInfoPrivacy(cfg.NodeInfoPrivacy), + core.NetworkDomain(cfg.NetworkDomain), } for _, addr := range cfg.Listen { options = append(options, core.ListenAddress(addr)) @@ -364,7 +365,7 @@ func run(args yggArgs, ctx context.Context) { tun.InterfaceName(cfg.IfName), tun.InterfaceMTU(cfg.IfMTU), } - if n.tun, err = tun.New(ipv6rwc.NewReadWriteCloser(n.core), logger, options...); err != nil { + if n.tun, err = tun.New(n.core, logger, options...); err != nil { panic(err) } if n.admin != nil && n.tun != nil { diff --git a/src/core/address.go b/src/core/address.go index a472cc7f..713fb920 100644 --- a/src/core/address.go +++ b/src/core/address.go @@ -17,7 +17,7 @@ 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 [...]byte{0xfc} + return c.config.networkdomain.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 7ad793e9..80c374e8 100644 --- a/src/core/options.go +++ b/src/core/options.go @@ -14,6 +14,8 @@ func (c *Core) _applyOption(opt SetupOption) { c.config.nodeinfo = v case NodeInfoPrivacy: c.config.nodeinfoPrivacy = v + case NetworkDomain: + c.config.networkdomain = v case AllowedPublicKey: pk := [32]byte{} copy(pk[:], v) @@ -41,4 +43,5 @@ func (a ListenAddress) isSetupOption() {} func (a Peer) isSetupOption() {} func (a NodeInfo) isSetupOption() {} func (a NodeInfoPrivacy) isSetupOption() {} +func (a NetworkDomain) isSetupOption() {} func (a AllowedPublicKey) isSetupOption() {} diff --git a/src/tun/tun.go b/src/tun/tun.go index f01e90ec..dc572b6e 100644 --- a/src/tun/tun.go +++ b/src/tun/tun.go @@ -91,9 +91,10 @@ func MaximumMTU() uint64 { // Init initialises the TUN module. You must have acquired a Listener from // the Mesh core before this point and it must not be in use elsewhere. -func New(rwc *ipv6rwc.ReadWriteCloser, log core.Logger, opts ...SetupOption) (*TunAdapter, error) { +func New(core *core.Core, log core.Logger, opts ...SetupOption) (*TunAdapter, error) { tun := &TunAdapter{ - rwc: rwc, + core: core, + rwc: ipv6rwc.NewReadWriteCloser(core), log: log, } for _, opt := range opts {