-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from zijiren233/main
feat: init
- Loading branch information
Showing
17 changed files
with
801 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
workflow_dispatch: | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-client: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
targets: | ||
- OS: darwin | ||
ARCH: amd64 | ||
EXT: "" | ||
- OS: darwin | ||
ARCH: arm64 | ||
EXT: "" | ||
- OS: windows | ||
ARCH: amd64 | ||
EXT: .exe | ||
- OS: windows | ||
ARCH: arm64 | ||
EXT: .exe | ||
- OS: linux | ||
ARCH: amd64 | ||
EXT: "" | ||
- OS: linux | ||
ARCH: arm64 | ||
EXT: "" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.23 | ||
|
||
- name: Go Build | ||
run: | | ||
export CGO_ENABLED=0 | ||
export GOOS=${{ matrix.targets.OS }} | ||
export GOARCH=${{ matrix.targets.ARCH }} | ||
mkdir -p dist | ||
go build \ | ||
-trimpath \ | ||
-ldflags="-s -w" \ | ||
-o dist/wst-${{ matrix.targets.OS }}-${{ matrix.targets.ARCH }}${{ matrix.targets.EXT }} \ | ||
./client | ||
- name: Release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
draft: false | ||
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }} | ||
append_body: false | ||
fail_on_unmatched_files: true | ||
name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'Dev Build' }} | ||
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'dev' }} | ||
files: | | ||
dist/* | ||
build-server: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: server | ||
push: true | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
- name: Image digest | ||
run: echo ${{ steps.docker_build.outputs.digest }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
wst | ||
**/*.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# Devbox Websocket Tunnel | ||
# Devbox Websocket Tunnel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/labring/devbox-websocket-tunnel/client | ||
|
||
go 1.23.4 | ||
|
||
require golang.org/x/net v0.32.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= | ||
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"io" | ||
"net/url" | ||
"os" | ||
) | ||
|
||
var target string | ||
|
||
func init() { | ||
flag.StringVar(&target, "target", "ws://127.0.0.1:8081/ws", "target url") | ||
} | ||
|
||
func main() { | ||
flag.Parse() | ||
|
||
u, err := url.Parse(target) | ||
if err != nil { | ||
panic(err) | ||
} | ||
conn, err := NewDialer( | ||
WithURL(u), | ||
).Dial() | ||
if err != nil { | ||
panic(err) | ||
} | ||
go func() { | ||
_, _ = io.Copy(os.Stdout, conn) | ||
}() | ||
_, _ = io.Copy(conn, os.Stdin) | ||
} |
Oops, something went wrong.