Skip to content

Commit 64aa913

Browse files
committed
ci: add workflow
1 parent 51e7342 commit 64aa913

14 files changed

Lines changed: 2146 additions & 57 deletions

File tree

.github/Dockerfile_TUIC

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM alpine:latest
2+
3+
# Accept binary names and binary dir via build-args passed by reusable workflow
4+
ARG BINARY_DIR=./docker-bins
5+
ARG SERVER_BINARY_AMD64=tuic-server-x86_64-linux-musl
6+
ARG SERVER_BINARY_ARM64=tuic-server-aarch64-linux-musl
7+
ARG TARGETARCH
8+
9+
# Select correct binary based on TARGETARCH using BuildKit bind mount (no layer created)
10+
RUN --mount=type=bind,source=${BINARY_DIR},target=/tmp/binaries \
11+
if [ "${TARGETARCH}" = "amd64" ]; then \
12+
cp /tmp/binaries/${SERVER_BINARY_AMD64} /usr/bin/tuic-server; \
13+
elif [ "${TARGETARCH}" = "arm64" ]; then \
14+
cp /tmp/binaries/${SERVER_BINARY_ARM64} /usr/bin/tuic-server; \
15+
else \
16+
echo "Unsupported TARGETARCH: ${TARGETARCH}"; exit 1; \
17+
fi && \
18+
chmod +x /usr/bin/tuic-server
19+
20+
# Setup environment
21+
RUN mkdir -p /etc/tuic
22+
23+
WORKDIR /root
24+
ENV IN_DOCKER=true
25+
26+
ENTRYPOINT [ "/usr/bin/tuic-server" ]
27+
CMD [ "-d", "/etc/tuic" ]

.github/workflows/ci.yml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,14 @@ env:
2020
RUST_LOG: "wind=TRACE"
2121
RUST_TOOLCHAIN: "stable"
2222
RUSTC_BOOTSTRAP: "1"
23-
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
2423

2524
jobs:
2625
build:
2726
name: Build
28-
uses: rust-proxy/workflows/.github/workflows/rust-build.yml@v1.0.10
29-
secrets:
30-
sentry-dsn: ${{ secrets.SENTRY_DSN }}
27+
uses: rust-proxy/workflows/.github/workflows/rust-build.yml@v1.0.12
3128
with:
3229
rust-toolchain: "stable"
33-
packages: "wind"
30+
packages: "wind,tuic-server,tuic-client"
3431
target-config-file: ".github/target.toml"
3532
rustflags: ""
3633
enable-tmate: false
@@ -40,21 +37,37 @@ jobs:
4037
name: Release
4138
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')))
4239
needs: [build]
43-
uses: rust-proxy/workflows/.github/workflows/release-publish.yml@v1.0.10
40+
uses: rust-proxy/workflows/.github/workflows/release-publish.yml@v1.0.12
4441
with:
4542
cliff-config: '.github/cliff.toml'
43+
create-latest-on-push: true
44+
45+
docker_tuic:
46+
name: Docker of TUIC
47+
needs: [build]
48+
uses: rust-proxy/workflows/.github/workflows/docker-publish.yml@main
49+
# secrets:
50+
# registrys: |
51+
# ${{ secrets.DOCKERHUB_USERNAME }}:$${{ secrets.DOCKERHUB_TOKEN }}@docker.io
52+
with:
53+
docker-file: '.github/Dockerfile_TUIC'
54+
image-name: 'tuic-server'
55+
platforms: 'linux/amd64,linux/arm64'
56+
binary-dir: './docker-bins'
57+
server-binary-amd64: 'tuic-server-x86_64-linux-musl'
58+
server-binary-arm64: 'tuic-server-aarch64-linux-musl'
4659

