Skip to content

Commit

Permalink
Add host option (#174)
Browse files Browse the repository at this point in the history
* add host option

* gitignore logs and uploaded files

* update log messages

---------

Co-authored-by: Jack Tang <[email protected]>
  • Loading branch information
jackhftang and Jack Tang authored Oct 29, 2024
1 parent ba5b8f0 commit be16c8f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/main.flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
15 changes: 9 additions & 6 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}()

Expand Down

0 comments on commit be16c8f

Please sign in to comment.