/
dowse
executable file
·55 lines (42 loc) · 1.27 KB
/
dowse
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
#!/usr/bin/env zsh
dowse_mod_name=squid-privoxy
dowse_mod_desc="Transparent http proxy pipeline chaining squid to privoxy"
dowse_mod_type=(http proxy)
dowse_mod_ports=(squid3/3128 privoxy/8118)
dowse_mod_deps=(squid3 privoxy)
dowse_mod_authors=(Jaromil)
dowse_mod_version=0.1
# setup a transparent proxy on port 80
# using squid and privoxy
module-setup() {
rm -f $R/run/squid.conf
squid-conf > $R/run/squid.conf
cat <<EOF >> $R/run/squid.conf
http_port $address:3128 transparent
pid_filename $R/run/squid.pid
cache_log $R/log/squid_cache.log
access_log /dev/null
# access_log $R/log/squid_access.log squid
# pass through privoxy
cache_peer $address parent 8118 0 default no-query no-digest no-netdb-exchange proxy-only
EOF
rm -f $R/run/privoxy.conf
privoxy-conf > $R/run/privoxy.conf
cat <<EOF >> $R/run/privoxy.conf
logdir $R/log/privoxy.log
pid-file $R/run/privoxy.pid
EOF
}
module-start() {
[[ $EUID = 0 ]] && {
notice "setup transparent proxy to squid"
iptables -t nat -A PREROUTING -i $interface -s $dowse_net \
-p tcp --dport 80 -j REDIRECT --to-port 3128
}
privoxy-start $R/run/privoxy.conf
squid-start $R/run/squid.conf
}
module-stop() {
squid-stop $R/run/squid.pid
privoxy-stop $R/run/privoxy.pid
}