Pull request: dhcpd: fix ip option parsing
Merge in DNS/adguard-home from 2688-dhcp-opt-ip to master Updates #2688. Squashed commit of the following: commit e17e003a3a61c1f4ed55617bb61df721cbca12c1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Feb 16 17:10:32 2021 +0300 dhcpd: fix ip option parsing
This commit is contained in:
@@ -293,14 +293,22 @@ func parseOptionString(s string) (uint8, []byte) {
|
||||
if err != nil {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
case "ip":
|
||||
ip := net.ParseIP(sval)
|
||||
if ip == nil {
|
||||
return 0, nil
|
||||
}
|
||||
val = ip
|
||||
|
||||
// Most DHCP options require IPv4, so do not put the 16-byte
|
||||
// version if we can. Otherwise, the clients will receive weird
|
||||
// data that looks like four IPv4 addresses.
|
||||
//
|
||||
// See https://github.com/AdguardTeam/AdGuardHome/issues/2688.
|
||||
if ip4 := ip.To4(); ip4 != nil {
|
||||
val = ip4
|
||||
} else {
|
||||
val = ip
|
||||
}
|
||||
default:
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user