15 if [ $PID -gt 0 ]; then
16 if ps $PID | grep -q $NAME; then
23 if [ "$CMD" = "P2P-GROUP-STARTED" ]; then
25 if [ "$4" = "GO" ]; then
26 kill_daemon dhclient /var/run/dhclient-$GIFNAME.pid
27 rm /var/run/dhclient.leases-$GIFNAME
28 kill_daemon dnsmasq /var/run/dnsmasq.pid-$GIFNAME
29 ifconfig $GIFNAME 192.168.42.1 up
30 if ! dnsmasq -x /var/run/dnsmasq.pid-$GIFNAME \
32 -F192.168.42.11,192.168.42.99; then
33 # another dnsmasq instance may be running and blocking us; try to
34 # start with -z to avoid that
35 dnsmasq -x /var/run/dnsmasq.pid-$GIFNAME \
37 -F192.168.42.11,192.168.42.99 --listen-address 192.168.42.1 -z
40 if [ "$4" = "client" ]; then
41 kill_daemon dhclient /var/run/dhclient-$GIFNAME.pid
42 rm /var/run/dhclient.leases-$GIFNAME
43 kill_daemon dnsmasq /var/run/dnsmasq.pid-$GIFNAME
44 dhclient -pf /var/run/dhclient-$GIFNAME.pid \
45 -lf /var/run/dhclient.leases-$GIFNAME \
51 if [ "$CMD" = "P2P-GROUP-REMOVED" ]; then
53 if [ "$4" = "GO" ]; then
54 kill_daemon dnsmasq /var/run/dnsmasq.pid-$GIFNAME
55 ifconfig $GIFNAME 0.0.0.0
57 if [ "$4" = "client" ]; then
58 kill_daemon dhclient /var/run/dhclient-$GIFNAME.pid
59 rm /var/run/dhclient.leases-$GIFNAME
60 ifconfig $GIFNAME 0.0.0.0
64 if [ "$CMD" = "P2P-CROSS-CONNECT-ENABLE" ]; then
67 # enable NAT/masquarade $GIFNAME -> $UPLINK
68 iptables -P FORWARD DROP
69 iptables -t nat -A POSTROUTING -o $UPLINK -j MASQUERADE
70 iptables -A FORWARD -i $UPLINK -o $GIFNAME -m state --state RELATED,ESTABLISHED -j ACCEPT
71 iptables -A FORWARD -i $GIFNAME -o $UPLINK -j ACCEPT
72 sysctl net.ipv4.ip_forward=1
75 if [ "$CMD" = "P2P-CROSS-CONNECT-DISABLE" ]; then
78 # disable NAT/masquarade $GIFNAME -> $UPLINK
79 sysctl net.ipv4.ip_forward=0
80 iptables -t nat -D POSTROUTING -o $UPLINK -j MASQUERADE
81 iptables -D FORWARD -i $UPLINK -o $GIFNAME -m state --state RELATED,ESTABLISHED -j ACCEPT
82 iptables -D FORWARD -i $GIFNAME -o $UPLINK -j ACCEPT