Skip to content

Commit 61958b6

Browse files
committed
Bumped v0.5.13
Signed-off-by: Vishal Rana <vr@labstack.com>
1 parent d6d5c02 commit 61958b6

File tree

5 files changed

+335
-335
lines changed

5 files changed

+335
-335
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
IMAGE = labstack/tunnel
2-
VERSION = 0.5.12
2+
VERSION = 0.5.13
33

44
publish:
55
git tag v$(VERSION)

cmd/root.go

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,106 @@
11
package cmd
22

33
import (
4-
"errors"
5-
"fmt"
6-
"net"
7-
"os"
8-
"path/filepath"
9-
"strings"
4+
"errors"
5+
"fmt"
6+
"net"
7+
"os"
8+
"path/filepath"
9+
"strings"
1010

11-
"github.com/labstack/tunnel-client/daemon"
12-
"github.com/spf13/cobra"
11+
"github.com/labstack/tunnel-client/daemon"
12+
"github.com/spf13/cobra"
1313

14-
"github.com/mitchellh/go-homedir"
15-
"github.com/spf13/viper"
14+
"github.com/mitchellh/go-homedir"
15+
"github.com/spf13/viper"
1616
)
1717

1818
var configuration string
1919
var protocol string
2020
var rootCmd = &cobra.Command{
21-
Use: "tunnel [address]",
22-
Short: "Tunnel lets you expose local servers to the internet securely",
23-
Long: "Signup @ https://tunnel.labstack.com to get an api key and get started",
24-
Args: func(cmd *cobra.Command, args []string) error {
25-
if len(args) < 1 {
26-
return errors.New("requires a target address")
27-
}
28-
return nil
29-
},
30-
Run: func(cmd *cobra.Command, args []string) {
31-
s.Start()
32-
startDaemon()
33-
c, err := getClient()
34-
if err != nil {
35-
exit(err)
36-
}
37-
defer c.Close()
38-
rep := new(daemon.ConnectReply)
39-
addr := args[0]
40-
_, _, err = net.SplitHostPort(addr)
41-
if err != nil && strings.Contains(err.Error(), "missing port") {
42-
addr = ":" + addr
43-
}
44-
err = c.Call("Server.Connect", &daemon.ConnectRequest{
45-
Configuration: configuration,
46-
Address: addr,
47-
Protocol: daemon.Protocol(protocol),
48-
}, rep)
49-
if err != nil {
50-
exit(err)
51-
}
52-
s.Stop()
53-
psRPC()
54-
},
21+
Use: "tunnel [address]",
22+
Short: "Tunnel lets you expose local servers to the internet securely",
23+
Long: "Signup @ https://tunnel.labstack.com to get an api key and get started",
24+
Args: func(cmd *cobra.Command, args []string) error {
25+
if len(args) < 1 {
26+
return errors.New("requires a target address")
27+
}
28+
return nil
29+
},
30+
Run: func(cmd *cobra.Command, args []string) {
31+
s.Start()
32+
startDaemon()
33+
c, err := getClient()
34+
if err != nil {
35+
exit(err)
36+
}
37+
defer c.Close()
38+
rep := new(daemon.ConnectReply)
39+
addr := args[0]
40+
_, _, err = net.SplitHostPort(addr)
41+
if err != nil && strings.Contains(err.Error(), "missing port") {
42+
addr = ":" + addr
43+
}
44+
err = c.Call("Server.Connect", &daemon.ConnectRequest{
45+
Configuration: configuration,
46+
Address: addr,
47+
Protocol: daemon.Protocol(protocol),
48+
}, rep)
49+
if err != nil {
50+
exit(err)
51+
}
52+
s.Stop()
53+
psRPC()
54+
},
5555
}
5656

5757
func Execute() {
58-
if err := rootCmd.Execute(); err != nil {
59-
exit(err)
60-
}
58+
if err := rootCmd.Execute(); err != nil {
59+
exit(err)
60+
}
6161
}
6262

6363
func init() {
64-
cobra.OnInitialize(initialize)
64+
cobra.OnInitialize(initialize)
6565
}
6666

