Skip to content

Commit

Permalink
Merge pull request #83 from blacknon/develop
Browse files Browse the repository at this point in the history
Update Version 0.6.5

- go-prompt version up to 0.2.6
- Changed the key input mechanism of the parallel shell.
  • Loading branch information
blacknon authored Feb 16, 2022
2 parents 3217d77 + a35ca14 commit 9397205
Show file tree
Hide file tree
Showing 31 changed files with 341 additions and 229 deletions.
207 changes: 207 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
# Copyright (c) 2021 Blacknon. All rights reserved.
# Use of this source code is governed by an MIT license
# that can be found in the LICENSE file.
# reference:
# - https://motemen.hatenablog.com/entry/2019/11/github-actions-crossbuild-rust
# - https://github.com/motemen/lssh/blob/97d3745dcc8931a1d75217573d5ca60705be632f/.github/workflows/release.yml
# - https://github.com/greymd/teip/blob/master/.github/workflows/release.yml


name: Release Job.

on:
push:
branches:
- master

jobs:
# build rust binary
build:
strategy:
matrix:
include:
- goos: linux
goarch: amd64
os: ubuntu-latest
ext: tar.gz
- goos: linux
goarch: amd64
os: ubuntu-latest
ext: rpm
- goos: linux
goarch: amd64
os: ubuntu-latest
ext: deb
- goos: darwin
goarch: amd64
os: macos-latest
ext: tar.gz
# - goos: windows
# goarch: amd64
# os: windows-latest
# ext: zip
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1

- name: Set up Go 1.17
uses: actions/setup-go@v1
with:
go-version: 1.17

- name: Get version
id: package_version
shell: bash
run: |
VERSION="$(go run ./cmd/lssh/ --version | awk '{print $NF}')"
echo "::set-output name=version::$VERSION"
- name: Build binary
run: |
go build -o lssh.${{ matrix.goos }}_${{ matrix.goarch }} ./cmd/lssh
go build -o lscp.${{ matrix.goos }}_${{ matrix.goarch }} ./cmd/lscp
go build -o lsftp.${{ matrix.goos }}_${{ matrix.goarch }} ./cmd/lsftp
- name: Create package file
if: ${{ (matrix.ext == 'tar.gz') || (matrix.ext == 'rpm') || (matrix.ext == 'deb') }}
run: |
_TAR=lssh_${{ steps.package_version.outputs.version }}_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz
mkdir -p package/bin
mv lssh.${{ matrix.goos }}_${{ matrix.goarch }} package/bin/lssh
mv lscp.${{ matrix.goos }}_${{ matrix.goarch }} package/bin/lscp
mv lsftp.${{ matrix.goos }}_${{ matrix.goarch }} package/bin/lsftp
## mkdir -p package/man
## cp man/lssh.1 package/man
cp -r completion package/
## sed -i is not used due to difference between macOS and Linux
perl -i -pe s/___VERSION___/${{ steps.package_version.outputs.version }}/ ./package/.tar2package.yml
## tar czvf "$_TAR" -C "$PWD/package" completion bin man .tar2package.yml
tar czvf "$_TAR" -C "$PWD/package" completion bin .tar2package.yml
# use: https://github.com/greymd/tar2package
- name: Build rpm
id: rpm
if: matrix.ext == 'rpm'
run: |
_TAR=lssh_${{ steps.package_version.outputs.version }}_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz
docker run -i "greymd/tar2rpm:1.0.1" < "$_TAR" > lssh_${{ steps.package_version.outputs.version }}_${{ matrix.goos }}_${{ matrix.goarch }}.rpm
echo ::set-output name=sha256::$( sha256sum lssh_${{ steps.package_version.outputs.version }}_${{ matrix.goos }}_${{ matrix.goarch }}.rpm | awk '{print $1}' )
# use: https://github.com/greymd/tar2package
- name: Build deb
id: deb
if: matrix.ext == 'deb'
run: |
_TAR=lssh_${{ steps.package_version.outputs.version }}_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz
docker run -i "greymd/tar2deb:1.0.1" < "$_TAR" > lssh_${{ steps.package_version.outputs.version }}_${{ matrix.goos }}_${{ matrix.goarch }}.deb
echo ::set-output name=sha256::$( sha256sum lssh_${{ steps.package_version.outputs.version }}_${{ matrix.goos }}_${{ matrix.goarch }}.deb | awk '{print $1}' )
- name: README for rpm
if: matrix.ext == 'rpm'
run: |
_TAR=lssh_${{ steps.package_version.outputs.version }}_${{ matrix.goos }}_${{ matrix.goarch }}.rpm
- name: Upload artifact
if: matrix.ext == 'rpm'
uses: actions/upload-artifact@v1
with:
name: build-${{ matrix.goos }}_${{ matrix.goarch }}
path: lssh_${{ steps.package_version.outputs.version }}_${{ matrix.goos }}_${{ matrix.goarch }}.rpm

