From dfca87ba80e8e8fa6855dd60ca6d498955dc825c Mon Sep 17 00:00:00 2001 From: Arceliar Date: Sat, 15 May 2021 16:44:56 -0500 Subject: [PATCH] start a reader to disard traffic if the tun is disabled --- src/tuntap/tun.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/tuntap/tun.go b/src/tuntap/tun.go index e8f7fcbb..6d41f59b 100644 --- a/src/tuntap/tun.go +++ b/src/tuntap/tun.go @@ -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