dhcp4d: add HostnameOverride field
This can be used to permanently override a hostname, regardless of whether the lease is static or not. We use a separate field because we want devices to be able to change their hostname themselves, until we override it.
This commit is contained in:
parent
4cde5ec6fc
commit
fa82132962
@ -106,7 +106,7 @@ th {
|
||||
padding-top: 1em;
|
||||
text-align: left;
|
||||
}
|
||||
span.active, span.expired, span.static {
|
||||
span.active, span.expired, span.static, span.hostname-override {
|
||||
min-width: 5em;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
@ -119,6 +119,10 @@ span.active {
|
||||
span.expired {
|
||||
background-color: #f00000;
|
||||
}
|
||||
span.hostname-override {
|
||||
min-width: 1em;
|
||||
background-color: orange;
|
||||
}
|
||||
.ipaddr, .hwaddr {
|
||||
font-family: monospace;
|
||||
}
|
||||
@ -139,7 +143,12 @@ tr:nth-child(even) {
|
||||
{{ range $idx, $l := . }}
|
||||
<tr>
|
||||
<td class="ipaddr">{{$l.Addr}}</td>
|
||||
<td>{{$l.Hostname}}</td>
|
||||
<td>
|
||||
{{$l.Hostname}}
|
||||
{{ if (ne $l.HostnameOverride "") }}
|
||||
<span class="hostname-override">!</span>
|
||||
{{ end }}
|
||||
</td>
|
||||
<td class="hwaddr">{{$l.HardwareAddr}}</td>
|
||||
<td>{{$l.Vendor}}</td>
|
||||
<td title="{{ timefmt $l.Expiry }}">
|
||||
|
@ -31,11 +31,12 @@ import (
|
||||
)
|
||||
|
||||
type Lease struct {
|
||||
Num int `json:"num"` // relative to Handler.start
|
||||
Addr net.IP `json:"addr"`
|
||||
HardwareAddr string `json:"hardware_addr"`
|
||||
Hostname string `json:"hostname"`
|
||||
Expiry time.Time `json:"expiry"`
|
||||
Num int `json:"num"` // relative to Handler.start
|
||||
Addr net.IP `json:"addr"`
|
||||
HardwareAddr string `json:"hardware_addr"`
|
||||
Hostname string `json:"hostname"`
|
||||
HostnameOverride string `json:"hostname_override"`
|
||||
Expiry time.Time `json:"expiry"`
|
||||
}
|
||||
|
||||
func (l *Lease) Expired(at time.Time) bool {
|
||||
@ -277,6 +278,10 @@ func (h *Handler) serveDHCP(p dhcp4.Packet, msgType dhcp4.MessageType, options d
|
||||
lease.Expiry = time.Time{}
|
||||
lease.Hostname = l.Hostname
|
||||
}
|
||||
if l.HostnameOverride != "" {
|
||||
lease.Hostname = l.HostnameOverride
|
||||
lease.HostnameOverride = l.HostnameOverride
|
||||
}
|
||||
|
||||
// Release any old leases for this client
|
||||
delete(h.leasesIP, l.Num)
|
||||
|
Loading…
x
Reference in New Issue
Block a user