- name: README for deb
if: matrix.ext == 'deb'
run: |
_TAR=lssh_${{ steps.package_version.outputs.version }}_${{ matrix.goos }}_${{ matrix.goarch }}.deb
- name: Upload artifact
if: matrix.ext == 'deb'
uses: actions/upload-artifact@v1
with:
name: build-${{ matrix.goos }}_${{ matrix.goarch }}
path: lssh_${{ steps.package_version.outputs.version }}_${{ matrix.goos }}_${{ matrix.goarch }}.deb

- name: Upload artifact
if: matrix.ext == 'tar.gz'
uses: actions/upload-artifact@v1
with:
name: build-${{ matrix.goos }}_${{ matrix.goarch }}
path: lssh_${{ steps.package_version.outputs.version }}_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz

# create package release
create-release:
needs:
- build
runs-on: ubuntu-latest
outputs:
version: ${{ steps.package_version.outputs.version }}
steps:
- uses: actions/checkout@v1

- name: Get version
id: package_version
shell: bash
run: |
VERSION="$(go run ./cmd/lssh/ --version | awk '{print $NF}')"
echo "::set-output name=version::$VERSION"
- id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.package_version.outputs.version }}
release_name: Version ${{ steps.package_version.outputs.version }}
draft: true
prerelease: false

- run: |
echo '${{ steps.create-release.outputs.upload_url }}' > release_upload_url.txt
- uses: actions/upload-artifact@v1
with:
name: create-release
path: release_upload_url.txt

upload-release:
strategy:
matrix:
include:
- goos: linux
goarch: amd64
os: ubuntu-latest
ext: tar.gz
- goos: linux
goarch: amd64
os: ubuntu-latest
ext: rpm
- goos: linux
goarch: amd64
os: ubuntu-latest
ext: deb
- goos: darwin
goarch: amd64
os: macos-latest
ext: tar.gz
needs: [create-release]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v1
with:
name: create-release

- id: upload-url
run: |
echo "::set-output name=url::$(cat create-release/release_upload_url.txt)"
- uses: actions/download-artifact@v1
with:
name: build-${{ matrix.goos }}_${{ matrix.goarch }}

- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.upload-url.outputs.url }}
asset_path: ./build-${{ matrix.goos }}_${{ matrix.goarch }}/lssh_${{ needs.create-release.outputs.version }}_${{ matrix.goos }}_${{ matrix.goarch }}.${{ matrix.ext }}
asset_name: lssh_${{ needs.create-release.outputs.version }}_${{ matrix.goos }}_${{ matrix.goarch }}.${{ matrix.ext }}
asset_content_type: application/octet-stream
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ TUI list select ssh/scp/sftp client tools.

## Description

command to read a prepared list in advance and connect ssh/scp/sftp the selected host. List file is set in yaml format. When selecting a host, you can filter by keywords. Can execute commands concurrently to multiple hosts. Supported multiple ssh proxy, http/socks5 proxy, x11 forward, and port forwarding.
This command utility to read a prepared list in advance and connect ssh/scp/sftp the selected host.
List file is set in yaml format.
When selecting a host, you can filter by keywords.
Can execute commands concurrently to multiple hosts.

lssh also has a shell (parallel shell) that connects to multiple hosts at the same time and pipes the execution results of local commands and remote hosts.
In addition, lsftp also has a shell that can be connected in parallel.

