From 8e0a899bf2212079ea1155259f2755f05df07809 Mon Sep 17 00:00:00 2001 From: xzeldon Date: Tue, 31 Oct 2023 05:48:14 +0300 Subject: [PATCH] fix(main.go): add validation for AUTH_USERNAME and AUTH_PASSWORD to ensure both are provided or neither is provided --- main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.go b/main.go index 3a3561a..1d0c22f 100644 --- a/main.go +++ b/main.go @@ -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),