Skip to content

Commit 3af14c6

Browse files
authored
Merge pull request mdlayher#9 from paultag/paultag/create-from-packet-conn
Allow the user to create a Client from a PacketConn
2 parents d035564 + 16dcaf0 commit 3af14c6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

client.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,15 @@ func NewClient(ifi *net.Interface) (*Client, error) {
3333
if err != nil {
3434
return nil, err
3535
}
36+
return NewClientPacketConn(ifi, p)
37+
}
3638

39+
// NewClientPacketConn creates a new Client using the specified network interface
40+
// and net.PacketConn. This allows the caller to define exactly how they bind to the
41+
// net.PacketConn. This is most useful to define what protocol to pass to socket(7).
42+
//
43+
// In most cases, callers would be better off calling NewClient.
44+
func NewClientPacketConn(ifi *net.Interface, p net.PacketConn) (*Client, error) {
3745
// Check for usable IPv4 addresses for the Client
3846
addrs, err := ifi.Addrs()
3947
if err != nil {

0 commit comments

Comments
 (0)