Supported multiple ssh proxy, http/socks5 proxy, x11 forward, and port forwarding.

## Features

Expand Down Expand Up @@ -102,7 +110,7 @@ option(lssh)
blacknon([email protected])

VERSION:
0.6.4
0.6.5

USAGE:
# connect ssh
Expand Down Expand Up @@ -143,7 +151,7 @@ option(lscp)
blacknon([email protected])

VERSION:
0.6.4
0.6.5

USAGE:
# local to remote scp
Expand Down Expand Up @@ -178,7 +186,7 @@ option(lsftp)
blacknon([email protected])

VERSION:
0.6.4
0.6.5

USAGE:
# start lsftp shell
Expand Down
2 changes: 1 addition & 1 deletion cmd/lscp/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ USAGE:
app.Name = "lscp"
app.Usage = "TUI list select and parallel scp client command."
app.Copyright = "blacknon([email protected])"
app.Version = "0.6.4"
app.Version = "0.6.5"

// options
// TODO(blacknon): オプションの追加(0.7.0)
Expand Down
2 changes: 1 addition & 1 deletion cmd/lsftp/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ USAGE:
app.Name = "lsftp"
app.Usage = "TUI list select and parallel sftp client command."
app.Copyright = "blacknon([email protected])"
app.Version = "0.6.4"
app.Version = "0.6.5"

