mirror of
https://github.com/SagerNet/sing-tun.git
synced 2025-09-26 20:51:13 +08:00
Fix darwin WritePacket
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
package tun
|
||||
|
||||
import (
|
||||
"github.com/sagernet/gvisor/pkg/tcpip/header"
|
||||
"github.com/sagernet/gvisor/pkg/tcpip/link/qdisc/fifo"
|
||||
"github.com/sagernet/gvisor/pkg/tcpip/stack"
|
||||
"github.com/sagernet/sing-tun/internal/fdbased_darwin"
|
||||
@@ -15,6 +16,11 @@ var _ GVisorTun = (*NativeTun)(nil)
|
||||
|
||||
func (t *NativeTun) WritePacket(pkt *stack.PacketBuffer) (int, error) {
|
||||
iovecs := t.iovecsOutputDefault
|
||||
if pkt.NetworkProtocolNumber == header.IPv4ProtocolNumber {
|
||||
iovecs = append(iovecs, packetHeaderVec4)
|
||||
} else {
|
||||
iovecs = append(iovecs, packetHeaderVec6)
|
||||
}
|
||||
var dataLen int
|
||||
for _, packetSlice := range pkt.AsSlices() {
|
||||
dataLen += len(packetSlice)
|
||||
|
Reference in New Issue
Block a user