From 0b34876f2b17f8cefcb4192b44f1f8139cf52818 Mon Sep 17 00:00:00 2001 From: Emile Date: Mon, 27 Jan 2020 20:28:05 +0100 Subject: implemented the config struct --- src/main.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/main.go') diff --git a/src/main.go b/src/main.go index 74f8f51..5a6d851 100644 --- a/src/main.go +++ b/src/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "log" "net/http" @@ -22,10 +23,14 @@ func main() { // create a cities map mapping a city to a location cities = make(map[string]location) + // parse flags building a config struct + config := parseFlags() + // start the ssh server log.Println("Starting SSH listener") go func() { - listenErr := ssh.ListenAndServe(":2222", nil, ssh.PasswordAuth(handlePass)) + sshPortString := fmt.Sprintf(":%d", config.sshPort) + listenErr := ssh.ListenAndServe(sshPortString, nil, ssh.PasswordAuth(handlePass)) if listenErr != nil { log.Fatalln(listenErr.Error()) } @@ -40,7 +45,8 @@ func main() { r.HandleFunc("/locations", locationHandlerEndpoint) // start the http server exposing the metrics and the locations - listenErr := http.ListenAndServe(":8084", r) + httpPortString := fmt.Sprintf(":%d", config.httpPort) + listenErr := http.ListenAndServe(httpPortString, r) // handle potential errors if listenErr != nil { -- cgit 1.4.1