This repository has been archived on 2024-03-03. You can view files and clone it, but cannot push or open issues or pull requests.
adlin/validator/main.go
2018-02-18 14:45:46 +01:00

35 lines
833 B
Go

package main
import (
"flag"
"log"
"net/http"
"path/filepath"
)
func main() {
var staticDir string
var bind = flag.String("bind", ":8081", "Bind port/socket")
flag.StringVar(&staticDir, "static", "./static/", "Directory containing static files")
flag.StringVar(&ARPTable, "arp", ARPTable, "Path to ARP table")
//var tftpdLogs = flag.String("tftpd", "/var/logs/tftpd.log", "Path to TFTPd logs")
flag.Parse()
var err error
// Sanitize options
log.Println("Checking paths...")
if staticDir, err = filepath.Abs(staticDir); err != nil {
log.Fatal(err)
}
log.Println("Registering handlers...")
mux := http.NewServeMux()
mux.HandleFunc("/", Index)
mux.Handle("/login", loginChecker{students})
http.HandleFunc("/", mux.ServeHTTP)
log.Println("Ready, listening on port", *bind)
http.ListenAndServe(*bind, nil)
}