mirror of
https://github.com/danderson/netboot.git
synced 2025-10-17 02:21:20 +02:00
Only try to parse the MAC address if the file has a known type.
Parsing unconditionally logs errors when serving non-kernel/initrd files.
This commit is contained in:
parent
3df58430a4
commit
a762c94d61
@ -134,15 +134,20 @@ func (s *Server) handleFile(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
s.log("HTTP", "Sent file %q to %s", name, r.RemoteAddr)
|
s.log("HTTP", "Sent file %q to %s", name, r.RemoteAddr)
|
||||||
|
|
||||||
mac, err := net.ParseMAC(r.URL.Query().Get("mac"))
|
|
||||||
if err != nil {
|
|
||||||
s.log("HTTP", "File fetch provided invalid MAC address %q", r.URL.Query().Get("mac"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch r.URL.Query().Get("type") {
|
switch r.URL.Query().Get("type") {
|
||||||
case "kernel":
|
case "kernel":
|
||||||
|
mac, err := net.ParseMAC(r.URL.Query().Get("mac"))
|
||||||
|
if err != nil {
|
||||||
|
s.log("HTTP", "File fetch provided invalid MAC address %q", r.URL.Query().Get("mac"))
|
||||||
|
return
|
||||||
|
}
|
||||||
s.machineEvent(mac, machineStateKernel, "Sent kernel %q", name)
|
s.machineEvent(mac, machineStateKernel, "Sent kernel %q", name)
|
||||||
case "initrd":
|
case "initrd":
|
||||||
|
mac, err := net.ParseMAC(r.URL.Query().Get("mac"))
|
||||||
|
if err != nil {
|
||||||
|
s.log("HTTP", "File fetch provided invalid MAC address %q", r.URL.Query().Get("mac"))
|
||||||
|
return
|
||||||
|
}
|
||||||
s.machineEvent(mac, machineStateInitrd, "Sent initrd %q", name)
|
s.machineEvent(mac, machineStateInitrd, "Sent initrd %q", name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user