Skip to content

Commit 1e05934

Browse files
authored
feat(RDGRS-752): Chisel update (#25)
Version update of upstream
1 parent ff5be03 commit 1e05934

18 files changed

+197
-65
lines changed

.github/Dockerfile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# build stage
2+
FROM golang:alpine AS build
3+
RUN apk update && apk add git
4+
ADD . /src
5+
WORKDIR /src
6+
ENV CGO_ENABLED=0
7+
RUN go build \
8+
-ldflags "-X github.com/jpillora/chisel/share.BuildVersion=$(git describe --abbrev=0 --tags)" \
9+
-o /tmp/bin
10+
# run stage
11+
FROM scratch
12+
LABEL maintainer="[email protected]"
13+
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
14+
WORKDIR /app
15+
COPY --from=build /tmp/bin /app/bin
16+
ENTRYPOINT ["/app/bin"]
File renamed without changes.

.github/goreleaser.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# test this file with
2+
# goreleaser release --config goreleaser.yml --clean --snapshot
3+
version: 2
4+
builds:
5+
- env:
6+
- CGO_ENABLED=0
7+
ldflags:
8+
- -s -w -X github.com/jpillora/chisel/share.BuildVersion={{.Version}}
9+
flags:
10+
- -trimpath
11+
goos:
12+
- linux
13+
- darwin
14+
- windows
15+
- openbsd
16+
goarch:
17+
- 386
18+
- amd64
19+
- arm
20+
- arm64
21+
- ppc64
22+
- ppc64le
23+
- mips
24+
- mipsle
25+
- mips64
26+
- mips64le
27+
- s390x
28+
goarm:
29+
- 5
30+
- 6
31+
- 7
32+
gomips:
33+
- hardfloat
34+
- softfloat
35+
nfpms:
36+
- maintainer: "https://github.com/{{ .Env.GITHUB_USER }}"
37+
formats:
38+
- deb
39+
- rpm
40+
- apk
41+
archives:
42+
- format: gz
43+
files:
44+
- none*
45+
release:
46+
draft: true
47+
prerelease: auto
48+
changelog:
49+
sort: asc
50+
filters:
51+
exclude:
52+
- "^docs:"
53+
- "^test:"

.github/workflows/ci.yml

+75-11
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,90 @@
1-
on: [push, pull_request]
21
name: CI
2+
on:
3+
pull_request: {}
4+
push: {}
5+
permissions: write-all
36
jobs:
47
# ================
5-
# TEST JOB
6-
# runs on every push and PR
7-
# runs 2x3 times (see matrix)
8+
# BUILD AND TEST JOB
89
# ================
910
test:
10-
name: Test
11+
name: Build & Test
1112
strategy:
1213
matrix:
13-
go-version: [1.21.x]
14-
platform: [ubuntu-latest]
14+
# optionally test/build across multiple platforms/Go-versions
15+
go-version: ["stable"] # '1.16', '1.17', '1.18,
16+
platform: [ubuntu-latest, macos-latest, windows-latest]
1517
runs-on: ${{ matrix.platform }}
1618
steps:
17-
- name: Install Go
19+
- name: Checkout
20+
uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
23+
- name: Set up Go
1824
uses: actions/setup-go@v3
1925
with:
2026
go-version: ${{ matrix.go-version }}
21-
- name: Checkout code
22-
uses: actions/checkout@v3
27+
check-latest: true
2328
- name: Build
2429
run: go build -v -o /dev/null .
2530
- name: Test
26-
run: go test -v ./...
31+
run: go test -v ./...
32+
# ================
33+
# RELEASE BINARIES (on push "v*" tag)
34+
# ================
35+
release_binaries:
36+
name: Release Binaries
37+
needs: test
38+
if: startsWith(github.ref, 'refs/tags/v')
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Check out code
42+
uses: actions/checkout@v3
43+
- name: goreleaser
44+
if: success()
45+
uses: docker://goreleaser/goreleaser:latest
46+
env:
47+
GITHUB_USER: ${{ github.repository_owner }}
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
with:
50+
args: release --config .github/goreleaser.yml
51+
# ================
52+
# RELEASE DOCKER IMAGES (on push "v*" tag)
53+
# ================
54+
release_docker:
55+
name: Release Docker Images
56+
needs: test
57+
if: startsWith(github.ref, 'refs/tags/v')
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Check out code
61+
uses: actions/checkout@v3
62+
- name: Set up QEMU
63+
uses: docker/setup-qemu-action@v2
64+
- name: Set up Docker Buildx
65+
uses: docker/setup-buildx-action@v2
66+
- name: Login to DockerHub
67+
uses: docker/login-action@v2
68+
with:
69+
username: jpillora
70+
password: ${{ secrets.DOCKERHUB_TOKEN }}
71+
- name: Docker meta
72+
id: meta
73+
uses: docker/metadata-action@v4
74+
with:
75+
images: jpillora/chisel
76+
tags: |
77+
type=semver,pattern={{version}}
78+
type=semver,pattern={{major}}.{{minor}}
79+
type=semver,pattern={{major}}
80+
- name: Build and push
81+
uses: docker/build-push-action@v3
82+
with:
83+
context: .
84+
file: .github/Dockerfile
85+
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/386,linux/arm/v7,linux/arm/v6
86+
push: true
87+
tags: ${{ steps.meta.outputs.tags }}
88+
labels: ${{ steps.meta.outputs.labels }}
89+
cache-from: type=gha
90+
cache-to: type=gha,mode=max

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Jaime Pillora <[email protected]>
3+
Copyright (c) 2024 Jaime Pillora <[email protected]>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ Since WebSockets support is required:
422422
- `1.6` - Added client stdio support (by @BoleynSu)
423423
- `1.7` - Added UDP support
424424
- `1.8` - Move to a `scratch`Docker image
425-
- `1.9` - Switch from `--key` seed to P256 key strings with `--key{gen,file}` + bump to Go 1.21 (by @cmenginnz)
425+
- `1.9` - Bump to Go 1.21. Switch from `--key` seed to P256 key strings with `--key{gen,file}` (by @cmenginnz)
426+
- `1.10` - Bump to Go 1.22. Add `.rpm` `.deb` and `.akp` to releases. Fix bad version comparison.
426427
427428
## License
428429

client/client.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88
"encoding/base64"
99
"errors"
1010
"fmt"
11-
"io/ioutil"
1211
"net"
1312
"net/http"
1413
"net/url"
14+
"os"
1515
"regexp"
1616
"strings"
1717
"time"
@@ -118,7 +118,7 @@ func NewClient(c *Config) (*Client, error) {
118118
tc.InsecureSkipVerify = true
119119
} else if c.TLS.CA != "" {
120120
rootCAs := x509.NewCertPool()
121-
if b, err := ioutil.ReadFile(c.TLS.CA); err != nil {
121+
if b, err := os.ReadFile(c.TLS.CA); err != nil {
122122
return nil, fmt.Errorf("Failed to load file: %s", c.TLS.CA)
123123
} else if ok := rootCAs.AppendCertsFromPEM(b); !ok {
124124
return nil, fmt.Errorf("Failed to decode PEM: %s", c.TLS.CA)

go.mod

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ require (
99
github.com/jpillora/backoff v1.0.0
1010
github.com/jpillora/requestlog v1.0.0
1111
github.com/jpillora/sizestr v1.0.0
12-
golang.org/x/crypto v0.13.0
13-
golang.org/x/net v0.15.0
14-
golang.org/x/sync v0.3.0
12+
golang.org/x/crypto v0.16.0
13+
golang.org/x/net v0.14.0
14+
golang.org/x/sync v0.5.0
1515
)
1616

1717
require (
1818
github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2 // indirect
1919
github.com/jpillora/ansi v1.0.3 // indirect
2020
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce // indirect
21-
golang.org/x/sys v0.12.0 // indirect
22-
golang.org/x/text v0.13.0 // indirect
21+
golang.org/x/sys v0.15.0 // indirect
22+
golang.org/x/text v0.14.0 // indirect
2323
)
2424

25-
replace github.com/jpillora/chisel => ../chisel
25+
replace github.com/jpillora/chisel => ../chisel

go.sum

+12-12
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ github.com/jpillora/sizestr v1.0.0 h1:4tr0FLxs1Mtq3TnsLDV+GYUWG7Q26a6s+tV5Zfw2yg
1616
github.com/jpillora/sizestr v1.0.0/go.mod h1:bUhLv4ctkknatr6gR42qPxirmd5+ds1u7mzD+MZ33f0=
1717
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce h1:fb190+cK2Xz/dvi9Hv8eCYJYvIGUTN2/KLq1pT6CjEc=
1818
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce/go.mod h1:o8v6yHRoik09Xen7gje4m9ERNah1d1PPsVq1VEx9vE4=
19-
golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
20-
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
21-
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
22-
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
23-
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
24-
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
19+
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
20+
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
21+
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
22+
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
23+
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
24+
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
2525
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
26-
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
27-
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
28-
golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU=
29-
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
30-
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
31-
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
26+
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
27+
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
28+
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
29+
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
30+
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
31+
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=

main.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package main
33
import (
44
"flag"
55
"fmt"
6-
"io/ioutil"
76
"log"
87
"net/http"
98
"os"
@@ -89,7 +88,7 @@ var commonHelp = `
8988

9089
func generatePidFile() {
9190
pid := []byte(strconv.Itoa(os.Getpid()))
92-
if err := ioutil.WriteFile("chisel.pid", pid, 0644); err != nil {
91+
if err := os.WriteFile("chisel.pid", pid, 0644); err != nil {
9392
log.Fatal(err)
9493
}
9594
}
@@ -241,6 +240,9 @@ func server(args []string) {
241240
} else if config.KeySeed == "" {
242241
config.KeySeed = settings.Env("KEY")
243242
}
243+
if config.Auth == "" {
244+
config.Auth = os.Getenv("AUTH")
245+
}
244246
s, err := chserver.NewServer(config)
245247
if err != nil {
246248
log.Fatal(err)

server/server_handler.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func (s *Server) handleClientHandler(w http.ResponseWriter, r *http.Request) {
1919
//websockets upgrade AND has chisel prefix
2020
upgrade := strings.ToLower(r.Header.Get("Upgrade"))
2121
protocol := r.Header.Get("Sec-WebSocket-Protocol")
22-
if upgrade == "websocket" {
22+
if upgrade == "websocket" {
2323
if protocol == chshare.ProtocolVersion {
2424
s.handleWebsocket(w, r)
2525
return
@@ -101,13 +101,13 @@ func (s *Server) handleWebsocket(w http.ResponseWriter, req *http.Request) {
101101
return
102102
}
103103
//print if client and server versions dont match
104-
if c.Version != chshare.BuildVersion {
105-
v := c.Version
106-
if v == "" {
107-
v = "<unknown>"
108-
}
109-
l.Infof("Client version (%s) differs from server version (%s)",
110-
v, chshare.BuildVersion)
104+
cv := strings.TrimPrefix(c.Version, "v")
105+
if cv == "" {
106+
cv = "<unknown>"
107+
}
108+
sv := strings.TrimPrefix(chshare.BuildVersion, "v")
109+
if cv != sv {
110+
l.Infof("Client version (%s) differs from server version (%s)", cv, sv)
111111
}
112112
//validate remotes
113113
for _, r := range c.Remotes {

server/server_listen.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"crypto/tls"
55
"crypto/x509"
66
"errors"
7-
"io/ioutil"
87
"net"
98
"os"
109
"os/user"
@@ -116,7 +115,7 @@ func addCA(ca string, c *tls.Config) error {
116115
clientCAPool := x509.NewCertPool()
117116
if fileInfo.IsDir() {
118117
//this is a directory holding CA bundle files
119-
files, err := ioutil.ReadDir(ca)
118+
files, err := os.ReadDir(ca)
120119
if err != nil {
121120
return err
122121
}
@@ -140,7 +139,7 @@ func addCA(ca string, c *tls.Config) error {
140139
}
141140

142141
func addPEMFile(path string, pool *x509.CertPool) error {
143-
content, err := ioutil.ReadFile(path)
142+
content, err := os.ReadFile(path)
144143
if err != nil {
145144
return err
146145
}

share/cio/stdio.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package cio
22

33
import (
44
"io"
5-
"io/ioutil"
65
"os"
76
)
87

@@ -11,6 +10,6 @@ var Stdio = &struct {
1110
io.ReadCloser
1211
io.Writer
1312
}{
14-
ioutil.NopCloser(os.Stdin),
13+
io.NopCloser(os.Stdin),
1514
os.Stdout,
1615
}

share/settings/users.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"encoding/json"
55
"errors"
66
"fmt"
7-
"io/ioutil"
7+
"os"
88
"regexp"
99
"sync"
1010

@@ -125,7 +125,7 @@ func (u *UserIndex) loadUserIndex() error {
125125
if u.configFile == "" {
126126
return errors.New("configuration file not set")
127127
}
128-
b, err := ioutil.ReadFile(u.configFile)
128+
b, err := os.ReadFile(u.configFile)
129129
if err != nil {
130130
return fmt.Errorf("Failed to read auth file: %s, error: %s", u.configFile, err)
131131
}

0 commit comments

Comments
 (0)