Skip to content

Commit 3af7305

Browse files
committed
Fix darwin WritePacket
1 parent aa1fd4d commit 3af7305

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tun_darwin_gvisor.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package tun
44

55
import (
6+
"github.com/sagernet/gvisor/pkg/tcpip/header"
67
"github.com/sagernet/gvisor/pkg/tcpip/link/qdisc/fifo"
78
"github.com/sagernet/gvisor/pkg/tcpip/stack"
89
"github.com/sagernet/sing-tun/internal/fdbased_darwin"
@@ -15,6 +16,11 @@ var _ GVisorTun = (*NativeTun)(nil)
1516

1617
func (t *NativeTun) WritePacket(pkt *stack.PacketBuffer) (int, error) {
1718
iovecs := t.iovecsOutputDefault
19+
if pkt.NetworkProtocolNumber == header.IPv4ProtocolNumber {
20+
iovecs = append(iovecs, packetHeaderVec4)
21+
} else {
22+
iovecs = append(iovecs, packetHeaderVec6)
23+
}
1824
var dataLen int
1925
for _, packetSlice := range pkt.AsSlices() {
2026
dataLen += len(packetSlice)

0 commit comments

Comments
 (0)