igor04091968 commited on
Commit
ff3ec48
·
verified ·
1 Parent(s): a5e200d

Create warp_proxy.sh

Browse files
Files changed (1) hide show
  1. warp_proxy.sh +58 -0
warp_proxy.sh ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Based on the entrypoint from Mon-ius/Docker-Warp-Socks v5
3
+
4
+ set -e
5
+ sleep 3
6
+
7
+ # Get WARP configuration
8
+ RESPONSE=$(curl -fsSL bit.ly/create-cloudflare-warp | sh -s)
9
+
10
+ # Extract variables
11
+ CF_CLIENT_ID=$(echo "$RESPONSE" | grep -oP '(?<=CLIENT_ID = ).*$')
12
+ CF_PRIVATE_KEY=$(echo "$RESPONSE" | grep -oP '(?<=PRIVATE_KEY = ).*$')
13
+ CF_ADDR_V4=$(echo "$RESPONSE" | grep -oP '(?<=V4 = ).*$')
14
+ CF_ADDR_V6=$(echo "$RESPONSE" | grep -oP '(?<=V6 = ).*$')
15
+
16
+ # Generate sing-box config
17
+ cat > /tmp/sing-box-config.json <<EOF
18
+ {
19
+ "log": {
20
+ "level": "info",
21
+ "timestamp": true
22
+ },
23
+ "inbounds": [
24
+ {
25
+ "type": "socks",
26
+ "tag": "socks-in",
27
+ "listen": "0.0.0.0",
28
+ "listen_port": 1080
29
+ }
30
+ ],
31
+ "outbounds": [
32
+ {
33
+ "type": "wireguard",
34
+ "tag": "warp-out",
35
+ "server": "engage.cloudflareclient.com",
36
+ "server_port": 2408,
37
+ "local_address": [
38
+ "${CF_ADDR_V4}/32",
39
+ "${CF_ADDR_V6}/128"
40
+ ],
41
+ "private_key": "${CF_PRIVATE_KEY}",
42
+ "peer_public_key": "bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=",
43
+ "reserved": [${reserved_bytes}],
44
+ "mtu": 1280
45
+ }
46
+ ]
47
+ }
48
+ EOF
49
+
50
+ # Replace reserved_bytes placeholder
51
+ # od -An -t u1 formats the bytes as unsigned decimal integers
52
+ reserved_bytes=$(echo "$CF_CLIENT_ID" | base64 -d | od -An -t u1 | awk
53
+ '{print $1", "$2", "$3}')
54
+ sed -i "s/\[${reserved_bytes}\]/\[${reserved_bytes}\]/" /tmp/sing-box-config.json
55
+
56
+
57
+ echo "Starting sing-box WARP proxy..."
58
+ exec /usr/local/bin/sing-box run -c /tmp/sing-box-config.json