flags.go 934 B

1234567891011121314151617181920212223242526
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "path"
  6. )
  7. import "github.com/mitchellh/go-homedir"
  8. var (
  9. VERSION = "httpsify/v3.1"
  10. HOME_DIR, _ = homedir.Dir()
  11. HTTP_ADDR = flag.String("http", ":http", "the http address to listen on")
  12. HTTPS_ADDR = flag.String("https", ":https", "the https address to listen on")
  13. AUTOREDIRECT = flag.Bool("redirect", false, "automatically redirect http traffic to https")
  14. STORAGE = flag.String("storage", path.Join(HOME_DIR, ".httpsify/certs"), "the ssl certs storage directory")
  15. HOSTS_FILE = flag.String("hosts", path.Join(HOME_DIR, ".httpsify/hosts.json"), "the sites configurations filename")
  16. HSTS = flag.String("hsts", "max-age=86400; includeSubDomains", "the hsts header value, empty value means disable")
  17. EXPOSE_INFO = flag.Bool("expose-info", true, "whether to expose the httpsify info header or not")
  18. )
  19. func InitFlags() {
  20. flag.Parse()
  21. os.MkdirAll(*STORAGE, 0755)
  22. }