Skip to content

Commit

Permalink
Bumped v0.5.14
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Rana <vr@labstack.com>
  • Loading branch information
vishr committed Nov 23, 2019
1 parent 61958b6 commit 6beb7de
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
IMAGE = labstack/tunnel
VERSION = 0.5.13
VERSION = 0.5.14

publish:
git tag v$(VERSION)
Expand Down
6 changes: 5 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,13 @@ func initialize() {
viper.Set("daemon_pid", filepath.Join(root, "daemon.pid"))
viper.Set("daemon_addr", filepath.Join(root, "daemon.addr"))
viper.Set("hostname", "labstack.me")
viper.Set("port", 22)
viper.Set("remote_port", 80)
viper.Set("api_url", "https://tunnel.labstack.com/api/v1")
if dev := viper.GetString("DC") == "dev"; dev {
viper.Set("host", "labstack.d:22")
viper.Set("hostname", "labstack.d")
viper.Set("port", 2200)
viper.Set("remote_port", 8000)
viper.Set("api_url", "http://tunnel.labstack.d/api/v1")
viper.SetConfigName("config.dev")
} else {
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

const (
version = "v0.5.13"
version = "v0.5.14"
)

var versionCmd = &cobra.Command{
Expand Down
20 changes: 9 additions & 11 deletions daemon/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

type (
Header struct {
User struct {
ID string `json:"id"`
Protocol Protocol `json:"protocol"`
Target string `json:"target"`
Expand All @@ -45,15 +45,14 @@ type (
started bool
stopped bool
retries time.Duration
Header *Header
user *User
ID string `json:"id"`
Name string `json:"name"`
Random bool `json:"random"`
Hostname string `json:"hostname"`
Port int `json:"port"`
TargetAddress string `json:"target_address"`
RemoteHost string
RemotePort int
RemotePort string
RemoteURI string `json:"remote_uri"`
Status ConnectionStatus `json:"status"`
ConnectedAt time.Time `json:"connected_at"`
Expand Down Expand Up @@ -82,7 +81,7 @@ func (c *Connection) Host() (host string) {
} else if c.Hostname != "" {
h = c.Hostname
}
return net.JoinHostPort(h, "22")
return net.JoinHostPort(h, viper.GetString("port"))
}

func (s *Server) newConnection(req *ConnectRequest) (c *Connection, err error) {
Expand All @@ -95,8 +94,6 @@ func (s *Server) newConnection(req *ConnectRequest) (c *Connection, err error) {
stopChan: make(chan bool),
ID: id,
TargetAddress: req.Address,
RemoteHost: "0.0.0.0",
RemotePort: 80,
Configuration: new(Configuration),
}

Expand All @@ -115,11 +112,12 @@ func (s *Server) newConnection(req *ConnectRequest) (c *Connection, err error) {
c.Name = req.Configuration
req.Protocol = c.Configuration.Protocol
}
c.RemotePort = viper.GetString("remote_port")
if req.Protocol != ProtocolHTTP {
c.RemotePort = 0
c.RemotePort = "0"
}

c.Header = &Header{
c.user = &User{
ID: id,
Protocol: req.Protocol,
Target: req.Address,
Expand All @@ -145,7 +143,7 @@ RECONNECT:
c.startChan <- fmt.Errorf("failed to parse host key: %v", err)
return
}
user, _ := json.Marshal(c.Header)
user, _ := json.Marshal(c.user)
config := &ssh.ClientConfig{
User: string(user),
Auth: []ssh.AuthMethod{
Expand Down Expand Up @@ -210,7 +208,7 @@ RECONNECT:
}()

// Remote listener
l, err := sc.Listen("tcp", fmt.Sprintf("%s:%d", c.RemoteHost, c.RemotePort))
l, err := sc.Listen("tcp", fmt.Sprintf("0.0.0.0:%s", c.RemotePort))
if err != nil {
c.startChan <- fmt.Errorf("failed to listen on remote host: %v", err)
return
Expand Down

0 comments on commit 6beb7de

Please sign in to comment.