From d0d4feb1b63cc51aeb7be618330a25268bf0fa8f Mon Sep 17 00:00:00 2001 From: Michael Salaverry Date: Mon, 10 Jun 2024 22:34:30 +0300 Subject: [PATCH 1/6] Create makefile.yml --- .github/workflows/makefile.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/makefile.yml diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml new file mode 100644 index 0000000..5281623 --- /dev/null +++ b/.github/workflows/makefile.yml @@ -0,0 +1,18 @@ +name: Makefile CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: make binary + run: make websocketd From 56c69b732fabc41142cf8f101a89d921b2fc7494 Mon Sep 17 00:00:00 2001 From: Alex Sergeyev Date: Fri, 4 Nov 2022 08:30:56 -0400 Subject: [PATCH 2/6] Small fix to prevent panic when --address not provided with --ssl and --port (#431) kudos to Michail Kovtun for reporting it --- main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index ec09496..636bec0 100644 --- a/main.go +++ b/main.go @@ -94,13 +94,16 @@ func main() { pos := strings.IndexByte(addr, ':') rediraddr := addr[:pos] + ":" + strconv.Itoa(config.RedirPort) // it would be silly to optimize this one redir := &http.Server{Addr: rediraddr, Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - // redirect to same hostname as in request but different port and probably schema uri := "https://" if !config.Ssl { uri = "http://" } - uri += r.Host[:strings.IndexByte(r.Host, ':')] + addr[pos:] + "/" + if cpos := strings.IndexByte(r.Host, ':'); cpos > 0 { + uri += r.Host[:strings.IndexByte(r.Host, ':')] + addr[pos:] + "/" + } else { + uri += r.Host + addr[pos:] + "/" + } http.Redirect(w, r, uri, http.StatusMovedPermanently) })} From 7056997b684976b1ebb797bb68af074cea174624 Mon Sep 17 00:00:00 2001 From: King Louie <5188799+saturn99@users.noreply.github.com> Date: Sat, 4 Feb 2023 08:14:49 +0330 Subject: [PATCH 3/6] fix show help message Convert flag.Usage to flag.CommandLine.Usage for avoid showing the default help message printout --- config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.go b/config.go index e6750ad..6f8ed0a 100644 --- a/config.go +++ b/config.go @@ -54,8 +54,8 @@ func parseCommandLine() *Config { var mainConfig Config var config libwebsocketd.Config - flag.Usage = func() {} flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ContinueOnError) + flag.CommandLine.Usage = func() {} // If adding new command line options, also update the help text in help.go. // The flag library's auto-generate help message isn't pretty enough. From 093246b544e71f8b70ed8daf514d1490e4142c80 Mon Sep 17 00:00:00 2001 From: 645775992 <645775992@qq.com> Date: Fri, 4 Nov 2022 16:45:34 +0800 Subject: [PATCH 4/6] update github.com/gorilla/websocket v1.4.0 to 1.4.1 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index e40afd2..77c14c0 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module github.com/joewalnes/websocketd go 1.15 -require github.com/gorilla/websocket v1.4.0 +require github.com/gorilla/websocket v1.4.1 diff --git a/go.sum b/go.sum index cf4fbba..5f04ea2 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,4 @@ github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= +github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= From e0b24b44db4a6d66296b7905415bf5bbea563b6f Mon Sep 17 00:00:00 2001 From: Michael Salaverry Date: Mon, 10 Jun 2024 19:16:58 +0000 Subject: [PATCH 5/6] update gorilla websocket to 1.5.2 update go version to 1.22.3 --- Makefile | 2 +- go.mod | 6 ++++-- go.sum | 4 ++++ release/Makefile | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 47f9ee9..f760427 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ # To manually invoke the locally installed Go, use ./go # Go installation config. -GO_VER=1.11.5 +GO_VER=1.22.3 SYSTEM_NAME:=$(shell uname -s | tr '[:upper:]' '[:lower:]') SYSTEM_ARCH:=$(shell uname -m) GO_ARCH:=$(if $(filter x86_64, $(SYSTEM_ARCH)),amd64,386) diff --git a/go.mod b/go.mod index 77c14c0..c3592de 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,7 @@ module github.com/joewalnes/websocketd -go 1.15 +go 1.22.3 -require github.com/gorilla/websocket v1.4.1 +require github.com/gorilla/websocket v1.5.2 + +require golang.org/x/net v0.23.0 // indirect diff --git a/go.sum b/go.sum index 5f04ea2..7a88eee 100644 --- a/go.sum +++ b/go.sum @@ -2,3 +2,7 @@ github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.2 h1:qoW6V1GT3aZxybsbC6oLnailWnB+qTMVwMreOso9XUw= +github.com/gorilla/websocket v1.5.2/go.mod h1:0n9H61RBAcf5/38py2MCYbxzPIY9rOkpvvMT24Rqs30= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= diff --git a/release/Makefile b/release/Makefile index eb6feee..6049f6b 100644 --- a/release/Makefile +++ b/release/Makefile @@ -21,7 +21,7 @@ LAST_PATCH_VERSION:=$(shell git ls-remote git@github.com:joewalnes/websocketd.gi VERSION_PATCH:=$(or $(LAST_PATCH_VERSION),0) RELEASE_VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH) -GO_VERSION=1.15.7 +GO_VERSION=1.22.3 PLATFORMS=linux_amd64 linux_386 linux_arm linux_arm64 darwin_amd64 freebsd_amd64 freebsd_386 windows_386 windows_amd64 openbsd_386 openbsd_amd64 solaris_amd64 From 92ff58428866fb8161681b0ced1d62e226e8825f Mon Sep 17 00:00:00 2001 From: Michael Salaverry Date: Mon, 10 Jun 2024 20:52:50 +0000 Subject: [PATCH 6/6] test: add test and build caching fix: nektos/act isn't the same as the runner fix: another try fix: fix: fix: fix: fix: fix: fix: fix: --- .github/workflows/makefile.yml | 43 +++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index 5281623..66ad7bd 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -1,4 +1,4 @@ -name: Makefile CI +name: build and test on: push: @@ -14,5 +14,42 @@ jobs: steps: - uses: actions/checkout@v4 - - name: make binary - run: make websocketd + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + # - name: build using makefile + # run: make websocketd + + - name: build websocketd + run: go build + + - name: Archive build artifacts + uses: actions/upload-artifact@v4 + with: + name: websocketd + path: | + websocketd + ./examples/bash/dump-env.sh + + + test: + needs: build + runs-on: ubuntu-latest + + steps: + - name: Download built websocketd + uses: actions/download-artifact@v4 + with: + name: websocketd + + - name: fix permissions + run: chmod +x ./websocketd && chmod +x ./examples/bash/dump-env.sh + + - name: setup client + run: wget https://github.com/vi/websocat/releases/latest/download/websocat.x86_64-unknown-linux-musl && chmod +x websocat.x86_64-unknown-linux-musl + + - name: test + run: | + ./websocketd --port=8080 ./examples/bash/dump-env.sh & + ./websocat.x86_64-unknown-linux-musl -E ws://$(hostname):8080