diff --git a/iface/bind/bind.go b/iface/bind/bind.go index 00af25f67..35ba27bc0 100644 --- a/iface/bind/bind.go +++ b/iface/bind/bind.go @@ -13,14 +13,6 @@ import ( wgConn "golang.zx2c4.com/wireguard/conn" ) -type receiverCreator struct { - iceBind *ICEBind -} - -func (rc receiverCreator) CreateIPv4ReceiverFn(msgPool *sync.Pool, pc *ipv4.PacketConn, conn *net.UDPConn) wgConn.ReceiveFunc { - return rc.iceBind.createIPv4ReceiverFn(msgPool, pc, conn) -} - type ICEBind struct { *wgConn.StdNetBind @@ -35,9 +27,8 @@ func NewICEBind(transportNet transport.Net) *ICEBind { transportNet: transportNet, } - rc := receiverCreator{ - ib, - } + rc := newReceiverCreator(ib) + ib.StdNetBind = wgConn.NewStdNetBindWithReceiverCreator(rc) return ib } diff --git a/iface/bind/receiver_creator.go b/iface/bind/receiver_creator.go new file mode 100644 index 000000000..b205c4d5f --- /dev/null +++ b/iface/bind/receiver_creator.go @@ -0,0 +1,23 @@ +package bind + +import ( + "net" + "sync" + + "golang.org/x/net/ipv4" + wgConn "golang.zx2c4.com/wireguard/conn" +) + +type receiverCreator struct { + iceBind *ICEBind +} + +func newReceiverCreator(iceBind *ICEBind) receiverCreator { + return receiverCreator{ + iceBind: iceBind, + } +} + +func (rc receiverCreator) CreateIPv4ReceiverFn(msgPool *sync.Pool, pc *ipv4.PacketConn, conn *net.UDPConn) wgConn.ReceiveFunc { + return rc.iceBind.createIPv4ReceiverFn(msgPool, pc, conn) +}