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