[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [snowflake/master] Replace --webPort and --tlsPort with a single --addr option.



commit afe771690364e14586f24d98b65f0a2172cac1cc
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Fri Jul 14 20:29:02 2017 -0700

    Replace --webPort and --tlsPort with a single --addr option.
---
 broker/README.md |  4 +---
 broker/broker.go | 11 +++++------
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/broker/README.md b/broker/README.md
index 8d8c968..38a8029 100644
--- a/broker/README.md
+++ b/broker/README.md
@@ -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.
diff --git a/broker/broker.go b/broker/broker.go
index 9892fc3..a41265b 100644
--- a/broker/broker.go
+++ b/broker/broker.go
@@ -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")



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits