fix: also check if correct url parameters have been used

master
phga 4 years ago
parent 1247847e9a
commit c4e4ea0f52

@ -10,7 +10,7 @@ import (
"strings" "strings"
) )
// https://dd.phga.de/dd?usr=<username>&pw=<passwd> // https://dd.phga.de/dd?usr=<username>&pwd=<passwd>
func main() { func main() {
// cheap routing // cheap routing
http.HandleFunc("/dd", handleDynamicUpdate) http.HandleFunc("/dd", handleDynamicUpdate)
@ -30,7 +30,7 @@ func handleDynamicUpdate(w http.ResponseWriter, r *http.Request) {
ip = strings.Split(r.RemoteAddr, ":")[0] ip = strings.Split(r.RemoteAddr, ":")[0]
} }
if len(up) != 2 { if len(up) != 2 || len(up["usr"]) != 1 || len(up["pwd"]) != 1 {
log.Println("Attempted update for:", ip) log.Println("Attempted update for:", ip)
log.Println("Not enough arguments provided:", up) log.Println("Not enough arguments provided:", up)
return return

Loading…
Cancel
Save