Skip to content
Snippets Groups Projects
Commit afe77169 authored by David Fifield's avatar David Fifield
Browse files

Replace --webPort and --tlsPort with a single --addr option.

parent 2d89aa0b
No related branches found
No related tags found
No related merge requests found
......@@ -42,9 +42,7 @@ without having to run as root:
```
setcap 'cap_net_bind_service=+ep' /usr/local/bin/broker
```
You can control the listening port with the --tlsPort
or --webPort options (--webPort is honored only when
also using --disable-tls).
You can control the listening port with the --addr option.
You'll need to provide the URL of the custom broker
to the client plugin using the `--url $URL` flag.
......@@ -234,14 +234,13 @@ func ipHandler(w http.ResponseWriter, r *http.Request) {
func main() {
var acmeEmail string
var acmeHostnamesCommas string
var addr string
var disableTLS bool
var http_port, https_port string
flag.StringVar(&acmeEmail, "acme-email", "", "optional contact email for Let's Encrypt notifications")
flag.StringVar(&acmeHostnamesCommas, "acme-hostnames", "", "comma-separated hostnames for TLS certificate")
flag.StringVar(&addr, "addr", ":443", "address to listen on")
flag.BoolVar(&disableTLS, "disable-tls", false, "don't use HTTPS")
flag.StringVar(&http_port, "webPort", "80", "HTTP port number")
flag.StringVar(&https_port, "tlsPort", "443", "HTTPS port number")
flag.Parse()
ctx := NewBrokerContext()
......@@ -257,7 +256,9 @@ func main() {
http.Handle("/debug", SnowflakeHandler{ctx, debugHandler})
var err error
var server http.Server
server := http.Server{
Addr: addr,
}
if acmeHostnamesCommas != "" {
acmeHostnames := strings.Split(acmeHostnamesCommas, ",")
......@@ -269,11 +270,9 @@ func main() {
Email: acmeEmail,
}
server.Addr = net.JoinHostPort("", https_port)
server.TLSConfig = &tls.Config{GetCertificate: certManager.GetCertificate}
err = server.ListenAndServeTLS("", "")
} else if disableTLS {
server.Addr = net.JoinHostPort("", http_port)
err = server.ListenAndServe()
} else {
log.Fatal("the --acme-hostnames or --disable-tls option is required")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment