fix(main.go): add validation for AUTH_USERNAME and AUTH_PASSWORD to ensure both are provided or neither is provided

This commit is contained in:
Timofey Gelazoniya 2023-10-31 05:48:14 +03:00
parent cacc311854
commit 8e0a899bf2
Signed by: zeldon
GPG Key ID: 047886915281DD2A

View File

@ -116,6 +116,10 @@ func main() {
flag.StringVar(&AUTH_PASSWORD, "password", "", "Password for proxy authentication")
flag.Parse()
if (AUTH_USERNAME == "" && AUTH_PASSWORD != "") || (AUTH_USERNAME != "" && AUTH_PASSWORD == "") {
log.Fatal("Error: Both username and password must be provided, or neither should be.")
}
server := &http.Server{
Addr: ":" + PORT,
Handler: http.HandlerFunc(mainHandler),