-
-
Notifications
You must be signed in to change notification settings - Fork 467
101 lines (89 loc) · 2.58 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Test
concurrency:
group: test-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- 'main'
pull_request:
jobs:
build-test:
name: Build Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
check-latest: true
go-version-file: 'go.mod'
- name: Cache go module
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run test
run: |
go test ./...
docker-test:
name: Docker Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
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
with:
version: latest
# - name: Build image
# uses: docker/build-push-action@v6
# with:
# context: .
# file: Dockerfile.test
# platforms: linux/amd64
# tags: tun2socks:test
- name: Set up env
env:
DEBIAN_FRONTEND: noninteractive
CONTAINER: t2s
DNS: 1.1.1.1
TUN: tun0
ADDR: 198.18.0.1/15
PROXY: direct://
IFACE: eth0
run: |
docker run --rm -d --privileged \
-v $PWD:/src \
--dns $DNS \
--name $CONTAINER golang:bullseye \
bash -c \
"set -x;
cd /src;
apt update && apt install -y iputils-ping net-tools iptables \
iproute2 netcat curl dnsutils iperf3 tcpdump git make gcc;
make tun2socks && mv /src/build/tun2socks /usr/bin/tun2socks;
ip tuntap add mode tun dev $TUN;
ip addr add $ADDR dev $TUN;
ip link set dev $TUN up;
sysctl net.ipv4.conf.all.rp_filter=0;
sysctl net.ipv4.conf.default.rp_filter=0;
sysctl net.ipv4.conf.eth0.rp_filter=0;
sysctl net.ipv4.conf.$TUN.rp_filter=0;
ip route add 0.0.0.0/1 dev $TUN
ip route add 128.0.0.0/1 dev $TUN
exec tun2socks --device $TUN --proxy $PROXY --interface $IFACE"
- name: Run tests
env:
CONTAINER: t2s
run: |
docker exec -it $CONTAINER bash -c "curl -v 223.5.5.5"