Skip to content

Commit b5fa2ae

Browse files
authored
Merge pull request #1 from zijiren233/main
feat: init
2 parents e2ed04e + 6047acb commit b5fa2ae

File tree

17 files changed

+801
-1
lines changed

17 files changed

+801
-1
lines changed

Diff for: .github/workflows/build.yml

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository }}
12+
13+
jobs:
14+
build-client:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
targets:
19+
- OS: darwin
20+
ARCH: amd64
21+
EXT: ""
22+
- OS: darwin
23+
ARCH: arm64
24+
EXT: ""
25+
- OS: windows
26+
ARCH: amd64
27+
EXT: .exe
28+
- OS: windows
29+
ARCH: arm64
30+
EXT: .exe
31+
- OS: linux
32+
ARCH: amd64
33+
EXT: ""
34+
- OS: linux
35+
ARCH: arm64
36+
EXT: ""
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Set up Go
42+
uses: actions/setup-go@v5
43+
with:
44+
go-version: 1.23
45+
46+
- name: Go Build
47+
run: |
48+
export CGO_ENABLED=0
49+
export GOOS=${{ matrix.targets.OS }}
50+
export GOARCH=${{ matrix.targets.ARCH }}
51+
mkdir -p dist
52+
go build \
53+
-trimpath \
54+
-ldflags="-s -w" \
55+
-o dist/wst-${{ matrix.targets.OS }}-${{ matrix.targets.ARCH }}${{ matrix.targets.EXT }} \
56+
./client
57+
58+
- name: Release
59+
uses: softprops/action-gh-release@v2
60+
with:
61+
token: ${{ secrets.GITHUB_TOKEN }}
62+
draft: false
63+
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }}
64+
append_body: false
65+
fail_on_unmatched_files: true
66+
name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'Dev Build' }}
67+
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'dev' }}
68+
files: |
69+
dist/*
70+
71+
build-server:
72+
runs-on: ubuntu-latest
73+
74+
steps:
75+
- uses: actions/checkout@v4
76+
77+
- name: Set up QEMU
78+
uses: docker/setup-qemu-action@v3
79+
80+
- name: Set up Docker Buildx
81+
uses: docker/setup-buildx-action@v3
82+
83+
- name: Log in to the Container registry
84+
uses: docker/login-action@v1
85+
with:
86+
registry: ${{ env.REGISTRY }}
87+
username: ${{ github.actor }}
88+
password: ${{ secrets.GITHUB_TOKEN }}
89+
90+
- name: Extract metadata (tags, labels) for Docker
91+
id: meta
92+
uses: docker/metadata-action@v3
93+
with:
94+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
95+
96+
- name: Build and push
97+
id: docker_build
98+
uses: docker/build-push-action@v5
99+
with:
100+
context: server
101+
push: true
102+
platforms: linux/amd64,linux/arm64
103+
tags: ${{ steps.meta.outputs.tags }}
104+
labels: ${{ steps.meta.outputs.labels }}
105+
106+
- name: Image digest
107+
run: echo ${{ steps.docker_build.outputs.digest }}

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
wst
2+
**/*.local

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Devbox Websocket Tunnel
1+
# Devbox Websocket Tunnel

Diff for: client/go.mod

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/labring/devbox-websocket-tunnel/client
2+
3+
go 1.23.4
4+
5+
require golang.org/x/net v0.32.0

Diff for: client/go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
2+
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=

Diff for: client/main.go

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"io"
6+
"net/url"
7+
"os"
8+
)
9+
10+
var target string
11+
12+
func init() {
13+
flag.StringVar(&target, "target", "ws://127.0.0.1:8081/ws", "target url")
14+
}
15+
16+
func main() {
17+
flag.Parse()
18+
19+
u, err := url.Parse(target)
20+
if err != nil {
21+
panic(err)
22+
}
23+
conn, err := NewDialer(
24+
WithURL(u),
25+
).Dial()
26+
if err != nil {
27+
panic(err)
28+
}
29+
go func() {
30+
_, _ = io.Copy(os.Stdout, conn)
31+
}()
32+
_, _ = io.Copy(conn, os.Stdin)
33+
}

0 commit comments

Comments
 (0)