From f71420139e76835709daa0f1effa52438b3d713c Mon Sep 17 00:00:00 2001 From: Henrique Santos Date: Tue, 6 Aug 2024 18:07:58 +0100 Subject: [PATCH 1/4] fix(RDGRS-662): server side keep alive From chisel#442 . Not tested --- share/tunnel/tunnel.go | 62 ++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/share/tunnel/tunnel.go b/share/tunnel/tunnel.go index 0cfba6fa..f06039b4 100644 --- a/share/tunnel/tunnel.go +++ b/share/tunnel/tunnel.go @@ -18,7 +18,7 @@ import ( "golang.org/x/sync/errgroup" ) -//Config a Tunnel +// Config a Tunnel type Config struct { *cio.Logger Inbound bool @@ -27,13 +27,13 @@ type Config struct { KeepAlive time.Duration } -//Tunnel represents an SSH tunnel with proxy capabilities. -//Both chisel client and server are Tunnels. -//chisel client has a single set of remotes, whereas -//chisel server has multiple sets of remotes (one set per client). -//Each remote has a 1:1 mapping to a proxy. -//Proxies listen, send data over ssh, and the other end of the ssh connection -//communicates with the endpoint and returns the response. +// Tunnel represents an SSH tunnel with proxy capabilities. +// Both chisel client and server are Tunnels. +// chisel client has a single set of remotes, whereas +// chisel server has multiple sets of remotes (one set per client). +// Each remote has a 1:1 mapping to a proxy. +// Proxies listen, send data over ssh, and the other end of the ssh connection +// communicates with the endpoint and returns the response. type Tunnel struct { Config //ssh connection @@ -47,7 +47,7 @@ type Tunnel struct { socksServer *socks5.Server } -//New Tunnel from the given Config +// New Tunnel from the given Config func New(c Config) *Tunnel { c.Logger = c.Logger.Fork("tun") t := &Tunnel{ @@ -68,7 +68,7 @@ func New(c Config) *Tunnel { return t } -//BindSSH provides an active SSH for use for tunnelling +// BindSSH provides an active SSH for use for tunnelling func (t *Tunnel) BindSSH(ctx context.Context, c ssh.Conn, reqs <-chan *ssh.Request, chans <-chan ssh.NewChannel) error { //link ctx to ssh-conn go func() { @@ -104,7 +104,7 @@ func (t *Tunnel) BindSSH(ctx context.Context, c ssh.Conn, reqs <-chan *ssh.Reque return err } -//getSSH blocks while connecting +// getSSH blocks while connecting func (t *Tunnel) getSSH(ctx context.Context) ssh.Conn { //cancelled already? if isDone(ctx) { @@ -140,8 +140,8 @@ func (t *Tunnel) activatingConnWait() <-chan struct{} { return ch } -//BindRemotes converts the given remotes into proxies, and blocks -//until the caller cancels the context or there is a proxy error. +// BindRemotes converts the given remotes into proxies, and blocks +// until the caller cancels the context or there is a proxy error. func (t *Tunnel) BindRemotes(ctx context.Context, remotes []*settings.Remote) error { if len(remotes) == 0 { return errors.New("no remotes") @@ -174,16 +174,42 @@ func (t *Tunnel) BindRemotes(ctx context.Context, remotes []*settings.Remote) er func (t *Tunnel) keepAliveLoop(sshConn ssh.Conn) { //ping forever + + //reply_timeout set to KeepAlive interval, if KeepAlive is less than 10s, set reply_timeout to 10s + //maybe a new config option for reply_timeout is also fine + reply_timeout := t.Config.KeepAlive + + if reply_timeout < 10*time.Second { + reply_timeout = 10 * time.Second + } + for { time.Sleep(t.Config.KeepAlive) - _, b, err := sshConn.SendRequest("ping", true, nil) + + errChannel := make(chan error, 2) + + time.AfterFunc(reply_timeout, func() { + errChannel <- errors.New("KEEPALIVE REPLY TIMEOUT ERROR") + }) + + go func() { + _, b, err := sshConn.SendRequest("ping", true, nil) + + ret_err := err + + if err == nil && len(b) > 0 && !bytes.Equal(b, []byte("pong")) { + t.Debugf("strange ping response") + ret_err = errors.New("strange ping response") + } + + errChannel <- ret_err + }() + + err := <-errChannel + if err != nil { break } - if len(b) > 0 && !bytes.Equal(b, []byte("pong")) { - t.Debugf("strange ping response") - break - } } //close ssh connection on abnormal ping sshConn.Close() From a0feabe11ce12bbc00cd8315eac485e6f44477a0 Mon Sep 17 00:00:00 2001 From: Henrique Santos <103441484+OS-henriquesantos@users.noreply.github.com> Date: Mon, 12 Aug 2024 16:20:35 +0100 Subject: [PATCH 2/4] feat(RDGRS-662): build image (#20) (#21) * feat(RDGRS-662): build image * feat(RDGRS-662): restore test CI and dependabot * feat(RDGRS-662): test CI only on linux * feat(RDGRS-662): add version to goreleaser --- .github/goreleaser.yml | 46 -------------------- .github/workflows/ci.yml | 59 +------------------------- .github/{ => workflows}/dependabot.yml | 2 +- Dockerfile | 19 ++------- go.sum | 11 +---- goreleaser.yml | 41 ++++++++++++++++++ 6 files changed, 48 insertions(+), 130 deletions(-) delete mode 100644 .github/goreleaser.yml rename .github/{ => workflows}/dependabot.yml (91%) create mode 100644 goreleaser.yml diff --git a/.github/goreleaser.yml b/.github/goreleaser.yml deleted file mode 100644 index d0cece00..00000000 --- a/.github/goreleaser.yml +++ /dev/null @@ -1,46 +0,0 @@ -# test this goreleaser config with: -# - cd chisel -# - goreleaser --skip-publish --rm-dist --config .github/goreleaser.yml -builds: - - env: - - CGO_ENABLED=0 - ldflags: - - -s -w -X github.com/jpillora/chisel/share.BuildVersion={{.Version}} - flags: - - -trimpath - goos: - - linux - - darwin - - windows - goarch: - - 386 - - amd64 - - arm - - arm64 - - ppc64 - - ppc64le - - mips - - mipsle - - mips64 - - mips64le - - s390x - goarm: - - 5 - - 6 - - 7 - gomips: - - hardfloat - - softfloat -archives: - - format: gz - files: - - none* -release: - draft: true - prerelease: auto -changelog: - sort: asc - filters: - exclude: - - "^docs:" - - "^test:" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b79e1621..83ecab03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: go-version: [1.21.x] - platform: [ubuntu-latest, macos-latest, windows-latest] + platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} steps: - name: Install Go @@ -23,59 +23,4 @@ jobs: - 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: - name: Release Binaries - needs: test - if: startsWith(github.ref, 'refs/tags/v') - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v3 - - name: goreleaser - if: success() - uses: docker://goreleaser/goreleaser:latest - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - args: release --config .github/goreleaser.yml - release_docker: - name: Release Docker Images - needs: test - if: startsWith(github.ref, 'refs/tags/v') - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v3 - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: jpillora - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Docker meta - id: docker_meta - uses: docker/metadata-action@v4 - with: - images: jpillora/chisel - tags: | - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - name: Build and push - uses: docker/build-push-action@v3 - with: - context: . - 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 }} + run: go test -v ./... \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/workflows/dependabot.yml similarity index 91% rename from .github/dependabot.yml rename to .github/workflows/dependabot.yml index 2dd92b7b..6067b7de 100644 --- a/.github/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -10,4 +10,4 @@ updates: - package-ecosystem: "gomod" directory: "/" # Location of package manifests schedule: - interval: "monthly" + interval: "monthly" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8d2f8ccf..37c36525 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,3 @@ -# build stage -FROM golang:alpine AS build -RUN apk update && apk add git -ADD . /src -WORKDIR /src -ENV CGO_ENABLED 0 -RUN go build \ - -ldflags "-X github.com/jpillora/chisel/share.BuildVersion=$(git describe --abbrev=0 --tags)" \ - -o /tmp/bin -# run stage -FROM scratch -LABEL maintainer="dev@jpillora.com" -COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ -WORKDIR /app -COPY --from=build /tmp/bin /app/bin -ENTRYPOINT ["/app/bin"] \ No newline at end of file +FROM alpine +COPY chisel /app/ +ENTRYPOINT ["/app/chisel"] \ No newline at end of file diff --git a/go.sum b/go.sum index 679504e8..75df3b5c 100644 --- a/go.sum +++ b/go.sum @@ -16,25 +16,16 @@ github.com/jpillora/sizestr v1.0.0 h1:4tr0FLxs1Mtq3TnsLDV+GYUWG7Q26a6s+tV5Zfw2yg github.com/jpillora/sizestr v1.0.0/go.mod h1:bUhLv4ctkknatr6gR42qPxirmd5+ds1u7mzD+MZ33f0= github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce h1:fb190+cK2Xz/dvi9Hv8eCYJYvIGUTN2/KLq1pT6CjEc= github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce/go.mod h1:o8v6yHRoik09Xen7gje4m9ERNah1d1PPsVq1VEx9vE4= -golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= -golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= -golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= -golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= -golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= diff --git a/goreleaser.yml b/goreleaser.yml new file mode 100644 index 00000000..b5b9b21a --- /dev/null +++ b/goreleaser.yml @@ -0,0 +1,41 @@ +# test this goreleaser config with: +# - cd chisel +# - goreleaser --clean --snapshot --config goreleaser.yml +version: 2 +project_name: chisel +before: + hooks: + - go mod tidy + - go generate ./... +builds: + - env: + - CGO_ENABLED=0 + ldflags: + - -s -w -X github.com/outsystems/chisel/share.BuildVersion={{.Version}} + flags: + - -trimpath + goos: + - linux +dockers: + - image_templates: + - "ghcr.io/outsystems/{{ .ProjectName }}:{{ .Version }}" + - "ghcr.io/outsystems/{{ .ProjectName }}:latest" + build_flag_templates: + - --platform=linux/amd64 + - --label=org.opencontainers.image.title=OutSystems Chisel + - --label=org.opencontainers.image.description=OutSystems Chisel + - --label=org.opencontainers.image.url=https://github.com/outsystems/chisel + - --label=org.opencontainers.image.source=https://github.com/outsystems/chisel + - --label=org.opencontainers.image.version={{ .Version }} + - --label=org.opencontainers.image.created={{ .Date }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" From c67386dfae70fb2612bdbf68b3346e8c72d88a59 Mon Sep 17 00:00:00 2001 From: Henrique Santos Date: Mon, 12 Aug 2024 16:22:50 +0100 Subject: [PATCH 3/4] Revert "feat(RDGRS-662): build image (#20) (#21)" This reverts commit a0feabe11ce12bbc00cd8315eac485e6f44477a0. --- .github/{workflows => }/dependabot.yml | 2 +- .github/goreleaser.yml | 46 ++++++++++++++++++++ .github/workflows/ci.yml | 59 +++++++++++++++++++++++++- Dockerfile | 19 +++++++-- go.sum | 11 ++++- goreleaser.yml | 41 ------------------ 6 files changed, 130 insertions(+), 48 deletions(-) rename .github/{workflows => }/dependabot.yml (91%) create mode 100644 .github/goreleaser.yml delete mode 100644 goreleaser.yml diff --git a/.github/workflows/dependabot.yml b/.github/dependabot.yml similarity index 91% rename from .github/workflows/dependabot.yml rename to .github/dependabot.yml index 6067b7de..2dd92b7b 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/dependabot.yml @@ -10,4 +10,4 @@ updates: - package-ecosystem: "gomod" directory: "/" # Location of package manifests schedule: - interval: "monthly" \ No newline at end of file + interval: "monthly" diff --git a/.github/goreleaser.yml b/.github/goreleaser.yml new file mode 100644 index 00000000..d0cece00 --- /dev/null +++ b/.github/goreleaser.yml @@ -0,0 +1,46 @@ +# test this goreleaser config with: +# - cd chisel +# - goreleaser --skip-publish --rm-dist --config .github/goreleaser.yml +builds: + - env: + - CGO_ENABLED=0 + ldflags: + - -s -w -X github.com/jpillora/chisel/share.BuildVersion={{.Version}} + flags: + - -trimpath + goos: + - linux + - darwin + - windows + goarch: + - 386 + - amd64 + - arm + - arm64 + - ppc64 + - ppc64le + - mips + - mipsle + - mips64 + - mips64le + - s390x + goarm: + - 5 + - 6 + - 7 + gomips: + - hardfloat + - softfloat +archives: + - format: gz + files: + - none* +release: + draft: true + prerelease: auto +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83ecab03..b79e1621 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: go-version: [1.21.x] - platform: [ubuntu-latest] + platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: - name: Install Go @@ -23,4 +23,59 @@ jobs: - name: Build run: go build -v -o /dev/null . - name: Test - run: go test -v ./... \ No newline at end of file + run: go test -v ./... + # ================ + # RELEASE JOBS + # runs after a success test + # only runs on push "v*" tag + # ================ + release_binaries: + name: Release Binaries + needs: test + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + - name: goreleaser + if: success() + uses: docker://goreleaser/goreleaser:latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + args: release --config .github/goreleaser.yml + release_docker: + name: Release Docker Images + needs: test + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: jpillora + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Docker meta + id: docker_meta + uses: docker/metadata-action@v4 + with: + images: jpillora/chisel + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + 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 }} diff --git a/Dockerfile b/Dockerfile index 37c36525..8d2f8ccf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,16 @@ -FROM alpine -COPY chisel /app/ -ENTRYPOINT ["/app/chisel"] \ No newline at end of file +# build stage +FROM golang:alpine AS build +RUN apk update && apk add git +ADD . /src +WORKDIR /src +ENV CGO_ENABLED 0 +RUN go build \ + -ldflags "-X github.com/jpillora/chisel/share.BuildVersion=$(git describe --abbrev=0 --tags)" \ + -o /tmp/bin +# run stage +FROM scratch +LABEL maintainer="dev@jpillora.com" +COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +WORKDIR /app +COPY --from=build /tmp/bin /app/bin +ENTRYPOINT ["/app/bin"] \ No newline at end of file diff --git a/go.sum b/go.sum index 75df3b5c..679504e8 100644 --- a/go.sum +++ b/go.sum @@ -16,16 +16,25 @@ github.com/jpillora/sizestr v1.0.0 h1:4tr0FLxs1Mtq3TnsLDV+GYUWG7Q26a6s+tV5Zfw2yg github.com/jpillora/sizestr v1.0.0/go.mod h1:bUhLv4ctkknatr6gR42qPxirmd5+ds1u7mzD+MZ33f0= github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce h1:fb190+cK2Xz/dvi9Hv8eCYJYvIGUTN2/KLq1pT6CjEc= github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce/go.mod h1:o8v6yHRoik09Xen7gje4m9ERNah1d1PPsVq1VEx9vE4= +golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= -golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= diff --git a/goreleaser.yml b/goreleaser.yml deleted file mode 100644 index b5b9b21a..00000000 --- a/goreleaser.yml +++ /dev/null @@ -1,41 +0,0 @@ -# test this goreleaser config with: -# - cd chisel -# - goreleaser --clean --snapshot --config goreleaser.yml -version: 2 -project_name: chisel -before: - hooks: - - go mod tidy - - go generate ./... -builds: - - env: - - CGO_ENABLED=0 - ldflags: - - -s -w -X github.com/outsystems/chisel/share.BuildVersion={{.Version}} - flags: - - -trimpath - goos: - - linux -dockers: - - image_templates: - - "ghcr.io/outsystems/{{ .ProjectName }}:{{ .Version }}" - - "ghcr.io/outsystems/{{ .ProjectName }}:latest" - build_flag_templates: - - --platform=linux/amd64 - - --label=org.opencontainers.image.title=OutSystems Chisel - - --label=org.opencontainers.image.description=OutSystems Chisel - - --label=org.opencontainers.image.url=https://github.com/outsystems/chisel - - --label=org.opencontainers.image.source=https://github.com/outsystems/chisel - - --label=org.opencontainers.image.version={{ .Version }} - - --label=org.opencontainers.image.created={{ .Date }} - - --label=org.opencontainers.image.revision={{ .FullCommit }} -checksum: - name_template: 'checksums.txt' -snapshot: - name_template: "{{ incpatch .Version }}-next" -changelog: - sort: asc - filters: - exclude: - - "^docs:" - - "^test:" From 42125fed3dfb5dfc154b7fbacce733be20e5faef Mon Sep 17 00:00:00 2001 From: Henrique Santos Date: Tue, 13 Aug 2024 10:47:30 +0000 Subject: [PATCH 4/4] feat(RDGRS-662): add explicit timer stop --- share/tunnel/tunnel.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/share/tunnel/tunnel.go b/share/tunnel/tunnel.go index f06039b4..1d80bd5b 100644 --- a/share/tunnel/tunnel.go +++ b/share/tunnel/tunnel.go @@ -188,7 +188,7 @@ func (t *Tunnel) keepAliveLoop(sshConn ssh.Conn) { errChannel := make(chan error, 2) - time.AfterFunc(reply_timeout, func() { + timeoutTimer := time.AfterFunc(reply_timeout, func() { errChannel <- errors.New("KEEPALIVE REPLY TIMEOUT ERROR") }) @@ -207,6 +207,12 @@ func (t *Tunnel) keepAliveLoop(sshConn ssh.Conn) { err := <-errChannel + // explicitly stop the timer, as it's no longer needed at this point. + timeoutTimer.Stop() + // errChannel should be garbage collected, as it won't be in use, even on a timeout, + // as SendRequest will be unblocked on connection closure, the goroutine will send + // an error message and finish, therefore releasing the channel. + if err != nil { break }