6767
func initialize() {
68-
// Create directories
69-
dir, err := homedir.Dir()
70-
if err != nil {
71-
fmt.Printf("failed to find the home directory: %v", err)
72-
}
73-
root := filepath.Join(dir, ".tunnel")
74-
if err = os.MkdirAll(root, 0755); err != nil {
75-
fmt.Printf("failed to create root directory: %v", err)
76-
}
77-
if _, err := os.OpenFile(filepath.Join(root, "config.yaml"), os.O_RDONLY|os.O_CREATE, 0644); err != nil {
78-
fmt.Printf("failed to create config file: %v", err)
79-
}
68+
// Create directories
69+
dir, err := homedir.Dir()
70+
if err != nil {
71+
fmt.Printf("failed to find the home directory: %v", err)
72+
}
73+
root := filepath.Join(dir, ".tunnel")
74+
if err = os.MkdirAll(root, 0755); err != nil {
75+
fmt.Printf("failed to create root directory: %v", err)
76+
}
77+
if _, err := os.OpenFile(filepath.Join(root, "config.yaml"), os.O_RDONLY|os.O_CREATE, 0644); err != nil {
78+
fmt.Printf("failed to create config file: %v", err)
79+
}
8080

81-
// Config
82-
viper.AutomaticEnv()
83-
viper.Set("root", root)
84-
viper.Set("log_file", filepath.Join(root, "daemon.log"))
85-
viper.Set("daemon_pid", filepath.Join(root, "daemon.pid"))
86-
viper.Set("daemon_addr", filepath.Join(root, "daemon.addr"))
87-
viper.Set("hostname", "labstack.me")
88-
viper.Set("api_url", "https://tunnel.labstack.com/api/v1")
89-
if dev := viper.GetString("DC") == "dev"; dev {
90-
viper.Set("host", "labstack.d:22")
91-
viper.Set("api_url", "http://tunnel.labstack.d/api/v1")
92-
viper.SetConfigName("config.dev")
93-
} else {
94-
viper.SetConfigName("config")
95-
}
96-
viper.AddConfigPath(root)
97-
viper.ReadInConfig()
98-
viper.WatchConfig()
81+
// Config
82+
viper.AutomaticEnv()
83+
viper.Set("root", root)
84+
viper.Set("log_file", filepath.Join(root, "daemon.log"))
85+
viper.Set("daemon_pid", filepath.Join(root, "daemon.pid"))
86+
viper.Set("daemon_addr", filepath.Join(root, "daemon.addr"))
87+
viper.Set("hostname", "labstack.me")
88+
viper.Set("api_url", "https://tunnel.labstack.com/api/v1")
89+
if dev := viper.GetString("DC") == "dev"; dev {
90+
viper.Set("host", "labstack.d:22")
91+
viper.Set("api_url", "http://tunnel.labstack.d/api/v1")
92+
viper.SetConfigName("config.dev")
93+
} else {
94+
viper.SetConfigName("config")
95+
}
96+
viper.AddConfigPath(root)
97+
viper.ReadInConfig()
98+
viper.WatchConfig()
9999
}
100100

101101
func init() {
102-
rootCmd.PersistentFlags().StringVarP(&configuration, "configuration", "c", "",
103-
"configuration name from the console")
104-
rootCmd.PersistentFlags().StringVarP(&protocol, "protocol", "p", daemon.ProtocolHTTP,
105-
"connection protocol (http, tcp, tls)")
102+
rootCmd.PersistentFlags().StringVarP(&configuration, "configuration", "c", "",
103+
"configuration name from the console")
104+
rootCmd.PersistentFlags().StringVarP(&protocol, "protocol", "p", string(daemon.ProtocolHTTP),
105+
"connection protocol (http, tcp, tls)")
106106
}

cmd/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
const (
10-
version = "v0.5.12"
10+
version = "v0.5.13"
1111
)
1212

1313
var versionCmd = &cobra.Command{

0 commit comments

Comments
 (0)