login-validator: New parameter -just-login

This commit is contained in:
nemunaire 2022-02-03 18:05:17 +01:00
parent a2a056f3ff
commit d5a67e2bbb
2 changed files with 12 additions and 1 deletions

View File

@ -15,7 +15,10 @@ import (
"time" "time"
) )
var loginSalt string var (
loginSalt string
justLogin bool
)
type loginChecker struct { type loginChecker struct {
students []Student students []Student
@ -81,6 +84,12 @@ func (l loginChecker) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return return
} }
if justLogin {
log.Println("Successful login of", lu.Username, "at", r.RemoteAddr)
http.Error(w, "You're now successfully logged.", http.StatusOK)
return
}
// Find corresponding MAC // Find corresponding MAC
var ip net.IP var ip net.IP
spl := strings.SplitN(r.RemoteAddr, ":", 2) spl := strings.SplitN(r.RemoteAddr, ":", 2)

View File

@ -18,6 +18,8 @@ var tftpDir string
func main() { func main() {
var studentsFile string var studentsFile string
flag.BoolVar(&justLogin, "just-login", justLogin, "Don't perform MAC assignation and remote registration")
var bind = flag.String("bind", ":8081", "Bind port/socket") var bind = flag.String("bind", ":8081", "Bind port/socket")
flag.StringVar(&studentsFile, "students", "./students.csv", "Path to a CSV file containing students list") flag.StringVar(&studentsFile, "students", "./students.csv", "Path to a CSV file containing students list")
flag.StringVar(&ARPTable, "arp", ARPTable, "Path to ARP table") flag.StringVar(&ARPTable, "arp", ARPTable, "Path to ARP table")