diff options
author | Marek Majkowski <marek@cloudflare.com> | 2020-01-22 12:50:28 +0000 |
---|---|---|
committer | Marek Majkowski <marek@cloudflare.com> | 2020-01-27 13:51:15 +0000 |
commit | 45398b160f4ccc3148644dde5eb5e4610e6a2d9b (patch) | |
tree | 9bb16834d3cf5abc9b7608493e8565f1698a07b7 /pkg/tcpip/adapters/gonet | |
parent | 6b43cf791a74a746443f70f98d859c1246f87e2a (diff) |
Expose gonet.NewPacketConn, for parity with gonet.NewConn API
gonet.Conn can be created with both gonet.NewConn and gonet.Dial.
gonet.PacketConn was created only by gonet.DialUDP. This prevented
us from being able to use PacketConn in udp.NewForwarder() context.
This simple constructor - NewPacketConn, allows user to create
correct structure from that context.
Diffstat (limited to 'pkg/tcpip/adapters/gonet')
-rw-r--r-- | pkg/tcpip/adapters/gonet/gonet.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pkg/tcpip/adapters/gonet/gonet.go b/pkg/tcpip/adapters/gonet/gonet.go index 3bba4028b..b659cfccf 100644 --- a/pkg/tcpip/adapters/gonet/gonet.go +++ b/pkg/tcpip/adapters/gonet/gonet.go @@ -556,6 +556,17 @@ type PacketConn struct { wq *waiter.Queue } +// NewPacketConn creates a new PacketConn. +func NewPacketConn(s *stack.Stack, wq *waiter.Queue, ep tcpip.Endpoint) *PacketConn { + c := &PacketConn{ + stack: s, + ep: ep, + wq: wq, + } + c.deadlineTimer.init() + return c +} + // DialUDP creates a new PacketConn. // // If laddr is nil, a local address is automatically chosen. |