mirror of
https://github.com/sigcn/pg.git
synced 2025-12-24 11:31:03 +08:00
vpn: recycle packets rejected by handlers (#37)
This commit is contained in:
@@ -110,8 +110,9 @@ func (vpn *VPN) nicWrite(wg *sync.WaitGroup, vnic *nic.VirtualNIC) {
|
||||
return pkt
|
||||
}
|
||||
for packet := range vpn.inbound {
|
||||
in := packet
|
||||
if packet = handle(packet); packet == nil {
|
||||
nic.RecyclePacket(packet)
|
||||
nic.RecyclePacket(in)
|
||||
continue
|
||||
}
|
||||
err := vnic.Write(packet)
|
||||
@@ -167,8 +168,9 @@ func (vpn *VPN) packetConnWrite(wg *sync.WaitGroup, packetConn net.PacketConn) {
|
||||
return pkt
|
||||
}
|
||||
for packet := range vpn.outbound {
|
||||
out := packet
|
||||
if packet = handle(packet); packet == nil {
|
||||
nic.RecyclePacket(packet)
|
||||
nic.RecyclePacket(out)
|
||||
continue
|
||||
}
|
||||
pkt := packet.AsBytes()
|
||||
|
||||
Reference in New Issue
Block a user