-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathscript.sh
executable file
·113 lines (93 loc) · 3.29 KB
/
script.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
#!/bin/sh
# POSIX
build=0
client=0
browser="chromium"
while :; do
case $1 in
-b|-\?|--build)
build=1
;;
-c|-\?|--client)
client=1
;;
--gecko)
browser="gecko"
;;
--chromium)
browser="chromium"
;;
-?*)
printf 'Warning: Unknown option: %s\n' "$1" >&2
;;
*) #default case: no more options
break
esac
shift
done
# we manually copy files locally (avoiding go install so we don't have to recompile every time)
if [ "$build" -ne "0" ]; then
#kill broker, proxy, client processes
pkill -f broker
pkill -f client
pkill -f tor
pkill -f server
pkill -f probetest
cd /go/src/snowflake/broker
go get -d -v
go build -v
cd /go/src/snowflake/proxy
go get -d -v
go build -v
cd /go/src/snowflake/client
go get -d -v
go build -v
cd /go/src/snowflake/server
go get -d -v
go build -v
cd /go/src/snowflake/probetest
go get -d -v
go build -v
cd /go/src/snowflake-webext
npm install
npm run build
npm run webext $browser
#need to point to our localhost broker instead
sed -i 's/snowflake-broker.freehaven.net/localhost:8080/' build/embed.js
sed -i 's/snowflake-broker.freehaven.net/localhost:8080/' build-webext/snowflake.js
sed -i 's/wss:\/\/snowflake.freehaven.net/ws:\/\/127.0.0.1:8000/' build/embed.js
sed -i 's/wss:\/\/snowflake.freehaven.net/ws:\/\/127.0.0.1:8000/' build-webext/snowflake.js
sed -i 's/snowflake.torproject.net/127.0.0.1/' build/embed.js
sed -i 's/snowflake.torproject.net/127.0.0.1/' build-webext/snowflake.js
sed -i 's/wss:\/\/\*.freehaven.net/ws:\/\/127.0.0.1:8000 http:\/\/localhost:8080/' build-webext/manifest.json
sed -i 's/wss/ws/' build/embed.js
sed -i 's/wss/ws/' build-webext/snowflake.js
cd /go/src
fi
if [ "$client" -eq "0" ]; then
cp /go/src/snowflake/broker/broker /go/bin/
cp /go/src/snowflake/proxy/proxy /go/bin/
cp /go/src/snowflake/client/client /go/bin/
cp /go/src/snowflake/server/server /go/bin/
cp /go/src/snowflake/probetest/probetest /go/bin/
cd
broker -addr ":8080" -disable-tls -unsafe-logging -default-relay-pattern ^127.0.0.1$ -allowed-relay-pattern ^127.0.0.1$ -bridge-list-path bridge-list.json > broker.log 2> broker.err &
proxy -keep-local-addresses -broker "http://localhost:8080" -relay ws://127.0.0.1:8000/ -stun stun:stun.voip.blackberry.com:3478 -allow-proxying-to-private-addresses -allowed-relay-hostname-pattern ^127.0.0.1$ -allow-non-tls-relay -unsafe-logging -verbose > proxy.log 2> proxy.err &
tor -f torrc-server > server.out &
probetest --disable-tls 2> probetest.err &
else
cd
# Find a SOCKSPort to bind to that is not in use
count=0
while :; do
if ! netstat --inet -n -a -p 2> /dev/null | grep ":$(($count+9050))" ; then
break
fi
count=$(($count+1))
done
cp torrc-client torrc-$count
sed -i -e "s/datadir/datadir$count/g" torrc-$count
sed -i -e "/^-url http:\/\/localhost:8080\//a -log snowflake_client-$count.log" torrc-$count
echo "SOCKSPort $(($count+9050))" >> torrc-$count
tor -f torrc-$count > client-$count.log 2> client-$count.err &
fi