dhcpd -- Remember hostname, for UI.

This commit is contained in:
Eugene Bujak 2018-12-29 16:44:07 +03:00
parent fedfc3a1fd
commit 86d79ae232
1 changed files with 6 additions and 4 deletions

View File

@ -16,6 +16,7 @@ const defaultDiscoverTime = time.Second * 3
type Lease struct { type Lease struct {
HWAddr net.HardwareAddr `json:"mac" yaml:"hwaddr"` HWAddr net.HardwareAddr `json:"mac" yaml:"hwaddr"`
IP net.IP `json:"ip"` IP net.IP `json:"ip"`
Hostname string `json:"hostname"`
Expiry time.Time `json:"expires"` Expiry time.Time `json:"expires"`
} }
@ -176,7 +177,8 @@ func (s *Server) reserveLease(p dhcp4.Packet) (*Lease, error) {
return nil, wrapErrPrint(err, "Couldn't find free IP for the lease %s", hwaddr.String()) return nil, wrapErrPrint(err, "Couldn't find free IP for the lease %s", hwaddr.String())
} }
trace("Assigning to %s IP address %s", hwaddr, ip.String()) trace("Assigning to %s IP address %s", hwaddr, ip.String())
lease := &Lease{HWAddr: hwaddr, IP: ip} hostname := p.ParseOptions()[dhcp4.OptionHostName]
lease := &Lease{HWAddr: hwaddr, IP: ip, Hostname: string(hostname)}
s.leases = append(s.leases, lease) s.leases = append(s.leases, lease)
return lease, nil return lease, nil
} }