-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (174 loc) · 5.96 KB
/
v2ray.yml
File metadata and controls
175 lines (174 loc) · 5.96 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: SSH Forward Port To Public Server
#on:
# workflow_dispatch:
# schedule:
# - cron: '*/30 * * * *'
jobs:
env:
runs-on: ubuntu-latest
steps:
- name: Set ENV
run: |
sudo apt update
sudo apt -y install sshpass
sudo passwd runner << EOD
root
root
EOD
- name: Set v2ray
run: |
mkdir v2ray
cd v2ray
wget https://github.com/v2fly/v2ray-core/releases/download/v5.0.6/v2ray-linux-64.zip
unzip v2ray-linux-64.zip
cat > config.json << EOD
{
"log": {
"loglevel": "info"
},
"inbounds": [
{
"port": 3456,
"protocol": "vmess",
"allocate": {
"strategy": "always"
},
"settings": {
"clients": [
{
"id": "26e3a620-e33e-45e6-b316-4570b0ecf39c",
"level": 1,
"alterId": 0,
"email": "client@example.com"
}
],
"disableInsecureEncryption": true
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"connectionReuse": true,
"path": "/graphql"
},
"security": "none",
"tcpSettings": {
"header": {
"type": "http",
"response": {
"version": "1.1",
"status": "200",
"reason": "OK",
"headers": {
"Content-Type": [
"application/octet-stream",
"application/x-msdownload",
"text/html",
"application/x-shockwave-flash"
],
"Transfer-Encoding": ["chunked"],
"Connection": ["keep-alive"],
"Pragma": "no-cache"
}
}
}
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
},
{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}
],
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"type": "field",
"ip": [
"0.0.0.0/8",
"10.0.0.0/8",
"100.64.0.0/10",
"127.0.0.0/8",
"169.254.0.0/16",
"172.16.0.0/12",
"192.0.0.0/24",
"192.0.2.0/24",
"192.168.0.0/16",
"198.18.0.0/15",
"198.51.100.0/24",
"203.0.113.0/24",
"::1/128",
"fc00::/7",
"fe80::/10",
"geoip:private"
],
"outboundTag": "blocked"
},
{
"type": "field",
"protocol": ["bittorrent"],
"outboundTag": "blocked"
}
]
}
}
EOD
nohup ./v2ray run > v2ray.log &
cd ~
- name: Run Caddy
run: |
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt -y install caddy
sudo mkdir /web
sudo cat > ./index.html << EOD
<div>Hello World!</div>
EOD
sudo cat > ./Caddyfile << EOD
:${{ secrets.SERVER_REMOTE_PORT }} {
log {
output stdout
}
root * /web
reverse_proxy localhost:3456
}
auto_https off
EOD
sudo cp -a ./Caddyfile /etc/caddy/Caddyfile
sudo cp -a ./index.html /web/index.html
sudo chown root:root /etc/caddy/Caddyfile
cat /etc/caddy/Caddyfile
sudo systemctl restart caddy
- name: Prepare SH
run: |
echo "#!/bin/bash" >> ready.sh
echo "echo \"http://$SERVER_IP:$SERVER_PORT\"" >> ready.sh
echo "CODE=\`curl -I -m 10 -o /dev/null -s -w '%{http_code}\\n' \"http://$SERVER_IP:$SERVER_PORT\"\`" >> ready.sh
echo "echo \"CODE: \$CODE\"" >> ready.sh
echo "while [[ \"123\$CODE\" -eq \"123404\" ]]; do" >> ready.sh
echo "CODE=\`curl -I -m 10 -o /dev/null -s -w '%{http_code}\\n' \"http://$SERVER_IP:$SERVER_PORT\"\`" >> ready.sh
echo "echo \"CODE: \$CODE\"" >> ready.sh
echo "sleep 5" >> ready.sh
echo "done" >> ready.sh
echo "echo \"ok\"" >> ready.sh
chmod +x ./ready.sh
env:
SERVER_IP: ${{ secrets.SERVER_IP }}
SERVER_PORT: ${{ secrets.SERVER_REMOTE_PORT }}
- name: wait
run: |
cat ./ready.sh
bash ./ready.sh
- name: Connect Server
run: |
sshpass -p ${{ secrets.SERVER_SSH_PASSWORD }} ssh -o "StrictHostKeyChecking no" -f -NT -p ${{ secrets.SERVER_SSH_PORT }} -R :${{ secrets.SERVER_REMOTE_PORT }}:localhost:${{ secrets.SERVER_REMOTE_PORT }} ${{ secrets.SERVER_SSH_USER }}@${{ secrets.SERVER_IP }}
sleep 1860