Skip to content

Commit

Permalink
feat(cmd/proxy/tcp): Add proxy, proxy tcp command
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejsika committed Aug 21, 2021
1 parent f60eceb commit 82b1320
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
_ "github.com/sikalabs/slu/cmd/postgres/create"
_ "github.com/sikalabs/slu/cmd/postgres/drop"
_ "github.com/sikalabs/slu/cmd/postgres/list"
_ "github.com/sikalabs/slu/cmd/proxy"
_ "github.com/sikalabs/slu/cmd/proxy/tcp"
"github.com/sikalabs/slu/cmd/root"
_ "github.com/sikalabs/slu/cmd/version"
"github.com/spf13/cobra"
Expand Down
15 changes: 15 additions & 0 deletions cmd/proxy/proxy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package proxy

import (
"github.com/sikalabs/slu/cmd/root"
"github.com/spf13/cobra"
)

var Cmd = &cobra.Command{
Use: "proxy",
Short: "Proxy Utils",
}

func init() {
root.RootCmd.AddCommand(Cmd)
}
40 changes: 40 additions & 0 deletions cmd/proxy/tcp/tcp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package tcp

import (
proxy_cmd "github.com/sikalabs/slu/cmd/proxy"
"github.com/sikalabs/slu/utils/3rdparty/go_tcp_proxy"

"github.com/spf13/cobra"
)

var CmdFlagLocalAddr string
var CmdFlagRemoteAddr string

var Cmd = &cobra.Command{
Use: "tcp",
Short: "TCP Proxy",
Args: cobra.NoArgs,
Run: func(c *cobra.Command, args []string) {
go_tcp_proxy.RunProxy(CmdFlagLocalAddr, CmdFlagRemoteAddr)
},
}

func init() {
proxy_cmd.Cmd.AddCommand(Cmd)
Cmd.Flags().StringVarP(
&CmdFlagLocalAddr,
"local",
"l",
"",
"Local address (eg. :8000)",
)
Cmd.MarkFlagRequired("local")
Cmd.Flags().StringVarP(
&CmdFlagRemoteAddr,
"remote",
"r",
"",
"Remote address (eg. neverssl.com:80)",
)
Cmd.MarkFlagRequired("target")
}

0 comments on commit 82b1320

Please sign in to comment.