about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2020-01-27 20:28:05 +0100
committerEmile <hanemile@protonmail.com>2020-01-27 20:28:05 +0100
commit0b34876f2b17f8cefcb4192b44f1f8139cf52818 (patch)
tree0e180a10053c36396387b61942549fa4de63216f
parenta0962a4248ef055651cd358d56f6173deb20c289 (diff)
implemented the config struct
-rw-r--r--src/main.go10
1 files changed, 8 insertions, 2 deletions
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 {