-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultiTLSv1
executable file
·66 lines (58 loc) · 1.4 KB
/
multiTLSv1
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
#!/bin/bash
port="$2"
nChannels="$3"
cert="/home/debian/Documents/SOCAT/server.pem"
cafile="/home/debian/Documents/SOCAT/client.crt"
ccert="/home/debian/Documents/SOCAT/client.pem"
ccafile="/home/debian/Documents/SOCAT/server.crt"
case "$1" in
-s)
i=1
while [ $i -le $nChannels ]
do
auxport=$(($port - $nChannels -1 + $i))
nameTun="tun$i"
ipTun="192.168.$i.1"
echo "$ipTun"
socat openssl-listen:$auxport,reuseaddr,cert=$cert,cafile=$cafile TUN:$ipTun/24,tun-name=$nameTun,up &
channel1_pid=$!
echo "$channel1_pid"
i=$(($i + 1))
#sleep 1
done
socat tcp-listen:$port,reuseaddr echo &
communication_pid=$!
echo "$communication1_pid"
;;
-c)
i=1
lastTun="192.168.$nChannels.1"
while [ $i -le $nChannels ]
do
ipServer="$4"
auxport=$(($port - $nChannels -1 + $i))
nameTun="tun$i"
ipTun="192.168.$i.2"
j=$(($i -1))
auxIpTun="192.168.$j.1"
if [ "$i" -eq "1" ]
then
socat openssl-connect:$ipServer:$auxport,reuseaddr,cert=$ccert,cafile=$ccafile TUN:$ipTun/24,tun-name=$nameTun,up &
#channel1_pid=$!
#echo "$channel1_pid"
else
socat openssl-connect:$auxIpTun:$auxport,reuseaddr,cert=$ccert,cafile=$ccafile TUN:$ipTun/24,tun-name=$nameTun,up &
#channel1_pid=$!
#echo "$channel1_pid"
fi
i=$(($i + 1))
sleep 1
done
socat stdio tcp:$lastTun:$port
#communication_pid=$!
#echo "$communication1_pid"
;;
*)
echo "DEFAULT"
;;
esac