| 1 | #!/bin/sh |
|---|
| 2 | # |
|---|
| 3 | # Script to bypass HTTP interception for traffic forwarded by OLSR |
|---|
| 4 | # bms 9-Aug-2005 |
|---|
| 5 | # Licensed under GPL |
|---|
| 6 | # |
|---|
| 7 | |
|---|
| 8 | rm -f /tmp/get_neighbors.awk |
|---|
| 9 | cat > /tmp/get_neighbors.awk <<__HERE1__ |
|---|
| 10 | BEGIN { |
|---|
| 11 | while("route -n"|getline) { |
|---|
| 12 | if (/^[0-9]/) { |
|---|
| 13 | if (0 < \$5) { |
|---|
| 14 | if (\$3 == "255.255.255.255 <http://255.255.255.255>") { |
|---|
| 15 | printf "%s\n", \$1; |
|---|
| 16 | } |
|---|
| 17 | } |
|---|
| 18 | } |
|---|
| 19 | } |
|---|
| 20 | } |
|---|
| 21 | __HERE1__ |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | iptables -t nat -D WiFiDog_Unknown -j OlsrNeighbors 2>&1 >/dev/null |
|---|
| 25 | iptables -t nat -F OlsrNeighbors 2>&1 >/dev/null |
|---|
| 26 | iptables -t nat -X OlsrNeighbors 2>&1 >/dev/null |
|---|
| 27 | iptables -t nat -N OlsrNeighbors |
|---|
| 28 | |
|---|
| 29 | neighbors=$(awk -f /tmp/get_neighbors.awk) |
|---|
| 30 | |
|---|
| 31 | for _neighbor in ${neighbors} ; do |
|---|
| 32 | |
|---|
| 33 | _mac=$(grep "^${_neighbor}" /proc/net/arp | awk '{print $4}') |
|---|
| 34 | echo ${_mac} |
|---|
| 35 | iptables -t nat -A OlsrNeighbors -m mac --mac-source ${_mac} \ |
|---|
| 36 | -p tcp --dport 80 -j ACCEPT |
|---|
| 37 | |
|---|
| 38 | done |
|---|
| 39 | |
|---|
| 40 | iptables -t nat -I WiFiDog_Unknown -j OlsrNeighbors |
|---|