summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se (leap communications)>2019-07-05 19:07:32 +0200
committerKali Kaneko <kali@leap.se (leap communications)>2019-07-05 19:07:32 +0200
commit638ff1ddac9d45ad442e78bd698a39fa3469eb6d (patch)
treecb84a27e2f58209fd3c1b8d5e1c3b5bc1479f8fb /main.go
parentba4d83dd8db90f77a861186801ac0fccd015aaef (diff)
add tls
Diffstat (limited to 'main.go')
-rw-r--r--main.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/main.go b/main.go
index d52d5ac..d88c20c 100644
--- a/main.go
+++ b/main.go
@@ -45,6 +45,10 @@ func main() {
var caCrt = flag.String("caCrt", "", "path to the CA public key")
var caKey = flag.String("caKey", "", "path to the CA private key")
var port = flag.Int("port", 8000, "port where the server will listen")
+ var notls = flag.Bool("notls", false, "disable TLS on the service")
+ var tlskey = flag.String("tls_key", "", "path to the key file for TLS")
+ var tlscrt = flag.String("tls_crt", "", "path to the cert file for TLS")
+ flag.Parse()
flag.Parse()
@@ -66,5 +70,11 @@ func main() {
httpFileHandler("/1/configs.json", "./public/1/configs.json")
httpFileHandler("/1/service.json", "./public/1/service.json")
- log.Fatal(http.ListenAndServe(":"+strconv.Itoa(*port), nil))
+ pstr := ":" + strconv.Itoa(*port)
+
+ if *notls == true {
+ log.Fatal(http.ListenAndServe(pstr, nil))
+ } else {
+ log.Fatal(http.ListenAndServeTLS(pstr, *tlscrt, *tlskey, nil))
+ }
}