From be16c8fb1a3a9122c9e945ddf228793b85b07016 Mon Sep 17 00:00:00 2001 From: Jack Tang <1190545+jackhftang@users.noreply.github.com> Date: Tue, 29 Oct 2024 20:30:33 +0800 Subject: [PATCH] Add host option (#174) * add host option * gitignore logs and uploaded files * update log messages --------- Co-authored-by: Jack Tang --- .gitignore | 2 ++ src/main.flags.go | 1 + src/main.go | 15 +++++++++------ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index c24ad2a5..34aeac7e 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,8 @@ src/web/Cyinput/* # Release folder and database stuffs */aofs.db release/ +src/files +src/system/logs src/system/neuralnet/yolov3.weights src/system/ao.db.lock src/system/auth/authlog.db.lock diff --git a/src/main.flags.go b/src/main.flags.go index 52488c4e..1f0a8970 100644 --- a/src/main.flags.go +++ b/src/main.flags.go @@ -49,6 +49,7 @@ var systemWideLogger *logger.Logger //The sync map to // =========== SYSTEM FLAGS ============== // Flags related to System startup +var listen_host = flag.String("host", "", "Listening host for HTTP server") var listen_port = flag.Int("port", 8080, "Listening port for HTTP server") var tls_listen_port = flag.Int("tls_port", 8443, "Listening port for HTTPS server") var show_version = flag.Bool("version", false, "Show system build version") diff --git a/src/main.go b/src/main.go index 1c0c4cb9..b75c39e4 100644 --- a/src/main.go +++ b/src/main.go @@ -116,15 +116,18 @@ func main() { if *use_tls { if !*disable_http { go func() { - log.Println("Standard (HTTP) Web server listening at :" + strconv.Itoa(*listen_port)) - http.ListenAndServe(":"+strconv.Itoa(*listen_port), nil) + var address = fmt.Sprintf("%s:%d", *listen_host, *listen_port) + log.Println("Standard (HTTP) Web server listening at", address) + http.ListenAndServe(address, nil) }() } - log.Println("Secure (HTTPS) Web server listening at :" + strconv.Itoa(*tls_listen_port)) - http.ListenAndServeTLS(":"+strconv.Itoa(*tls_listen_port), *tls_cert, *tls_key, nil) + var address = fmt.Sprintf("%s:%d", *listen_host, *tls_listen_port) + log.Println("Secure (HTTPS) Web server listening at", address) + http.ListenAndServeTLS(address, *tls_cert, *tls_key, nil) } else { - log.Println("Web server listening at :" + strconv.Itoa(*listen_port)) - http.ListenAndServe(":"+strconv.Itoa(*listen_port), nil) + var address = fmt.Sprintf("%s:%d", *listen_host, *listen_port) + log.Println("Web server listening at", address) + http.ListenAndServe(address, nil) } }()