summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/server4
AgeCommit message (Collapse)Author
2022-10-01Merge branch 'master' into fix-not-nil-checksPablo Mazzini
2022-10-01dhcpv4: fix require.NotNil() usage in testsDennis Marttinen
Any parameter passed to `require.NotNil()` after the first two will not be tested but instead appended to the message that is printed if the test fails. This means that `lease.ACK` was never tested to not be nil. Signed-off-by: Dennis Marttinen <twelho@welho.tech>
2022-10-01dhcpv4: return a new lease from Renew()Dennis Marttinen
Signed-off-by: Dennis Marttinen <twelho@welho.tech>
2022-09-10Merge branch 'master' into fix-nil-optionsPablo Mazzini
2022-09-07Update conn_unix.goJacob Weinstock
Add `SO_REUSEPORT` to aid in debugging and testing. Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
2022-07-27dhcpv4: add a client method to facilitate lease renewalsDennis Marttinen
Signed-off-by: Dennis Marttinen <twelho@welho.tech>
2021-06-08Make server4 package compile on Windows (#428)Guillaume Rose
2020-09-16docs: fix package commentsChris Koch
Signed-off-by: Chris Koch <chrisko@google.com>
2020-07-10- add Offer into LeaseHu Jun
- change Client.Request so it now only return Lease - change test case and example accordingly Signed-off-by: Hu Jun <hujun.work@gmail.com>
2020-06-27fix a broken test in server_test.go, caused by update of Client.Request() ↵Hu Jun
which now returns a lease instead of ack Signed-off-by: Hu Jun <hujun.work@gmail.com>
2020-03-28remove some testsPablo Mazzini
Signed-off-by: Pablo Mazzini <pmazzini@gmail.com>
2020-03-19Added support for a custom logger when instantiating the server4 orValerio Santinelli
server6 object Signed-off-by: Valerio Santinelli <santinelli@altralogica.it>
2020-01-24Fix a compare in Serve() of IP4 Zero to use an IP4 addressRonald G. Minnich
Fixes, among other things, u-root pxeserver Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
2019-10-15server4: Only allow IPv4 addressesAnatole Denis
IPv6 addresses would not cause a crash, but would silently listen on the wildcard address instead of the passed address, which is surprising at best. Instead check for the address family and reject non-v4 addresses Signed-off-by: Anatole Denis <natolumin@unverle.fr>
2019-10-15server4: Use port 0 in testsAnatole Denis
Tests use a randPort() workaround for not using port 0, as port 0 is not usable with raw sockets. We don't actually use raw sockets, so port 0 is fine, this makes use of it which ensures we avoid port collisions. Signed-off-by: Anatole Denis <natolumin@unverle.fr>
2019-10-15server4: Respect listen addressAnatole Denis
NewIPv4UDPConn doesn't support listening on a specific address, only on the wildcard address. This extends it to allow listening on an address, and at the same time homogenizes the function signature with the NewIPv6UDPConn server6 equivalent. It modifies NewServer() to pass the full address given to it instead of just the port as well Note that listening on a non-wildcard interface is seldom useful as the socket won't receive broadcasts, so it is useless in a direct-attached server. It can be useful in a server only used behind relays This breaks API compatibility for NewIPv4UDPConn, which as far as I know nobody uses (yet) Signed-off-by: Anatole Denis <natolumin@unverle.fr>
2019-10-01server{4,6}: Return UDPConn from NewIPv*UDPConnAnatole Denis
The concrete type under the interface is known here since we create the connection in the same function. Since *net.UDPConn implements net.PacketConn anyway, returning the concrete type here is more powerful and less risky than having downstream users cast the value themselves There should be no code change for downstream users, with the exception of explicit casts (`udpc := conn.(*net.UDPConn)`), which can simply be removed Signed-off-by: Anatole Denis <natolumin@unverle.fr>
2019-08-14Bind interface fix (#310)borna-blazevic
Added a bind to interface functionality.
2019-07-29server4: set peer to broadcast if client IP is zeroChris Koch
Clients without an IP set their source address to 0.0.0.0, so the peer returned by ReadFrom may not actually be the address to send to. Clients without an IP should have their response broadcast. Signed-off-by: Chris Koch <chrisko@google.com>
2019-05-08[CI] Added lintersAndrea Barberio
Now the CI will also run golangci-lint Signed-off-by: Andrea Barberio <insomniac@slackware.it>
2019-04-17nclient4: fix conn race conditionChristopher Koch
Why did I ever think this would work?? Signed-off-by: Christopher Koch <chrisko@google.com>
2019-04-17[server] Serve returns an error, and closes when doneAndrea Barberio
Server6 and Server4 had Serve methods that return without reporting an error, changed in this PR. Serve now also closes the connection when done. Signed-off-by: Andrea Barberio <insomniac@slackware.it>
2019-03-29server4 test: pick ports > 32kChris K
2019-03-27client4: add a new DHCPv4 client.Christopher Koch
- Able to send UDP packets before interface is configured. - Able to use any net.PacketConn. - RFC2131-compliant retransmission logic. - Tests. - Race-condition-averse. Previous clients (both mine and the ones here) are prone to race condition errors. Having one and only one place that calls receive on the socket "continuously" without having to coordinate hand-offs makes the logic way easier to follow, and allows for multiple requests in flux at a time. Signed-off-by: Christopher Koch <chrisko@google.com>
2019-01-28dhcpv4: moved client into dhcpv4/client4Andrea Barberio