Skip to content

Adds the bind-to-interface helper code#5

Open
farcaller wants to merge 1 commit into
krolaw:masterfrom
farcaller:socket-helper
Open

Adds the bind-to-interface helper code#5
farcaller wants to merge 1 commit into
krolaw:masterfrom
farcaller:socket-helper

Conversation

@farcaller
Copy link
Copy Markdown
Contributor

Typical UDP socket would listen on 0.0.0.0:67 and bind to an interface
to limit exposure. This PR implements a helper method to bind and serve
on a socket.

Currently it’s linux only. I left an unimplemented!() trap for BSD with
a note how to progress there and feature-gated the code.

Typical UDP socket would listen on 0.0.0.0:67 and bind to an interface
to limit exposure. This PR implements a helper method to bind and serve
on a socket.

Currently it’s linux only. I left an unimplemented!() trap for BSD with
a note how to progress there and feature-gated the code.
Copy link
Copy Markdown
Owner

@krolaw krolaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my Go version, I went with the equivalent of bind_and_serve (called ServeIf), which I now believe was a mistake. In my private branch I've deprecated those functions - favouring a NewUDP4BoundConn(ifname string, addr string) fn, the result of which is passed to Serve. However, now I'm thinking, that such a general function deserves it's own lib, leaving the DHCP4r completely OS agnostic.

@farcaller
Copy link
Copy Markdown
Contributor Author

While I can agree that it could fit net2 or similar better, I'd argue that it's widely used for dhcp servers specifically, so all of the users would end up re-implementing it over and over. Given it's feature and platform gated, I think it's still an useful addition.

@farcaller
Copy link
Copy Markdown
Contributor Author

bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants