|
@@ -1,6 +1,7 @@
|
|
|
package client
|
|
|
|
|
|
import (
|
|
|
+ "fmt"
|
|
|
metrics "github.com/inconshreveable/go-metrics"
|
|
|
"ngrok/client/ui"
|
|
|
"ngrok/proto"
|
|
@@ -11,6 +12,7 @@ import (
|
|
|
type State struct {
|
|
|
id string
|
|
|
publicUrl string
|
|
|
+ publicPort int
|
|
|
serverVersion string
|
|
|
update ui.UpdateStatus
|
|
|
protocol proto.Protocol
|
|
@@ -24,13 +26,20 @@ type State struct {
|
|
|
// implement client.ui.State
|
|
|
func (s State) GetClientVersion() string { return version.MajorMinor() }
|
|
|
func (s State) GetServerVersion() string { return s.serverVersion }
|
|
|
-func (s State) GetPublicUrl() string { return s.publicUrl }
|
|
|
func (s State) GetLocalAddr() string { return s.opts.localaddr }
|
|
|
func (s State) GetWebPort() int { return s.opts.webport }
|
|
|
func (s State) GetStatus() string { return s.status }
|
|
|
func (s State) GetProtocol() proto.Protocol { return s.protocol }
|
|
|
func (s State) GetUpdate() ui.UpdateStatus { return s.update }
|
|
|
|
|
|
+func (s State) GetPublicUrl() string {
|
|
|
+ publicUrl := s.publicUrl
|
|
|
+ if s.publicPort != 80 && s.publicPort != 443 {
|
|
|
+ publicUrl += fmt.Sprintf(":%d", s.publicPort)
|
|
|
+ }
|
|
|
+ return publicUrl
|
|
|
+}
|
|
|
+
|
|
|
func (s State) GetConnectionMetrics() (metrics.Meter, metrics.Timer) {
|
|
|
return s.metrics.connMeter, s.metrics.connTimer
|
|
|
}
|