mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-07-23 15:53:28 +03:00
Add L3 routing support
This commit is contained in:
27
transport/wireguard/device_nat_gvisor.go
Normal file
27
transport/wireguard/device_nat_gvisor.go
Normal file
@@ -0,0 +1,27 @@
|
||||
//go:build with_gvisor
|
||||
|
||||
package wireguard
|
||||
|
||||
import (
|
||||
"github.com/sagernet/sing/common"
|
||||
"github.com/sagernet/sing/common/buf"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/tcpip/stack"
|
||||
)
|
||||
|
||||
func (d *natDestinationWrapper) WritePacketBuffer(buffer *stack.PacketBuffer) error {
|
||||
defer buffer.DecRef()
|
||||
if d.device.writer != nil {
|
||||
d.device.writer.RewritePacketBuffer(buffer)
|
||||
}
|
||||
var packetLen int
|
||||
for _, slice := range buffer.AsSlices() {
|
||||
packetLen += len(slice)
|
||||
}
|
||||
packet := buf.NewSize(packetLen)
|
||||
for _, slice := range buffer.AsSlices() {
|
||||
common.Must1(packet.Write(slice))
|
||||
}
|
||||
d.device.outbound <- packet
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user