add ipv6 to shaper.sh
authorJustin Wind <justin.wind+git@gmail.com>
Sun, 1 Oct 2017 19:20:28 +0000 (12:20 -0700)
committerJustin Wind <justin.wind+git@gmail.com>
Sun, 1 Oct 2017 19:20:28 +0000 (12:20 -0700)
shaper.sh

index 8fdc296445799747ab9271a7171f9e52e0847736..5b55d3fd4b8b3ebbfd78f35c4725262956c8a448 100755 (executable)
--- a/shaper.sh
+++ b/shaper.sh
@@ -52,15 +52,24 @@ function shape(){
        then
                $IPTABLES -t mangle -A "${SHAPE_CHAIN}" "$@" -j MARK --set-mark ${prio}
        fi
+       if ! $IP6TABLES -t mangle -C "${SHAPE_CHAIN}" "$@" -j MARK --set-mark ${prio} >/dev/null 2>&1
+       then
+               $IP6TABLES -t mangle -A "${SHAPE_CHAIN}" "$@" -j MARK --set-mark ${prio}
+       fi
 }
 
 shape_if "${EXT_IF}" "${UPLINK}" "${BURST}"
 
 if ! $IPTABLES -t mangle -L "${SHAPE_CHAIN}" >/dev/null 2>&1
 then
-       echo "initializing chain '${SHAPE_CHAIN}'"
+       echo "initializing ipv4 chain '${SHAPE_CHAIN}'"
        $IPTABLES -t mangle -N "${SHAPE_CHAIN}"
 fi
+if ! $IP6TABLES -t mangle -L "${SHAPE_CHAIN}" >/dev/null 2>&1
+then
+       echo "initializing ipv6 chain '${SHAPE_CHAIN}'"
+       $iP6TABLES -t mangle -N "${SHAPE_CHAIN}"
+fi
 
 # prioritize small and responsive things
 shape 1 -p icmp
@@ -92,3 +101,12 @@ then
        $IPTABLES -t mangle -I POSTROUTING -o "${EXT_IF}" -j "${SHAPE_CHAIN}"
 fi
 
+if ! $IP6TABLES -t mangle -C POSTROUTING -o "${EXT_IF}" -j "${SHAPE_CHAIN}" >/dev/null 2>&1
+then
+       $IP6TABLES -t mangle -I POSTROUTING -o "${EXT_IF}" -j "${SHAPE_CHAIN}"
+fi
+
+if [[ ! -e /etc/local.d/shaper.start ]]
+then
+       echo "add shaper to local rc start!"
+fi