-
Notifications
You must be signed in to change notification settings - Fork 2
/
gen_proxy_64.sh
73 lines (59 loc) · 1.5 KB
/
gen_proxy_64.sh
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
#!/bin/sh
random() {
tr </dev/urandom -dc A-Za-z0-9 | head -c5
echo
}
array=(1 2 3 4 5 6 7 8 9 0 a b c d e f)
main_interface=$(ip route get 8.8.8.8 | awk -- '{printf $5}')
gen64() {
ip64() {
echo "${array[$RANDOM % 16]}${array[$RANDOM % 16]}${array[$RANDOM % 16]}${array[$RANDOM % 16]}"
}
echo "$1:$(ip64):$(ip64):$(ip64):$(ip64)"
}
gen_data() {
seq $FIRST_PORT $LAST_PORT | while read port; do
echo "$IP4/$port/$(gen64 $IP6)"
done
}
gen_iptables() {
cat <<EOF
$(awk -F "/" '{print "iptables -I INPUT -p tcp --dport " $2 " -m state --state NEW -j ACCEPT"}' ${WORKDATA})
EOF
}
gen_ifconfig() {
cat <<EOF
$(awk -F "/" '{print "ifconfig '$main_interface' inet6 add " $3 "/64"}' ${WORKDATA})
EOF
}
gen_3proxy() {
cat <<EOF
daemon
maxconn 2000
nserver 1.1.1.1
nserver 8.8.4.4
nserver 2001:4860:4860::8888
nserver 2001:4860:4860::8844
nscache 65536
timeouts 1 5 30 60 180 1800 15 60
setgid 65535
setuid 65535
stacksize 6291456
auth strong
users usrproxy:CL:passwdproxy
$(awk -F "/" '{print "auth strong\n" \
"proxy -6 -n -a -p" $2 " -i" $1 " -e"$3"\n" \
"flush\n"}' ${WORKDATA})
EOF
}
WORKDIR="/home/proxy-installer"
WORKDATA="${WORKDIR}/data.txt"
IP4=$(curl -4 -s icanhazip.com)
IP6=$(hostname -I | awk ' {print $2}' | cut -f1-4 -d':')
echo "Internal ip = ${IP4}. Exteranl sub for ip6 = ${IP6}"
FIRST_PORT=10000
LAST_PORT=13000
gen_data >$WORKDIR/data.txt
gen_iptables >$WORKDIR/boot_iptables.sh
gen_ifconfig >$WORKDIR/boot_ifconfig.sh
gen_3proxy >/usr/local/etc/3proxy/3proxy.cfg