Skip to content

Commit 774c9c6

Browse files
committed
Bumbed v0.1.0
Signed-off-by: Vishal Rana <vr@labstack.com>
1 parent 1ff3fdf commit 774c9c6

File tree

475 files changed

+214852
-110
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

475 files changed

+214852
-110
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
vendor
1+
build
2+
dist

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
VERSION = 0.1.0
2+
3+
clean:
4+
rm -rf build
5+
6+
build: clean
7+
xgo --targets=darwin-10.8/amd64,linux/amd64,linux/arm-6,linux/arm-7,linux/arm64,windows-8.0/amd64 --pkg cmd/tunnel -out build/tunnel-$(VERSION) github.com/labstack/tunnel
8+
9+
.PHONY: clean build

cmd/http.go

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,27 @@ import (
88
"github.com/spf13/cobra"
99
)
1010

11-
// httpCmd represents the http command
12-
var err error
13-
var httpCmd = &cobra.Command{
14-
Use: "http",
15-
Short: "Forwards HTTP/HTTPS traffic from internet to a target address",
16-
// Long: ``,
17-
Args: cobra.MinimumNArgs(1),
18-
Run: func(cmd *cobra.Command, args []string) {
19-
t := &tunnel.Tunnel{
20-
Protocol: "http",
21-
RemoteHost: "0.0.0.0",
22-
RemotePort: 80,
23-
}
24-
t.TargetHost, t.TargetPort, err = util.SplitHostPort(args[0])
25-
if err != nil {
26-
log.Fatalf("Failed to parse target address %v\n", err)
27-
}
28-
t.Create()
29-
},
30-
}
11+
var (
12+
err error
13+
httpCmd = &cobra.Command{
14+
Use: "http",
15+
Short: "Forward HTTP/HTTPS traffic from internet to a target address",
16+
// Long: ``,
17+
Args: cobra.MinimumNArgs(1),
18+
Run: func(cmd *cobra.Command, args []string) {
19+
t := &tunnel.Tunnel{
20+
Protocol: "http",
21+
RemoteHost: "0.0.0.0",
22+
RemotePort: 80,
23+
}
24+
t.TargetHost, t.TargetPort, err = util.SplitHostPort(args[0])
25+
if err != nil {
26+
log.Fatalf("Failed to parse target address %v\n", err)
27+
}
28+
t.Create()
29+
},
30+
}
31+
)
3132

