Browse Source

pass the protocol to the client UIs. only show http requests in terminal if protocol is http. cleaner terminal representation of public port forwarding

Alan Shreve 12 years ago
parent
commit
0d9ec62205
4 changed files with 15 additions and 9 deletions
  1. 1 0
      client/main.go
  2. 2 0
      client/state.go
  3. 1 0
      client/ui/interface.go
  4. 11 9
      client/ui/terminal.go

+ 1 - 0
client/main.go

@@ -197,6 +197,7 @@ func Main() {
 
 	// set initial ui state
 	s.status = "connecting"
+	s.protocol = opts.protocol
 	s.Update()
 
 	go control(s)

+ 2 - 0
client/state.go

@@ -10,6 +10,7 @@ type State struct {
 	id        string
 	ui        *ui.Ui
 	publicUrl string
+	protocol  string
 	history   *RequestHistory
 	opts      *Options
 	metrics   *ClientMetrics
@@ -25,6 +26,7 @@ func (s State) GetVersion() string   { return "" }
 func (s State) GetPublicUrl() string { return s.publicUrl }
 func (s State) GetLocalAddr() string { return s.opts.localaddr }
 func (s State) GetStatus() string    { return s.status }
+func (s State) GetProtocol() string  { return s.protocol }
 func (s State) GetHistory() []ui.HttpRequest {
 	// go sucks
 	historyEntries := make([]ui.HttpRequest, len(s.historyEntries))

+ 1 - 0
client/ui/interface.go

@@ -15,6 +15,7 @@ type State interface {
 	GetPublicUrl() string
 	GetLocalAddr() string
 	GetStatus() string
+	GetProtocol() string
 	GetHistory() []HttpRequest
 	IsStopping() bool
 	GetConnectionMetrics() (metrics.Meter, metrics.Timer)

+ 11 - 9
client/ui/terminal.go

@@ -89,8 +89,8 @@ func (t *Term) draw(updates chan State) {
 			msec := float64(time.Millisecond)
 
 			printf(0, 2, "%-30s%s", "Version", state.GetVersion())
-			printf(0, 3, "%-30s%s", "Public URL", state.GetPublicUrl())
-			printf(0, 4, "%-30s%s", "Local Address", state.GetLocalAddr())
+			printf(0, 3, "%-30s%s -> %s", "Forwarding", state.GetPublicUrl(), state.GetLocalAddr())
+			printf(0, 4, "%-30s%s", "HTTP Dashboard", "http://127.0.0.1:9999")
 			printfAttr(0, 5, t.statusColorMap[state.GetStatus()], "%-30s%s", "Tunnel Status", state.GetStatus())
 
 			connMeter, connTimer := state.GetConnectionMetrics()
@@ -106,13 +106,15 @@ func (t *Term) draw(updates chan State) {
 			printf(0, 11, "%-30s%d", "Bytes Out", bytesOutCount.Count())
 			printf(0, 12, "%-30s%.2f", "Bytes Out/req", bytesOut.Mean())
 
-			printf(0, 14, "Last HTTP Requests")
-			for i, http := range state.GetHistory() {
-				req := http.GetRequest()
-				resp := http.GetResponse()
-				printf(0, 15+i, "%s %v", req.Method, req.URL)
-				if resp != nil {
-					printf(30, 15+i, "%s", resp.Status)
+			if state.GetProtocol() == "http" {
+				printf(0, 13, "HTTP Requests")
+				for i, http := range state.GetHistory() {
+					req := http.GetRequest()
+					resp := http.GetResponse()
+					printf(0, 15+i, "%s %v", req.Method, req.URL)
+					if resp != nil {
+						printf(30, 15+i, "%s", resp.Status)
+					}
 				}
 			}