Browse Source

fix parsing of local address, add command line switch for web interface port

Alan Shreve 12 years ago
parent
commit
305882f844
2 changed files with 8 additions and 9 deletions
  1. 7 8
      src/ngrok/client/cli.go
  2. 1 1
      src/ngrok/client/main.go

+ 7 - 8
src/ngrok/client/cli.go

@@ -6,7 +6,6 @@ import (
 	"fmt"
 	"os"
 	"strconv"
-	"strings"
         "net"
 )
 
@@ -23,6 +22,7 @@ type Options struct {
 	url         string
 	subdomain   string
 	historySize int
+        webport int
 }
 
 func fail(msg string, args ...interface{}) {
@@ -65,8 +65,7 @@ func parseLocalAddr() string {
 	}
 
 	// try to parse as a connection string
-	parts := strings.Split(addr, ":")
-        host, port, err := net.SplitHostPort(addr)
+        _, port, err := net.SplitHostPort(addr)
         if err != nil {
                 fail("%v", err)
         }
@@ -116,10 +115,10 @@ func parseArgs() *Options {
 		"http",
 		"The protocol of the traffic over the tunnel {'http', 'tcp'} (default: 'http')")
 
-	historySize := flag.Int(
-		"history",
-		20,
-		"The number of previous requests to keep in your history")
+        webport := flag.Int(
+                "webport",
+                4040,
+                "The port on which the web interface is served")
 
 	flag.Parse()
 
@@ -130,6 +129,6 @@ func parseArgs() *Options {
 		subdomain:   *subdomain,
 		localaddr:   parseLocalAddr(),
 		protocol:    parseProtocol(*protocol),
-		historySize: *historySize,
+		webport:     *webport,
 	}
 }

+ 1 - 1
src/ngrok/client/main.go

@@ -178,7 +178,7 @@ func Main() {
 	// init ui
 	ctl := ui.NewController()
 	ui.NewTermView(ctl)
-	ui.NewWebView(ctl, s, 9999)
+	ui.NewWebView(ctl, s, opts.webport)
 
 	go control(s, ctl)