diff --git a/Dockerfile b/.github/Dockerfile similarity index 100% rename from Dockerfile rename to .github/Dockerfile diff --git a/.github/goreleaser.yml b/.github/goreleaser.yml index d0cece00..0722c7bf 100644 --- a/.github/goreleaser.yml +++ b/.github/goreleaser.yml @@ -1,6 +1,6 @@ -# test this goreleaser config with: -# - cd chisel -# - goreleaser --skip-publish --rm-dist --config .github/goreleaser.yml +# test this file with +# goreleaser release --config goreleaser.yml --clean --snapshot +version: 2 builds: - env: - CGO_ENABLED=0 @@ -12,6 +12,7 @@ builds: - linux - darwin - windows + - openbsd goarch: - 386 - amd64 @@ -31,6 +32,12 @@ builds: gomips: - hardfloat - softfloat +nfpms: + - maintainer: "https://github.com/{{ .Env.GITHUB_USER }}" + formats: + - deb + - rpm + - apk archives: - format: gz files: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 846c4c35..5f2dcdfa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,33 +1,36 @@ -on: [push, pull_request] name: CI +on: + pull_request: {} + push: {} +permissions: write-all jobs: # ================ - # TEST JOB - # runs on every push and PR - # runs 2x3 times (see matrix) + # BUILD AND TEST JOB # ================ test: - name: Test + name: Build & Test strategy: matrix: - go-version: [1.21.x] + # optionally test/build across multiple platforms/Go-versions + go-version: ['1.22'] # '1.16', '1.17', '1.18, platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: - - name: Install Go - uses: actions/setup-go@v5 + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v3 with: go-version: ${{ matrix.go-version }} - - name: Checkout code - uses: actions/checkout@v3 + check-latest: true - name: Build run: go build -v -o /dev/null . - name: Test run: go test -v ./... # ================ - # RELEASE JOBS - # runs after a success test - # only runs on push "v*" tag + # RELEASE BINARIES (on push "v*" tag) # ================ release_binaries: name: Release Binaries @@ -41,9 +44,13 @@ jobs: if: success() uses: docker://goreleaser/goreleaser:latest env: + GITHUB_USER: ${{ github.repository_owner }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: args: release --config .github/goreleaser.yml + # ================ + # RELEASE DOCKER IMAGES (on push "v*" tag) + # ================ release_docker: name: Release Docker Images needs: test @@ -53,17 +60,16 @@ jobs: - name: Check out code uses: actions/checkout@v3 - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 - name: Login to DockerHub uses: docker/login-action@v2 with: username: jpillora password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Docker meta - id: docker_meta + id: meta uses: docker/metadata-action@v4 with: images: jpillora/chisel @@ -74,8 +80,10 @@ jobs: - name: Build and push uses: docker/build-push-action@v3 with: - context: . + file: .github/Dockerfile platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/386,linux/arm/v7,linux/arm/v6 push: true - tags: ${{ steps.docker_meta.outputs.tags }} - labels: ${{ steps.docker_meta.outputs.labels }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file diff --git a/LICENSE b/LICENSE index 7ae236f7..08d56bd7 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Jaime Pillora +Copyright (c) 2024 Jaime Pillora Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 3af60c8e..2b4d2fc5 100644 --- a/README.md +++ b/README.md @@ -422,7 +422,8 @@ Since WebSockets support is required: - `1.6` - Added client stdio support (by @BoleynSu) - `1.7` - Added UDP support - `1.8` - Move to a `scratch`Docker image -- `1.9` - Switch from `--key` seed to P256 key strings with `--key{gen,file}` + bump to Go 1.21 (by @cmenginnz) +- `1.9` - Bump to Go 1.21. Switch from `--key` seed to P256 key strings with `--key{gen,file}` (by @cmenginnz) +- `1.10` - Bump to Go 1.22. Add `.rpm` `.deb` and `.akp` to releases. Fix bad version comparison. ## License diff --git a/main.go b/main.go index 525a2c7d..01f9ca3b 100644 --- a/main.go +++ b/main.go @@ -240,6 +240,9 @@ func server(args []string) { } else if config.KeySeed == "" { config.KeySeed = settings.Env("KEY") } + if config.Auth == "" { + config.Auth = os.Getenv("AUTH") + } s, err := chserver.NewServer(config) if err != nil { log.Fatal(err) diff --git a/server/server_handler.go b/server/server_handler.go index 952aa4d8..a732e2b6 100644 --- a/server/server_handler.go +++ b/server/server_handler.go @@ -19,7 +19,7 @@ func (s *Server) handleClientHandler(w http.ResponseWriter, r *http.Request) { //websockets upgrade AND has chisel prefix upgrade := strings.ToLower(r.Header.Get("Upgrade")) protocol := r.Header.Get("Sec-WebSocket-Protocol") - if upgrade == "websocket" { + if upgrade == "websocket" { if protocol == chshare.ProtocolVersion { s.handleWebsocket(w, r) return @@ -101,13 +101,13 @@ func (s *Server) handleWebsocket(w http.ResponseWriter, req *http.Request) { return } //print if client and server versions dont match - if c.Version != chshare.BuildVersion { - v := c.Version - if v == "" { - v = "" - } - l.Infof("Client version (%s) differs from server version (%s)", - v, chshare.BuildVersion) + cv := strings.TrimPrefix(c.Version, "v") + if cv == "" { + cv = "" + } + sv := strings.TrimPrefix(chshare.BuildVersion, "v") + if cv != sv { + l.Infof("Client version (%s) differs from server version (%s)", cv, sv) } //validate remotes for _, r := range c.Remotes {