Skip to content

Commit

Permalink
Merge pull request #1 from zijiren233/main
Browse files Browse the repository at this point in the history
feat: init
  • Loading branch information
zzjin authored Dec 11, 2024
2 parents e2ed04e + 6047acb commit b5fa2ae
Show file tree
Hide file tree
Showing 17 changed files with 801 additions and 1 deletion.
107 changes: 107 additions & 0 deletions .github/workflows/build.yml
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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
wst
**/*.local
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Devbox Websocket Tunnel
# Devbox Websocket Tunnel
5 changes: 5 additions & 0 deletions client/go.mod
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
2 changes: 2 additions & 0 deletions client/go.sum
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=
33 changes: 33 additions & 0 deletions client/main.go
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)
}
Loading

0 comments on commit b5fa2ae

Please sign in to comment.