Skip to content

Commit

Permalink
support zmodem lrzsz ( rz / sz )
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnywong committed Dec 3, 2023
1 parent ee4af17 commit c1f14ff
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,18 @@ _`~/` 代表 HOME 目录。在 Windows 中,请将下文的 `~/` 替换成 `C:\
EnableDragFile Yes
```

- 使用 `--zmodem` 启用 `rz / sz` 功能,想默认启用则可以在 `~/.ssh/config` 或扩展配置 `ExConfigPath` 中配置:

```
Host server0
# 如果配置在 ~/.ssh/config 中,可以加上 `#!!` 前缀,以兼容标准 ssh
EnableZmodem Yes
```

- 需要在客户端( 本地电脑 )上安装 `lrzsz`,Windows 可以从 [lrzsz-win32](https://github.com/trzsz/lrzsz-win32/releases) 下载解压并加到 `PATH` 中。

- 关于进度条,己传文件大小和传输速度不是精确值,会比实际偏大一些,它的主要作用只是指示传输正在进行中。

- 使用 `-oEnableTrzsz=No` 禁用 trzsz 功能,想默认禁用则可以在 `~/.ssh/config` 或扩展配置 `ExConfigPath` 中配置:

```
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ require (
github.com/trzsz/iterm2 v0.1.1
github.com/trzsz/promptui v0.10.5
github.com/trzsz/ssh_config v1.3.4
github.com/trzsz/trzsz-go v1.1.7-0.20231111144918-b45bed013817
github.com/trzsz/trzsz-go v1.1.7-0.20231203152037-fc290aa1e938
golang.org/x/crypto v0.16.0
golang.org/x/sys v0.15.0
golang.org/x/term v0.15.0
)

require (
github.com/UserExistsError/conpty v0.1.1 // indirect
github.com/UserExistsError/conpty v0.1.2 // indirect
github.com/akavel/rsrc v0.10.2 // indirect
github.com/alexflint/go-scalar v1.2.0 // indirect
github.com/andybrewer/mack v0.0.0-20220307193339-22e922cc18af // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/UserExistsError/conpty v0.1.1 h1:cHDsU/XeoeDAQmVvCTV53SrXLG39YJ4++Pp3iAi1gXE=
github.com/UserExistsError/conpty v0.1.1/go.mod h1:PDglKIkX3O/2xVk0MV9a6bCWxRmPVfxqZoTG/5sSd9I=
github.com/UserExistsError/conpty v0.1.2 h1:ikx+zk1ekB8Agiajun6Cpg4Ju/cEaU/mnRZQYT21naI=
github.com/UserExistsError/conpty v0.1.2/go.mod h1:PDglKIkX3O/2xVk0MV9a6bCWxRmPVfxqZoTG/5sSd9I=
github.com/akavel/rsrc v0.10.2 h1:Zxm8V5eI1hW4gGaYsJQUhxpjkENuG91ki8B4zCrvEsw=
github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/alessio/shellescape v1.4.2 h1:MHPfaU+ddJ0/bYWpgIeUnQUqKrlJ1S7BfEYPM4uEoM0=
Expand Down Expand Up @@ -92,8 +92,8 @@ github.com/trzsz/promptui v0.10.5 h1:tlzJkx+JOeE0sqKWmqgaoToZiYqj5G1Mz+QDV97VFu8
github.com/trzsz/promptui v0.10.5/go.mod h1:GMZtu6ZTzU73CBFkzGtmB4wnTROIAbv4GFA74fV8V8g=
github.com/trzsz/ssh_config v1.3.4 h1:7of+6rUmdWdqfgXnH9csgJe1kNkriS9xOiFGx4KCkEw=
github.com/trzsz/ssh_config v1.3.4/go.mod h1:Dl1okTjVVfsrtTA8nqkJ1OnjiCrZY6DUEI2DGT2/YoQ=
github.com/trzsz/trzsz-go v1.1.7-0.20231111144918-b45bed013817 h1:AGD0x1Oo3xIV3Gv7Pv1mGRcVCf7jV69oaEGgDgPs7wM=
github.com/trzsz/trzsz-go v1.1.7-0.20231111144918-b45bed013817/go.mod h1:sOLnYeA77qyF2Aqj+leycDWxFpylV46BA7g6F3gWcfQ=
github.com/trzsz/trzsz-go v1.1.7-0.20231203152037-fc290aa1e938 h1:qut/hta36wp13rlwLvmXNKQsivZoyofW4FxaUNcuBVc=
github.com/trzsz/trzsz-go v1.1.7-0.20231203152037-fc290aa1e938/go.mod h1:zzF7ucjLsEB/2La+59TY5AJMfO8QRhEwoLd1yMqyU3I=
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
Expand Down
1 change: 1 addition & 0 deletions tssh/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type sshArgs struct {
TraceLog bool `arg:"--tracelog" help:"enable trzsz detect trace logs for debugging"`
Relay bool `arg:"--relay" help:"force trzsz run as a relay on the jump server"`
Debug bool `arg:"--debug" help:"verbose mode for debugging, same as ssh's -vvv"`
Zmodem bool `arg:"--zmodem" help:"enable zmodem lrzsz ( rz / sz ) feature"`
EncSecret bool `arg:"--enc-secret" help:"tools: encode secret for configuration"`
NewHost bool `arg:"--new-host" help:"tools: add new host to configuration"`
originalDest string
Expand Down
1 change: 1 addition & 0 deletions tssh/args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func TestSshArgs(t *testing.T) {
assertArgsEqual("--tracelog", sshArgs{TraceLog: true})
assertArgsEqual("--relay", sshArgs{Relay: true})
assertArgsEqual("--debug", sshArgs{Debug: true})
assertArgsEqual("--zmodem", sshArgs{Zmodem: true})

assertArgsEqual("--enc-secret", sshArgs{EncSecret: true})
assertArgsEqual("--new-host", sshArgs{NewHost: true})
Expand Down
1 change: 1 addition & 0 deletions tssh/trzsz.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func enableTrzsz(args *sshArgs, client *ssh.Client, session *ssh.Session, server
TerminalColumns: int32(width),
DetectDragFile: args.DragFile || strings.ToLower(getExOptionConfig(args, "EnableDragFile")) == "yes",
DetectTraceLog: args.TraceLog,
EnableZmodem: args.Zmodem || strings.ToLower(getExOptionConfig(args, "EnableZmodem")) == "yes",
})

// reset terminal size on resize
Expand Down

0 comments on commit c1f14ff

Please sign in to comment.