3233
func init() {
3334
rootCmd.AddCommand(httpCmd)

cmd/root.go

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,19 @@ import (
44
"fmt"
55
"os"
66

7-
homedir "github.com/mitchellh/go-homedir"
7+
"github.com/mitchellh/go-homedir"
88
"github.com/spf13/cobra"
99
"github.com/spf13/viper"
1010
)
1111

12-
var cfgFile string
13-
14-
// rootCmd represents the base command when called without any subcommands
15-
var rootCmd = &cobra.Command{
16-
Use: "tunnel",
17-
Short: "A brief description of your application",
18-
Long: `A longer description that spans multiple lines and likely contains
19-
examples and usage of using your application. For example:
20-
21-
Cobra is a CLI library for Go that empowers applications.
22-
This application is a tool to generate the needed files
23-
to quickly create a Cobra application.`,
24-
// Uncomment the following line if your bare application
25-
// has an action associated with it:
26-
// Run: func(cmd *cobra.Command, args []string) { },
27-
}
12+
var (
13+
confFile string
14+
rootCmd = &cobra.Command{
15+
Use: "tunnel",
16+
Short: "Tunnel lets you expose local servers to the internet securely",
17+
Long: ``,
18+
}
19+
)
2820

2921
// Execute adds all child commands to the root command and sets flags appropriately.
3022
// This is called by main.main(). It only needs to happen once to the rootCmd.
@@ -37,22 +29,14 @@ func Execute() {
3729

3830
func init() {
3931
cobra.OnInitialize(initConfig)
40-
41-
// Here you will define your flags and configuration settings.
42-
// Cobra supports persistent flags, which, if defined here,
43-
// will be global for your application.
44-
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.tunnel.yaml)")
45-
46-
// Cobra also supports local flags, which will only run
47-
// when this action is called directly.
48-
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
32+
rootCmd.PersistentFlags().StringVarP(&confFile, "config", "c", "", "config file (default is $HOME/.tunnel.yaml)")
4933
}
5034

5135
// initConfig reads in config file and ENV variables if set.
5236
func initConfig() {
53-
if cfgFile != "" {
37+
if confFile != "" {
5438
// Use config file from the flag.
55-
viper.SetConfigFile(cfgFile)
39+
viper.SetConfigFile(confFile)
5640
} else {
5741
// Find home directory.
5842
home, err := homedir.Dir()
@@ -70,6 +54,6 @@ func initConfig() {
7054

7155
// If a config file is found, read it in.
7256
if err := viper.ReadInConfig(); err == nil {
73-
fmt.Println("Using config file:", viper.ConfigFileUsed())
57+
// fmt.Println("Using config file:", viper.ConfigFileUsed())
7458
}
7559
}

cmd/tcp.go

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,26 @@ import (
88
"github.com/spf13/cobra"
99
)
1010

11-
// tcpCmd represents the tcp command
12-
var tcpCmd = &cobra.Command{
13-
Use: "tcp",
14-
Short: "Forwards TCP traffic from internet to a target address",
15-
// Long: ``,
16-
Run: func(cmd *cobra.Command, args []string) {
17-
t := &tunnel.Tunnel{
18-
Protocol: "tcp",
19-
RemoteHost: "0.0.0.0",
20-
RemotePort: 0,
21-
}
22-
t.TargetHost, t.TargetPort, err = util.SplitHostPort(args[0])
23-
if err != nil {
24-
log.Fatalf("Failed to parse target address %v\n", err)
25-
}
26-
t.Create()
27-
},
28-
}
11+
var (
12+
tcpCmd = &cobra.Command{
13+
Use: "tcp",
14+
Short: "Forward TCP traffic from internet to a target address",
15+
// Long: ``,
16+
Args: cobra.MinimumNArgs(1),
17+
Run: func(cmd *cobra.Command, args []string) {
18+
t := &tunnel.Tunnel{
19+
Protocol: "tcp",
20+
RemoteHost: "0.0.0.0",
21+
RemotePort: 0,
22+
}
23+
t.TargetHost, t.TargetPort, err = util.SplitHostPort(args[0])
24+
if err != nil {
25+
log.Fatalf("Failed to parse target address %v\n", err)
26+
}
27+
t.Create()
28+
},
29+
}
30+
)
2931

3032
func init() {
3133
rootCmd.AddCommand(tcpCmd)

cmd/tls.go

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,26 @@ import (
88
"github.com/spf13/cobra"
99
)
1010

11-
// tlsCmd represents the tls command
12-
var tlsCmd = &cobra.Command{
13-
Use: "tls",
14-
Short: "Forwards TLS traffic from internet to a target address",
15-
// Long: ``,
16-
Run: func(cmd *cobra.Command, args []string) {
17-
t := &tunnel.Tunnel{
18-
Protocol: "tls",
19-
RemoteHost: "0.0.0.0",
20-
RemotePort: 0,
21-
}
22-
t.TargetHost, t.TargetPort, err = util.SplitHostPort(args[0])
23-
if err != nil {
24-
log.Fatalf("Failed to parse target address %v\n", err)
25-
}
26-
t.Create()
27-
},
28-
}
11+
var (
12+
tlsCmd = &cobra.Command{
13+
Use: "tls",
14+
Short: "Forward TLS traffic from internet to a target address",
15+
// Long: ``,
16+
Args: cobra.MinimumNArgs(1),
17+
Run: func(cmd *cobra.Command, args []string) {
18+
t := &tunnel.Tunnel{
19+
Protocol: "tls",
20+
RemoteHost: "0.0.0.0",
21+
RemotePort: 0,
22+
}
23+
t.TargetHost, t.TargetPort, err = util.SplitHostPort(args[0])
24+
if err != nil {
25+
log.Fatalf("Failed to parse target address %v\n", err)
26+
}
27+
t.Create()
28+
},
29+
}
30+
)
2931

3032
func init() {
3133
rootCmd.AddCommand(tlsCmd)

cmd/tunnel/main.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
// Copyright © 2018 NAME HERE <EMAIL ADDRESS>
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
14-
151
package main
162

173
import "github.com/labstack/tunnel/cmd"

cmd/version.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ import (
66
"github.com/spf13/cobra"
77
)
88

9-
// versionCmd represents the version command
10-
var versionCmd = &cobra.Command{
11-
Use: "version",
12-
Short: "Print the version of Tunnel",
13-
// Long: ``,
14-
Run: func(cmd *cobra.Command, args []string) {
15-
fmt.Println("v0.0.1")
16-
},
17-
}
9+
var (
10+
versionCmd = &cobra.Command{
11+
Use: "version",
12+
Short: "Print the version of Tunnel",
13+
// Long: ``,
14+
Run: func(cmd *cobra.Command, args []string) {
15+
fmt.Println("v0.1.0")
16+
},
17+
}
18+
)
1819

1920
func init() {
2021
rootCmd.AddCommand(versionCmd)

tunnel.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,14 @@ func (t *Tunnel) Create() {
3535
ssh.Password("password"),
3636
},
3737
HostKeyCallback: ssh.FixedHostKey(hostKey),
38+
BannerCallback: func(message string) error {
39+
fmt.Print(message)
40+
return nil
41+
},
3842
}
3943

4044
// Connect
41-
client, err := ssh.Dial("tcp", "localhost:2200", config)
45+
client, err := ssh.Dial("tcp", "labstack.me:22", config)
4246
if err != nil {
4347
log.Fatalf("Failed to connect %v\n", err)
4448
}

vendor/github.com/fsnotify/fsnotify/.editorconfig

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)