Add time and vendor information to leases
This commit is contained in:
parent
67711ee2c7
commit
c5a72342f2
@ -155,6 +155,8 @@ form {
|
||||
<th>Hostname</th>
|
||||
<th>MAC address</th>
|
||||
<th>Vendor</th>
|
||||
<th>VendorIdentifier</th>
|
||||
<th>Start</th>
|
||||
<th>Expiry</th>
|
||||
</tr>
|
||||
{{ range $idx, $l := . }}
|
||||
@ -171,6 +173,8 @@ form {
|
||||
</td>
|
||||
<td class="hwaddr">{{$l.HardwareAddr}}</td>
|
||||
<td>{{$l.Vendor}}</td>
|
||||
<td>{{$l.VendorIdentifier}}</td>
|
||||
<td>{{$l.Start}}</td>
|
||||
<td title="{{ timefmt $l.Expiry }}">
|
||||
{{ if $l.Expired }}
|
||||
{{ since $l.Expiry }}
|
||||
@ -183,6 +187,7 @@ form {
|
||||
<span class="active">active</span>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
|
@ -43,6 +43,8 @@ type Lease struct {
|
||||
Hostname string `json:"hostname"`
|
||||
HostnameOverride string `json:"hostname_override"`
|
||||
Expiry time.Time `json:"expiry"`
|
||||
Start time.Time `json:"start"`
|
||||
VendorIdentifier string `json:"vendor"`
|
||||
}
|
||||
|
||||
func (l *Lease) Expired(at time.Time) bool {
|
||||
@ -335,13 +337,15 @@ func (h *Handler) serveDHCP(p dhcp4.Packet, msgType dhcp4.MessageType, options d
|
||||
if leaseNum == -1 {
|
||||
return dhcp4.ReplyPacket(p, dhcp4.NAK, h.serverIP, nil, 0, nil)
|
||||
}
|
||||
|
||||
now := h.timeNow()
|
||||
lease := &Lease{
|
||||
Num: leaseNum,
|
||||
Addr: make([]byte, 4),
|
||||
HardwareAddr: hwAddr,
|
||||
Expiry: h.timeNow().Add(h.leasePeriodForDevice(hwAddr)),
|
||||
Hostname: string(options[dhcp4.OptionHostName]),
|
||||
Num: leaseNum,
|
||||
Addr: make([]byte, 4),
|
||||
HardwareAddr: hwAddr,
|
||||
Expiry: now.Add(h.leasePeriodForDevice(hwAddr)),
|
||||
Hostname: string(options[dhcp4.OptionHostName]),
|
||||
Start: now,
|
||||
VendorIdentifier: string(options[dhcp4.OptionVendorClassIdentifier]),
|
||||
}
|
||||
copy(lease.Addr, reqIP.To4())
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user