app.Flags = []cli.Flag{
cli.StringFlag{Name: "file,F", Value: defConf, Usage: "config file path"},
Expand Down
2 changes: 1 addition & 1 deletion cmd/lssh/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ USAGE:
app.Name = "lssh"
app.Usage = "TUI list select and parallel ssh client command."
app.Copyright = "blacknon([email protected])"
app.Version = "0.6.4"
app.Version = "0.6.5"

// TODO(blacknon): オプションの追加
// -f ... バックグラウンドでの接続(X11接続やport forwardingをバックグラウンドで実行する場合など)。
Expand Down
File renamed without changes.
39 changes: 26 additions & 13 deletions conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,34 +108,46 @@ type ServerConfig struct {
PKCS11Provider string `toml:"pkcs11provider"` // PKCS11 Provider PATH
PKCS11PIN string `toml:"pkcs11pin"` // PKCS11 PIN code

// pre | post command setting
PreCmd string `toml:"pre_cmd"`
// pre execute command
PreCmd string `toml:"pre_cmd"`

// post execute command
PostCmd string `toml:"post_cmd"`

// proxy setting
ProxyType string `toml:"proxy_type"`
Proxy string `toml:"proxy"`
ProxyCommand string `toml:"proxy_cmd"` // OpenSSH type proxy setting
ProxyType string `toml:"proxy_type"`

Proxy string `toml:"proxy"`

// OpenSSH type proxy setting
ProxyCommand string `toml:"proxy_cmd"`

// local rcfile setting
LocalRcUse string `toml:"local_rc"` // yes|no (default: yes)
// yes|no (default: yes)
LocalRcUse string `toml:"local_rc"`
LocalRcPath []string `toml:"local_rc_file"`
LocalRcDecodeCmd string `toml:"local_rc_decode_cmd"`

// local/remote port forwarding setting
PortForwardMode string `toml:"port_forward"` // [`L`,`l`,`LOCAL`,`local`]|[`R`,`r`,`REMOTE`,`remote`]
PortForwardLocal string `toml:"port_forward_local"` // port forward (local). "host:port"
PortForwardRemote string `toml:"port_forward_remote"` // port forward (remote). "host:port"
// local/remote port forwarding setting.
// ex. [`L`,`l`,`LOCAL`,`local`]|[`R`,`r`,`REMOTE`,`remote`]
PortForwardMode string `toml:"port_forward"`

// port forward (local). "host:port"
PortForwardLocal string `toml:"port_forward_local"`

// port forward (remote). "host:port"
PortForwardRemote string `toml:"port_forward_remote"`

// local/remote port forwarding settings
// {[`L`,`l`,`LOCAL`,`local`]|[`R`,`r`,`REMOTE`,`remote`]}:[localaddress]:[localport]:[remoteaddress]:[remoteport]
// ex. {[`L`,`l`,`LOCAL`,`local`]|[`R`,`r`,`REMOTE`,`remote`]}:[localaddress]:[localport]:[remoteaddress]:[remoteport]
PortForwards []string `toml:"port_forwards"`

// local/remote Port Forwarding slice.
Forwards []*PortForward

// Dynamic Port Forwarding setting
DynamicPortForward string `toml:"dynamic_port_forward"` // ex.) "11080"
// ex.) "11080"
DynamicPortForward string `toml:"dynamic_port_forward"`

// x11 forwarding setting
X11 bool `toml:"x11"`
Expand Down Expand Up @@ -177,7 +189,8 @@ type PortForward struct {
}

// ReadConf load configuration file and return Config structure
// TODO(blacknon): リファクタリング!(v0.6.1) 外出しや処理のまとめなど
// TODO(blacknon): リファクタリング!(v0.6.5) 外出しや処理のまとめなど
// TODO(blacknon): ~/.lssh.confがなくても、openssh用のファイルがアレばそれをみるように処理
func ReadConf(confPath string) (config Config) {
// user path
usr, _ := user.Current()
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require (
github.com/BurntSushi/toml v0.3.1
github.com/blacknon/go-sshlib v0.1.5
github.com/blacknon/textcol v0.0.1
github.com/c-bata/go-prompt v0.2.5
github.com/c-bata/go-prompt v0.2.6
github.com/dustin/go-humanize v1.0.0
github.com/kevinburke/ssh_config v0.0.0-20190724205821-6cfae18c12b8
github.com/mattn/go-runewidth v0.0.13
Expand Down Expand Up @@ -36,7 +36,7 @@ require (
github.com/mattn/go-tty v0.0.3 // indirect
github.com/miekg/pkcs11 v1.1.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/term v1.1.0 // indirect
github.com/pkg/term v1.2.0-beta.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/thales-e-security/pool v0.0.2 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/blacknon/go-sshlib v0.1.5 h1:nHuIi022DS72kf5/WTBRE15NHW43Qb+1umM76Gms
github.com/blacknon/go-sshlib v0.1.5/go.mod h1:sgMpYTYseacjT4Bt9pPwjMd+eMXsLGCjDtoFugXKYDE=
github.com/blacknon/textcol v0.0.1 h1:x9h7yLPGyr8Pdz12XJ30h7Iz5mJlKd0CzfGYxhrmnk8=
github.com/blacknon/textcol v0.0.1/go.mod h1:1x1tHA4cEgiQ8BsKysc60OALSZMG9WjmbjmJvPqIInQ=
github.com/c-bata/go-prompt v0.2.5 h1:3zg6PecEywxNn0xiqcXHD96fkbxghD+gdB2tbsYfl+Y=
github.com/c-bata/go-prompt v0.2.5/go.mod h1:vFnjEGDIIA/Lib7giyE4E9c50Lvl8j0S+7FVlAwDAVw=
github.com/c-bata/go-prompt v0.2.6 h1:POP+nrHE+DfLYx370bedwNhsqmpCUynWPxuHi0C5vZI=
github.com/c-bata/go-prompt v0.2.6/go.mod h1:/LMAke8wD2FsNu9EXNdHxNLbd9MedkPnCdfpU9wwHfY=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a h1:saTgr5tMLFnmy/yg3qDTft4rE5DY2uJ/cCxCe3q0XTU=
Expand Down Expand Up @@ -58,8 +58,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.10.1 h1:VasscCm72135zRysgrJDKsntdmPN+OuU3+nnHYA9wyc=
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
github.com/pkg/term v1.1.0 h1:xIAAdCMh3QIAy+5FrE8Ad8XoDhEU4ufwbaSozViP9kk=
github.com/pkg/term v1.1.0/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw=
github.com/pkg/term v1.2.0-beta.2 h1:L3y/h2jkuBVFdWiJvNfYfKmzcCnILw7mJWm2JQuMppw=
github.com/pkg/term v1.2.0-beta.2/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
Expand Down
Loading

0 comments on commit 9397205

Please sign in to comment.