pkg/login-validator: fix compilation errors

This commit is contained in:
nemunaire 2019-02-22 01:55:02 +01:00
parent 11f9820006
commit c69bd5c202

View File

@ -157,13 +157,16 @@ func (l loginChecker) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Find corresponding MAC
var fname string
spl := strings.SplitN(remoteAddr, ":", 2)
spl := strings.SplitN(r.RemoteAddr, ":", 2)
if ip := net.ParseIP(spl[0]); ip == nil {
return errors.New("Unable to parse given IPv4: " + spl[0])
http.Error(w, "Unable to parse given IPv4: " + spl[0], http.StatusInternalServerError)
return
} else if arptable, err := ARPAnalyze(); err != nil {
return err
http.Error(w, err.Error(), http.StatusInternalServerError)
return
} else if arpent := ARPContainsIP(arptable, ip); arpent == nil {
return errors.New("Unable to find MAC in ARP table")
http.Error(w, "Unable to find MAC in ARP table", http.StatusInternalServerError)
return
} else {
fname = fmt.Sprintf("%02x-%02x-%02x-%02x-%02x-%02x-%02x", arpent.HWType, arpent.HWAddress[0], arpent.HWAddress[1], arpent.HWAddress[2], arpent.HWAddress[3], arpent.HWAddress[4], arpent.HWAddress[5])
}