forked from suhailsherif/IITG-Transparent-Proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·122 lines (105 loc) · 2.46 KB
/
start.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
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
#!/bin/bash
# force bash
[ -z $BASH ] && { exec bash "$0" "$@" || exit; }
source /etc/allproxy/config
source $allproxy_path/config/config.sh
case $1 in
tproxy)
$allproxy_path/tproxy/start.sh &
;;
vproxy)
$allproxy_path/vproxy/start.sh &
;;
lproxy)
$allproxy_path/lproxy/start.sh &
;;
sproxy)
$allproxy_path/sproxy/start.sh &
;;
dproxy)
$allproxy_path/dproxy/start.sh $2 $3 &
;;
cproxy)
$allproxy_path/cproxy/start.sh &
;;
*)
echo "Stopping process if already running ..."
. $allproxy_path/stop.sh > $allproxy_path/log/stop.log
echo "Checking connectivity to default Gateway ..."
def_gateway=$(/sbin/ip route | awk '/default/ { print $3 }')
if [[ ! $def_gateway =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]
then
echo "default gateway not set"
read -p "Proxy Gateway ? : " def_gateway
if [[ $proxy_gateway =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]
then
ping -W 1 -c 2 $proxy_gateway >/dev/null
ping -W 1 -c 2 $proxy_gateway >/dev/null
if [ $? -eq 0 ]
then
echo "Internet is up."
sudo ip route add default via $def_gateway
else
echo "Offline"
echo "Check Internet Access and try again"
echo "Exit on Error !"
exit
fi
else
echo "incorrect gateway"
read -p "Proxy Gateway ? : " def_gateway
fi
else
ping -W 1 -c 2 $def_gateway >/dev/null
ping -W 1 -c 2 $def_gateway >/dev/null
if [ $? -eq 0 ]
then
echo "Internet is up."
else
echo "Offline"
read -p "Proxy Server Gateway ? : " def_gateway
if [[ $def_gateway =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]
then
ping -W 1 -c 2 $def_gateway >/dev/null
ping -W 1 -c 2 $def_gateway >/dev/null
if [ $? -eq 0 ]
then
echo "Internet is up."
# sudo ip route add default via $def_gateway
else
echo "Offline"
echo "Check Internet Access and try again"
echo "Exit on Error !"
exit
fi
fi
fi
fi
echo "Check your config/config.sh file"
read -p "Press [Enter] key to start ..."
chmod +rwx $allproxy_path/config/config.sh
source $allproxy_path/config/config.sh
read -p "Which proxy ? : " which_proxy
case $which_proxy in
tproxy)
source $allproxy_path/tproxy/start.sh &
;;
vproxy)
source $allproxy_path/vproxy/start.sh &
;;
lproxy)
source $allproxy_path/lproxy/start.sh &
;;
sproxy)
source $allproxy_path/sproxy/start.sh &
;;
nproxy)
source $allproxy_path/nproxy/start.sh &
;;
cproxy)
source $allproxy_path/cproxy/start.sh &
;;
esac
;;
esac
exit