+ dhcp custom options
Squashed commit of the following:
commit 140ac16568383cab2270e5d5ba895959902dd943
Merge: d5ed73b5 cb6ca3b0
Author: Simon Zolin <s.zolin@adguard.com>
Date: Tue Aug 25 13:46:34 2020 +0300
Merge remote-tracking branch 'origin/master' into 1585-dhcp-options
commit d5ed73b5e4f068b823fe97ab1161753670d10387
Author: Simon Zolin <s.zolin@adguard.com>
Date: Fri Aug 21 18:16:41 2020 +0300
minor
commit f5208a0b050c2dd462b32edee0379758cc6e5003
Author: Simon Zolin <s.zolin@adguard.com>
Date: Mon Jun 1 14:09:39 2020 +0300
+ dhcpv4 custom options
This commit is contained in:
18
dhcpd/v4.go
18
dhcpd/v4.go
@@ -475,6 +475,10 @@ func (s *v4Server) process(req *dhcpv4.DHCPv4, resp *dhcpv4.DHCPv4) int {
|
||||
resp.UpdateOption(dhcpv4.OptRouter(s.conf.routerIP))
|
||||
resp.UpdateOption(dhcpv4.OptSubnetMask(s.conf.subnetMask))
|
||||
resp.UpdateOption(dhcpv4.OptDNS(s.conf.dnsIPAddrs...))
|
||||
|
||||
for _, opt := range s.conf.options {
|
||||
resp.Options[opt.code] = opt.val
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -619,5 +623,19 @@ func v4Create(conf V4ServerConf) (DHCPServer, error) {
|
||||
s.conf.leaseTime = time.Second * time.Duration(conf.LeaseDuration)
|
||||
}
|
||||
|
||||
for _, o := range conf.Options {
|
||||
code, val := parseOptionString(o)
|
||||
if code == 0 {
|
||||
log.Debug("DHCPv4: bad option string: %s", o)
|
||||
continue
|
||||
}
|
||||
|
||||
opt := dhcpOption{
|
||||
code: code,
|
||||
val: val,
|
||||
}
|
||||
s.conf.options = append(s.conf.options, opt)
|
||||
}
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user