Skip to content

Commit

Permalink
Initial project
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnywong committed Jun 8, 2024
1 parent 7f1f867 commit 6e71ec1
Show file tree
Hide file tree
Showing 12 changed files with 307 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: trzsz
36 changes: 36 additions & 0 deletions .github/workflows/gotest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Go test tsshd
on: [push]
jobs:
go-test-on-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout tsshd
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: go test
run: go test -v -count=1 ./tsshd
go-test-on-macos:
runs-on: macos-latest
steps:
- name: Checkout tsshd
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: go test
run: go test -v -count=1 ./tsshd
go-test-on-windows:
runs-on: windows-latest
steps:
- name: Checkout tsshd
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: go test
run: go test -v -count=1 ./tsshd
39 changes: 39 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release and publish tsshd
on:
release:
types: [released]
jobs:
release-and-publish:
name: Release and publish tsshd
runs-on: ubuntu-latest
steps:
- name: Checkout tsshd
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean --skip=publish
- name: Upload Release Assets
uses: trzsz/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ github.event.release.id }}
assets_path: |
dist/*.tar.gz
dist/*.zip
dist/*.rpm
dist/*_checksums.txt
- name: Publish rpm to Gemfury
env:
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
run: |
for filename in dist/tsshd*.rpm; do
curl -F package=@"$filename" https://{$FURY_TOKEN}@push.fury.io/trzsz/
done
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@
# Go workspace file
go.work
go.work.sum

bin/
debian/files

*.swp
*.swo

dist/
vendor/
74 changes: 74 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
project_name: tsshd
before:
hooks:
- go mod tidy
builds:
- id: tsshd
main: ./cmd/tsshd
binary: tsshd
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- "386"
- amd64
- arm
- arm64
- loong64
goarm:
- "6"
- "7"
ignore:
- goos: windows
goarch: arm
- goos: darwin
goarch: arm
archives:
- id: tsshd
name_template: >-
{{ .ProjectName }}_
{{- .Version }}_
{{- if eq .Os "darwin" }}macos_
{{- else }}{{ .Os }}_{{ end }}
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else if eq .Arch "arm64" }}aarch64
{{- else if eq .Arch "arm" }}armv{{ .Arm }}
{{- else }}{{ .Arch }}{{ end }}
wrap_in_directory: true
format_overrides:
- goos: windows
format: zip
files:
- none*
nfpms:
- id: tsshd
builds:
- tsshd
file_name_template: >-
{{ .ProjectName }}_
{{- .Version }}_
{{- if eq .Os "darwin" }}macos_
{{- else }}{{ .Os }}_{{ end }}
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else if eq .Arch "arm64" }}aarch64
{{- else if eq .Arch "arm" }}armv{{ .Arm }}
{{- else }}{{ .Arch }}{{ end }}
homepage: https://trzsz.github.io/
maintainer: Lonny Wong <[email protected]>
description: |-
The `tssh --udp` works like `mosh`, and the `tsshd` works like `mosh-server`.
license: MIT
formats:
- rpm
bindir: /usr/bin
rpm:
group: Unspecified
snapshot:
name_template: "{{ .Version }}.next"
checksum:
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 trzsz
Copyright (c) 2024 The Trzsz SSH Authors.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
BIN_DIR := ./bin
BIN_DST := /usr/bin

ifdef GOOS
ifeq (${GOOS}, windows)
WIN_TARGET := True
endif
else
ifeq (${OS}, Windows_NT)
WIN_TARGET := True
endif
endif

ifdef WIN_TARGET
TSSHD := tsshd.exe
else
TSSHD := tsshd
endif

GO_TEST := ${shell basename `which gotest 2>/dev/null` 2>/dev/null || echo go test}

.PHONY: all clean test install

all: ${BIN_DIR}/${TSSHD}

${BIN_DIR}/${TSSHD}: $(wildcard ./cmd/tsshd/*.go ./tsshd/*.go) go.mod go.sum
go build -o ${BIN_DIR}/ ./cmd/tsshd

clean:
-rm -f ${BIN_DIR}/tsshd{,.exe}

test:
${GO_TEST} -v -count=1 ./tsshd

install: all
mkdir -p ${DESTDIR}${BIN_DST}
cp ${BIN_DIR}/tsshd ${DESTDIR}${BIN_DST}/
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# tsshd
The `tssh --udp` works like `mosh`, and the `tsshd` works like `mosh-server`.

The [`tssh --udp`](https://github.com/trzsz/trzsz-ssh) works like [`mosh`](https://github.com/mobile-shell/mosh), and the `tsshd` works like `mosh-server`.
35 changes: 35 additions & 0 deletions cmd/tsshd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
MIT License
Copyright (c) 2024 The Trzsz SSH Authors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

package main

import (
"os"

"github.com/trzsz/tsshd/tsshd"
)

func main() {
os.Exit(tsshd.TsshdMain())
}
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/trzsz/tsshd

go 1.20

require github.com/trzsz/go-arg v1.5.3

require (
github.com/alexflint/go-scalar v1.2.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
)
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
github.com/alexflint/go-scalar v1.2.0 h1:WR7JPKkeNpnYIOfHRa7ivM21aWAdHD0gEWHCx+WQBRw=
github.com/alexflint/go-scalar v1.2.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/trzsz/go-arg v1.5.3 h1:eIDwDEmvSahtr5HpQOLrSa+YMqWQQ0H20xx60XgXQJw=
github.com/trzsz/go-arg v1.5.3/go.mod h1:IC6Z/FiVH7uYvcbp1/gJhDYCFPS/GkL0APYakVvgY4I=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
51 changes: 51 additions & 0 deletions tsshd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
MIT License
Copyright (c) 2024 The Trzsz SSH Authors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

package tsshd

import (
"fmt"

"github.com/trzsz/go-arg"
)

const kTsshdVersion = "0.1.0"

type tsshdArgs struct {
}

func (tsshdArgs) Description() string {
return "tsshd works with `tssh --udp`, just like mosh-server.\n"
}

func (tsshdArgs) Version() string {
return fmt.Sprintf("trzsz sshd %s", kTsshdVersion)
}

// TsshdMain is the main function of `tsshd` binary.
func TsshdMain() int {
var args tsshdArgs
arg.MustParse(&args)
return 0
}

0 comments on commit 6e71ec1

Please sign in to comment.