Quellcode durchsuchen

added the letsencrypt fix

Mohamed Al Ashaal vor 6 Jahren
Ursprung
Commit
82171b767d
2 geänderte Dateien mit 17 neuen und 3 gelöschten Zeilen
  1. 3 2
      flags.go
  2. 14 1
      server.go

+ 3 - 2
flags.go

@@ -9,9 +9,10 @@ import (
 import "github.com/mitchellh/go-homedir"
 
 var (
-	VERSION     = "httpsify/v3.0.0"
+	VERSION     = "httpsify/v3.1"
 	HOME_DIR, _ = homedir.Dir()
-	HTTPS_ADDR  = flag.String("https", ":443", "the https address to listen on")
+	HTTP_ADDR   = flag.String("http", ":http", "the http address to listen on")
+	HTTPS_ADDR  = flag.String("https", ":https", "the https address to listen on")
 	STORAGE     = flag.String("storage", path.Join(HOME_DIR, ".httpsify/certs"), "the ssl certs storage directory")
 	HOSTS_FILE  = flag.String("hosts", path.Join(HOME_DIR, ".httpsify/hosts.json"), "the sites configurations filename")
 	HSTS        = flag.String("hsts", "max-age=86400; includeSubDomains", "the hsts header value, empty value means disable")

+ 14 - 1
server.go

@@ -30,13 +30,26 @@ func InitServer() error {
 			return errors.New("Unkown host(" + host + ")")
 		},
 	}
+
+	errchan := make(chan error)
+
 	s := &http.Server{
 		Addr:      *HTTPS_ADDR,
 		TLSConfig: &tls.Config{GetCertificate: m.GetCertificate},
 		Handler:   ServeHTTP(),
 	}
+
 	log.SetOutput(ioutil.Discard)
-	return s.ListenAndServeTLS("", "")
+
+	go (func() {
+		errchan <- http.ListenAndServe(*HTTP_ADDR, m.HTTPHandler(nil))
+	})()
+
+	go (func() {
+		errchan <- s.ListenAndServeTLS("", "")
+	})()
+
+	return <-errchan
 }
 
 // The main server handler