Skip to content

Commit

Permalink
update. purge pshell(purge other repository) and add http reverse dyn…
Browse files Browse the repository at this point in the history
…amic forward(-r option).
  • Loading branch information
blacknon committed Jul 3, 2024
1 parent 7286c1b commit 2b2af29
Show file tree
Hide file tree
Showing 54 changed files with 199 additions and 11,165 deletions.
9 changes: 4 additions & 5 deletions cmd/lssh/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ USAGE:
# run command parallel in selected server over ssh.
{{.Name}} -p command...
# run command parallel in selected server over ssh, do it in interactively shell.
{{.Name}} -s
`

// Create app
Expand Down Expand Up @@ -85,7 +82,7 @@ USAGE:
cli.StringSliceFlag{Name: "R", Usage: "Remote port forward mode.Specify a `[bind_address:]port:remote_address:port`. If only one port is specified, it will operate as Reverse Dynamic Forward. Only single connection works."},
cli.StringFlag{Name: "D", Usage: "Dynamic port forward mode(Socks5). Specify a `port`. Only single connection works."},
cli.StringFlag{Name: "d", Usage: "HTTP Dynamic port forward mode. Specify a `port`. Only single connection works."},
// cli.StringFlag{Name: "r", Usage: "HTTP Reverse Dynamic port forward mode. Specify a `port`. Only single connection works."},
cli.StringFlag{Name: "r", Usage: "HTTP Reverse Dynamic port forward mode. Specify a `port`. Only single connection works."},

// Other bool
cli.BoolFlag{Name: "w", Usage: "Displays the server header when in command execution mode."},
Expand All @@ -97,7 +94,6 @@ USAGE:
cli.BoolFlag{Name: "parallel,p", Usage: "run command parallel node(tail -F etc...)."},
cli.BoolFlag{Name: "localrc", Usage: "use local bashrc shell."},
cli.BoolFlag{Name: "not-localrc", Usage: "not use local bashrc shell."},
cli.BoolFlag{Name: "pshell,s", Usage: "use parallel-shell(pshell) (alpha)."},
cli.BoolFlag{Name: "list,l", Usage: "print server list from config."},
cli.BoolFlag{Name: "help,h", Usage: "print this help"},
}
Expand Down Expand Up @@ -249,6 +245,9 @@ USAGE:
// HTTP Dynamic port forwarding port
r.HTTPDynamicPortForward = c.String("d")

// HTTP Reverse Dynamic port forwarding port
r.HTTPReverseDynamicPortForward = c.String("r")

r.Start()
return nil
}
Expand Down
Empty file removed cmd/s/.gitkeep
Empty file.
4 changes: 4 additions & 0 deletions conf/conf_struct_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ type ServerConfig struct {
// ex.) "11080"
HTTPDynamicPortForward string `toml:"http_dynamic_port_forward"`

// HTTP Reverse Dynamic Port Forward setting
// ex.) "11080"
HTTPReverseDynamicPortForward string `toml:"http_reverse_dynamic_port_forward"`

// x11 forwarding setting
X11 bool `toml:"x11"`

Expand Down
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/blacknon/lssh

go 1.22.2
go 1.22.4

toolchain go1.22.5

// require
require (
Expand All @@ -11,20 +13,18 @@ require (
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 // indirect
github.com/blacknon/go-sshlib v0.1.11
github.com/blacknon/go-sshlib v0.1.12
github.com/blacknon/go-x11auth v0.1.0 // indirect
github.com/blacknon/textcol v0.0.1
github.com/c-bata/go-prompt v0.2.6
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a // indirect
github.com/disiqueira/gotree v1.0.0
github.com/dustin/go-humanize v1.0.0
github.com/elazarl/goproxy v0.0.0-20231117061959-7cc037d33fb5 // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/kevinburke/ssh_config v0.0.0-20190724205821-6cfae18c12b8
github.com/kr/fs v0.1.0 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/lunixbochs/vtclean v1.0.0 // indirect
github.com/mattn/go-colorable v0.1.7 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
Expand All @@ -48,7 +48,6 @@ require (
golang.org/x/sys v0.19.0
golang.org/x/term v0.19.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
mvdan.cc/sh v2.6.3+incompatible
)

// replace
Expand Down
16 changes: 2 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/blacknon/crypto11 v1.2.6 h1:Mv+Boto0qVR1O2k5lmoCYcyXfiQYY7mQ1P/TcK5Tw
github.com/blacknon/crypto11 v1.2.6/go.mod h1:HThRIRjHpJIJwcExGgNuPCyf26HqcFVTTAnipaXWz7M=
github.com/blacknon/go-prompt v0.2.7 h1:dVdTqVplKvpT/k4bB9BlbcBYl/k6amYX5tvjYBmuKkI=
github.com/blacknon/go-prompt v0.2.7/go.mod h1:zNBmC/BPAyr+3ey1oRhPxuXJS9zz1lEmJpwaoQroe3w=
github.com/blacknon/go-sshlib v0.1.11 h1:cUaAb9Cv0PI9OyQ1xJTz5hvJRki8Jqgf90n4F0MYxOc=
github.com/blacknon/go-sshlib v0.1.11/go.mod h1:GvW6dUsuVG4dcmyqYv40H773YUsUK8MGHdsoQxbtr6M=
github.com/blacknon/go-sshlib v0.1.12 h1:K66DzwzF5RhlKQjcda0R7/FbvslXOayVd75UVzCKfZQ=
github.com/blacknon/go-sshlib v0.1.12/go.mod h1:EqEKtFd4DInkF3Ryx+YXnj70u7pJenVr4H3uEGEgoHI=
github.com/blacknon/go-x11auth v0.1.0 h1:SnljCPWcvglWeGAlKc1RAPMHnOfMpM9+GrTGEUQ1lqQ=
github.com/blacknon/go-x11auth v0.1.0/go.mod h1:SKOCa19LluXHyB+OaLYobquzceE0SWxVW7e/qU5xGBM=
github.com/blacknon/textcol v0.0.1 h1:x9h7yLPGyr8Pdz12XJ30h7Iz5mJlKd0CzfGYxhrmnk8=
Expand All @@ -29,10 +29,6 @@ github.com/disiqueira/gotree v1.0.0 h1:en5wk87n7/Jyk6gVME3cx3xN9KmUCstJ1IjHr4Se4
github.com/disiqueira/gotree v1.0.0/go.mod h1:7CwL+VWsWAU95DovkdRZAtA7YbtHwGk+tLV/kNi8niU=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/elazarl/goproxy v0.0.0-20231117061959-7cc037d33fb5 h1:m62nsMU279qRD9PQSWD1l66kmkXzuYcnVJqL4XLeV2M=
github.com/elazarl/goproxy v0.0.0-20231117061959-7cc037d33fb5/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2 h1:dWB6v3RcOy03t/bUadywsbyrQwCqZeNIEX6M1OtSZOM=
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA=
Expand All @@ -43,11 +39,6 @@ github.com/kevinburke/ssh_config v0.0.0-20190724205821-6cfae18c12b8 h1:AUkD9wwFc
github.com/kevinburke/ssh_config v0.0.0-20190724205821-6cfae18c12b8/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lunixbochs/vtclean v1.0.0 h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+LVb8=
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
Expand Down Expand Up @@ -80,7 +71,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc=
github.com/sevlyar/go-daemon v0.1.5 h1:Zy/6jLbM8CfqJ4x4RPr7MJlSKt90f00kNM1D401C+Qk=
github.com/sevlyar/go-daemon v0.1.5/go.mod h1:6dJpPatBT9eUwM5VCw9Bt6CdX9Tk6UWvhW3MebLDRKE=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
Expand Down Expand Up @@ -137,5 +127,3 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
mvdan.cc/sh v2.6.3+incompatible h1:uXnnFNSBQbKUwwh2iBSkVjG+GbwoMuI+UmBVPnNiWhA=
mvdan.cc/sh v2.6.3+incompatible/go.mod h1:IeeQbZq+x2SUGBensq/jge5lLQbS3XT2ktyp3wrt4x8=
15 changes: 13 additions & 2 deletions ssh/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,16 @@ func (r *Run) cmd() (err error) {
config.ReverseDynamicPortForward = r.ReverseDynamicPortForward
}

// OverWrite dynamic port forwarding
// OverWrite http dynamic port forwarding
if r.HTTPDynamicPortForward != "" {
config.HTTPDynamicPortForward = r.HTTPDynamicPortForward
}

// OverWrite reverse http dynamic port forwarding
if r.HTTPReverseDynamicPortForward != "" {
config.HTTPReverseDynamicPortForward = r.HTTPReverseDynamicPortForward
}

// OverWrite local bashrc use
if r.IsBashrc {
config.LocalRcUse = "yes"
Expand Down Expand Up @@ -150,6 +155,12 @@ func (r *Run) cmd() (err error) {
go c.HTTPDynamicForward("localhost", config.HTTPDynamicPortForward)
}

// HTTP Reverse Dynamic Port Forwarding
if config.HTTPReverseDynamicPortForward != "" {
r.printHTTPReverseDynamicPortForward(config.HTTPReverseDynamicPortForward)
go c.HTTPReverseDynamicForward("localhost", config.HTTPReverseDynamicPortForward)
}

// if tty
if r.IsTerm {
c.Stdin = os.Stdin
Expand All @@ -172,7 +183,7 @@ func (r *Run) cmd() (err error) {
go output.PushInput(exitInput, writers, os.Stdin)

case !r.IsParallel && len(r.ServerList) > 1:
if r.isStdinPipe {
if r.IsStdinPipe {
stdinData, _ = ioutil.ReadAll(os.Stdin)
}
}
Expand Down
Loading

0 comments on commit 2b2af29

Please sign in to comment.