4760
docker:
4861
name: Docker
4962
needs: [build]
50-
uses: rust-proxy/workflows/.github/workflows/docker-publish.yml@v1.0.10
51-
secrets:
52-
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
53-
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
63+
uses: rust-proxy/workflows/.github/workflows/docker-publish.yml@main
64+
# secrets:
65+
# registrys: |
66+
# ${{ secrets.DOCKERHUB_USERNAME }}:$${{ secrets.DOCKERHUB_TOKEN }}@docker.io
5467
with:
5568
docker-file: '.github/Dockerfile'
5669
image-name: 'wind'
5770
platforms: 'linux/amd64,linux/arm64'
5871
binary-dir: './docker-bins'
5972
server-binary-amd64: 'wind-x86_64-linux-musl'
60-
server-binary-arm64: 'wind-aarch64-linux-musl'
73+
server-binary-arm64: 'wind-aarch64-linux-musl'

Cargo.lock

Lines changed: 38 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,17 @@ license = "MIT OR Apache-2.0"
2020
quinn = { branch = "bbrv3", git = "https://github.com/Tipuch/quinn.git", default-features = false }
2121
quinn-proto = { branch = "bbrv3", git = "https://github.com/Tipuch/quinn.git", default-features = false }
2222
quinn-congestions = { git = "https://github.com/proxy-rs/quinn-congestions.git", default-features = false }
23+
24+
# Patch datagram-socket to fix build failure on musl targets with libc >= 0.2.169.
25+
# libc::msghdr gained private padding fields (__pad1, __pad2) that prevent
26+
# struct literal construction. Fix from: https://github.com/cloudflare/quiche/pull/2224
27+
# [patch.crates-io]
28+
# datagram-socket = { path = "patches/datagram-socket" }
29+
30+
[profile.release]
31+
opt-level = "z"
32+
debug = 1
33+
lto = "fat"
34+
strip = true
35+
incremental = false
36+
codegen-units = 1

Cross.toml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1+
[build.env]
2+
passthrough = ["RUSTFLAGS", "RUSTC_BOOTSTRAP"]
3+
4+
15
# Use clang as the C/C++ compiler to avoid the aws-lc-sys GCC memcmp bug
26
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189
37
# The custom Dockerfile installs clang/llvm and sets CC=clang, CXX=clang++, AR=llvm-ar
4-
58
[build.dockerfile]
6-
file = ".cross/Dockerfile"
7-
8-
[build.env]
9-
passthrough = ["RUSTFLAGS", "RUST_LOG", "RUSTC_BOOTSTRAP"]
10-
11-
[target.mips-unknown-linux-musl]
12-
image = "ghcr.io/cross-rs/mips-unknown-linux-musl:edge"
13-
14-
[target.mipsel-unknown-linux-musl]
15-
image = "ghcr.io/cross-rs/mipsel-unknown-linux-musl:edge"
9+
file = ".cross/Dockerfile"

crates/tuic-server/src/wind_adapter.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,19 @@ impl OutboundAction for TuicOutboundHandler {
168168
.as_deref()
169169
.ok_or_else(|| eyre::eyre!("socks5 outbound missing 'addr'"))?;
170170

171-
let socks_stream = connect_socks5_tcp(socks_addr, &target, &self.rule).await?;
172-
tokio::io::copy_bidirectional(&mut stream, &mut { socks_stream }).await?;
171+
let mut socks_stream = connect_socks5_tcp(socks_addr, &target, &self.rule).await?;
172+
if let Err(e) = tokio::io::copy_bidirectional(&mut stream, &mut socks_stream).await {
173+
tracing::debug!("socks5 copy_bidirectional ended: {}", e);
174+
}
173175
}
174176
_ => {
175177
// "direct" and anything else treated as direct
176178
let ip_mode = self.rule.ip_mode.unwrap_or(StackPrefer::V4first);
177179
let target_sa = resolve_target(&target, ip_mode).await?;
178180
let mut target_stream = connect_direct_tcp(target_sa, &self.rule).await?;
179-
tokio::io::copy_bidirectional(&mut stream, &mut target_stream).await?;
181+
if let Err(e) = tokio::io::copy_bidirectional(&mut stream, &mut target_stream).await {
182+
tracing::debug!("direct copy_bidirectional ended: {}", e);
183+
}
180184
}
181185
}
182186

0 commit comments

Comments
 (0)