Add crypto-key routing into TUN/TAP

This commit is contained in:
Neil Alexander 2019-05-17 22:09:20 +01:00
parent 9c01947b1c
commit 71ccaf753e
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
3 changed files with 436 additions and 31 deletions

View file

@ -41,6 +41,7 @@ type TunAdapter struct {
dialer *yggdrasil.Dialer
addr address.Address
subnet address.Subnet
ckr cryptokey
icmpv6 ICMPv6
mtu int
iface *water.Interface
@ -117,8 +118,8 @@ func (tun *TunAdapter) Init(config *config.NodeState, log *log.Logger, listener
// Start the setup process for the TUN/TAP adapter. If successful, starts the
// read/write goroutines to handle packets on that interface.
func (tun *TunAdapter) Start() error {
tun.config.Mutex.Lock()
defer tun.config.Mutex.Unlock()
tun.config.Mutex.RLock()
defer tun.config.Mutex.RUnlock()
if tun.config == nil || tun.listener == nil || tun.dialer == nil {
return errors.New("No configuration available to TUN/TAP")
}
@ -173,6 +174,7 @@ func (tun *TunAdapter) Start() error {
go tun.reader()
go tun.writer()
tun.icmpv6.Init(tun)
tun.ckr.init(tun)
return nil
}