Skip to content

Commit 68e4e3e

Browse files
committed
ipn/wg: egress is packetconn if hopping over netstack gonet
1 parent 4e94ea4 commit 68e4e3e

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

intra/ipn/wg/wgconn.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func (s *StdNetBind) RemoteAddr() netip.AddrPort {
213213
return s.sendAddr.Load()
214214
}
215215

216-
func (s *StdNetBind) listenNet(network string, port int) (*net.UDPConn, int, error) {
216+
func (s *StdNetBind) listenNet(network string, port int) (net.PacketConn, int, error) {
217217
anyaddr := anyaddr6
218218
if network == "udp4" {
219219
anyaddr = anyaddr4
@@ -247,12 +247,7 @@ func (s *StdNetBind) listenNet(network string, port int) (*net.UDPConn, int, err
247247
}
248248
log.V("wg: bind: %s %s: listen(%v)", s.id, network, laddr)
249249
// typecast is safe, because "network" is always udp[4|6]; see: Open
250-
if udpconn, ok := conn.(*net.UDPConn); ok {
251-
return udpconn, uaddr.Port, nil
252-
} else {
253-
clos(conn)
254-
return nil, 0, errNotUDP
255-
}
250+
return conn, uaddr.Port, nil
256251
}
257252

258253
func (bind *StdNetBind) Open(uport uint16) ([]conn.ReceiveFunc, uint16, error) {
@@ -305,7 +300,8 @@ again:
305300
fns = append(fns, bind.makeReceiveFn(ipv6))
306301
}
307302

308-
log.I("wg: bind: %s opened port(%d) for v4? %t v6? %t", bind.id, port, ipv4 != nil, ipv6 != nil)
303+
log.I("wg: bind: %s opened port(%d) for v4? %t v6? %t",
304+
bind.id, port, ipv4 != nil, ipv6 != nil)
309305
if len(fns) == 0 {
310306
return nil, 0, syscall.EAFNOSUPPORT
311307
}

0 commit comments

Comments
 (0)