@@ -19,7 +19,7 @@ import (
1919)
2020
2121type (
22- Header struct {
22+ User struct {
2323 ID string `json:"id"`
2424 Protocol Protocol `json:"protocol"`
2525 Target string `json:"target"`
@@ -45,15 +45,14 @@ type (
4545 started bool
4646 stopped bool
4747 retries time.Duration
48- Header * Header
48+ user * User
4949 ID string `json:"id"`
5050 Name string `json:"name"`
5151 Random bool `json:"random"`
5252 Hostname string `json:"hostname"`
5353 Port int `json:"port"`
5454 TargetAddress string `json:"target_address"`
55- RemoteHost string
56- RemotePort int
55+ RemotePort string
5756 RemoteURI string `json:"remote_uri"`
5857 Status ConnectionStatus `json:"status"`
5958 ConnectedAt time.Time `json:"connected_at"`
@@ -82,7 +81,7 @@ func (c *Connection) Host() (host string) {
8281 } else if c .Hostname != "" {
8382 h = c .Hostname
8483 }
85- return net .JoinHostPort (h , "22" )
84+ return net .JoinHostPort (h , viper . GetString ( "port" ) )
8685}
8786
8887func (s * Server ) newConnection (req * ConnectRequest ) (c * Connection , err error ) {
@@ -95,8 +94,6 @@ func (s *Server) newConnection(req *ConnectRequest) (c *Connection, err error) {
9594 stopChan : make (chan bool ),
9695 ID : id ,
9796 TargetAddress : req .Address ,
98- RemoteHost : "0.0.0.0" ,
99- RemotePort : 80 ,
10097 Configuration : new (Configuration ),
10198 }
10299
@@ -115,11 +112,12 @@ func (s *Server) newConnection(req *ConnectRequest) (c *Connection, err error) {
115112 c .Name = req .Configuration
116113 req .Protocol = c .Configuration .Protocol
117114 }
115+ c .RemotePort = viper .GetString ("remote_port" )
118116 if req .Protocol != ProtocolHTTP {
119- c .RemotePort = 0
117+ c .RemotePort = "0"
120118 }
121119
122- c .Header = & Header {
120+ c .user = & User {
123121 ID : id ,
124122 Protocol : req .Protocol ,
125123 Target : req .Address ,
@@ -145,7 +143,7 @@ RECONNECT:
145143 c .startChan <- fmt .Errorf ("failed to parse host key: %v" , err )
146144 return
147145 }
148- user , _ := json .Marshal (c .Header )
146+ user , _ := json .Marshal (c .user )
149147 config := & ssh.ClientConfig {
150148 User : string (user ),
151149 Auth : []ssh.AuthMethod {
@@ -210,7 +208,7 @@ RECONNECT:
210208 }()
211209
212210 // Remote listener
213- l , err := sc .Listen ("tcp" , fmt .Sprintf ("%s:%d" , c . RemoteHost , c .RemotePort ))
211+ l , err := sc .Listen ("tcp" , fmt .Sprintf ("0.0.0.0:%s" , c .RemotePort ))
214212 if err != nil {
215213 c .startChan <- fmt .Errorf ("failed to listen on remote host: %v" , err )
216214 return
0 commit comments