mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 06:05:06 +03:00
start a reader to disard traffic if the tun is disabled
This commit is contained in:
parent
f61507238e
commit
dfca87ba80
1 changed files with 9 additions and 0 deletions
|
@ -138,6 +138,15 @@ func (tun *TunAdapter) _start() error {
|
|||
addr := fmt.Sprintf("%s/%d", net.IP(tun.addr[:]).String(), 8*len(address.GetPrefix())-1)
|
||||
if current.IfName == "none" || current.IfName == "dummy" {
|
||||
tun.log.Debugln("Not starting TUN as ifname is none or dummy")
|
||||
go func() {
|
||||
bs := make([]byte, tun.core.PacketConn.MTU())
|
||||
for {
|
||||
// Dump traffic to nowhere
|
||||
if _, _, err := tun.core.PacketConn.ReadFrom(bs); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
mtu := current.IfMTU
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue