Move receiverCreator to new file

This commit is contained in:
Zoltán Papp 2024-04-15 14:12:24 +02:00
parent b355c34b63
commit 28a9a2ef87
2 changed files with 25 additions and 11 deletions

View File

@ -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
}

View File

@ -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)
}