Skip to content

Commit 5cd256c

Browse files
authored
Merge pull request #51 from coder/spike/fix-tstun-linux
fix: fix conversion from netip to tcpip
2 parents 30fcb10 + 8318164 commit 5cd256c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

net/tstun/tap_linux.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,8 @@ func packLayer2UDP(payload []byte, srcMAC, dstMAC net.HardwareAddr, src, dst net
295295
buf := make([]byte, header.EthernetMinimumSize+header.UDPMinimumSize+header.IPv4MinimumSize+len(payload))
296296
payloadStart := len(buf) - len(payload)
297297
copy(buf[payloadStart:], payload)
298-
srcB := src.Addr().As4()
299-
srcIP := tcpip.Address(srcB[:])
300-
dstB := dst.Addr().As4()
301-
dstIP := tcpip.Address(dstB[:])
298+
srcIP := tcpip.AddrFromSlice(src.Addr().AsSlice())
299+
dstIP := tcpip.AddrFromSlice(dst.Addr().AsSlice())
302300
// Ethernet header
303301
eth := header.Ethernet(buf)
304302
eth.Encode(&header.EthernetFields{

0 commit comments

Comments
 (0)