From 9eaa2566c1d032d5769574f5825352568374c79f Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 14 Dec 2018 18:08:13 +0000 Subject: [PATCH] Parameterise tun.init --- src/yggdrasil/router.go | 5 +---- src/yggdrasil/tun.go | 4 +++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/yggdrasil/router.go b/src/yggdrasil/router.go index eab18b1..3b6d204 100644 --- a/src/yggdrasil/router.go +++ b/src/yggdrasil/router.go @@ -80,13 +80,10 @@ func (r *router) init(core *Core) { send := make(chan []byte, 32) r.recv = recv r.send = send - r.tun.recv = recv - r.tun.send = send r.reset = make(chan struct{}, 1) r.admin = make(chan func(), 32) r.cryptokey.init(r.core) - r.tun.init(r.core) - // go r.mainLoop() + r.tun.init(r.core, send, recv) } // Starts the mainLoop goroutine. diff --git a/src/yggdrasil/tun.go b/src/yggdrasil/tun.go index e462502..85204da 100644 --- a/src/yggdrasil/tun.go +++ b/src/yggdrasil/tun.go @@ -36,9 +36,11 @@ func getSupportedMTU(mtu int) int { } // Initialises the TUN/TAP adapter. -func (tun *tunDevice) init(core *Core) { +func (tun *tunDevice) init(core *Core, send chan<- []byte, recv <-chan []byte) { tun.core = core tun.icmpv6.init(tun) + tun.send = send + tun.recv = recv } // Starts the setup process for the TUN/TAP adapter, and if successful, starts