Explorar el Código

added support for hsts header and more cmd args

Mohamed Al Ashaal hace 6 años
padre
commit
c37269b071
Se han modificado 2 ficheros con 9 adiciones y 2 borrados
  1. 3 1
      flags.go
  2. 6 1
      server.go

+ 3 - 1
flags.go

@@ -9,11 +9,13 @@ import (
 import "github.com/mitchellh/go-homedir"
 
 var (
-	VERSION 	= "httpsify/v3.0.0"
+	VERSION     = "httpsify/v3.0.0"
 	HOME_DIR, _ = homedir.Dir()
 	HTTPS_ADDR  = flag.String("https", ":443", "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")
+	EXPOSE_INFO = flag.Bool("expose-info", true, "whether to expose the httpsify info header or not")
 )
 
 func InitFlags() {

+ 6 - 1
server.go

@@ -52,7 +52,12 @@ func ServeHTTP() http.Handler {
 					colorize(color.FgRed, "⇛", err.Error())
 				}
 			}
-			res.Header().Set("X-HTTPSIFY-Version", VERSION)
+			if *EXPOSE_INFO {
+				res.Header().Set("X-HTTPSIFY-Version", VERSION)
+			}
+			if *HSTS != "" {
+				res.Header().Set("Strict-Transport-Security", *HSTS)
+			}
 			loadbalancer.ServeHTTP(res, req)
 			return
 		}