5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-12-26 12:25:41 +00:00

fix crash when starting in tun mode

This commit is contained in:
Arceliar 2018-11-10 22:39:15 -06:00
parent b3887e554c
commit 1b1b776097

View File

@ -51,21 +51,23 @@ func (tun *tunDevice) start(ifname string, iftapmode bool, addr string, mtu int)
}
go func() { panic(tun.read()) }()
go func() { panic(tun.write()) }()
go func() {
for {
if _, ok := tun.icmpv6.peermacs[tun.core.router.addr]; ok {
break
if iftapmode {
go func() {
for {
if _, ok := tun.icmpv6.peermacs[tun.core.router.addr]; ok {
break
}
request, err := tun.icmpv6.create_ndp_tap(tun.core.router.addr)
if err != nil {
panic(err)
}
if _, err := tun.iface.Write(request); err != nil {
panic(err)
}
time.Sleep(time.Second)
}
request, err := tun.icmpv6.create_ndp_tap(tun.core.router.addr)
if err != nil {
panic(err)
}
if _, err := tun.iface.Write(request); err != nil {
panic(err)
}
time.Sleep(time.Second)
}
}()
}()
}
return nil
}