fix wireguard port number issue
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA FUCK
This commit is contained in:
@@ -1,99 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
# example env vars:
|
||||
# UP_TARGETS="fd69:c6:1055:cafe:10c:ba1:e001:c001 fd69:c6:1055:cafe:10c:ba1:e001:c002 fd69:c6:1055:cafe:10c:ba1:e001:c003"
|
||||
# UP_TARGET_NAMES="gw-1 gw-2 gw-3"
|
||||
# UP_TARGETS_V4=''
|
||||
# UP_TARGETS_V6="fd69:c6:1055:cafe:10c:ba1:e001:c001 fd69:c6:1055:cafe:10c:ba1:e001:c002 fd69:c6:1055:cafe:10c:ba1:e001:c003"
|
||||
# UP_GATEWAY_NUMS_V4=''
|
||||
# UP_GATEWAY_NUMS_V6='1 2 3'
|
||||
# ALL_TARGET_BIASES='69 4 20'
|
||||
# UP_TARGET_BIASES_V4=''
|
||||
# UP_TARGET_BIASES_V6='3 4 9'
|
||||
|
||||
|
||||
# note: THIS ONE IS CASE SENSITIVE!!!
|
||||
remote_juggler_ipv6="fd69:c6:1055:cafe:10c:ba1::1"
|
||||
juggle_if="circus-wg"
|
||||
|
||||
|
||||
# debug nft
|
||||
dnft() {
|
||||
echo nft "$*"
|
||||
nft $*
|
||||
return $?
|
||||
}
|
||||
|
||||
swap_map() {
|
||||
ipver="$1"
|
||||
virt_gw="$2"
|
||||
targets="$3"
|
||||
biases="$4"
|
||||
|
||||
|
||||
# build bullshit
|
||||
# nft has a bug in the version I'm using where the ranges don't work
|
||||
the_map=''
|
||||
bias_arr=($biases)
|
||||
range_i=0
|
||||
i=0
|
||||
for gw in $targets; do
|
||||
bias=${bias_arr[$i]}
|
||||
|
||||
for ((j = 0; j < $bias; j++)); do
|
||||
the_map="$the_map$range_i: $gw, "
|
||||
range_i=$(($range_i + 1))
|
||||
done
|
||||
|
||||
i=$(($i+1))
|
||||
done
|
||||
mod=$range_i
|
||||
|
||||
|
||||
# build biased round-robin map
|
||||
# the_map=''
|
||||
# bias_arr=($biases)
|
||||
# range_i=0
|
||||
# i=0
|
||||
# for gw in $targets; do
|
||||
|
||||
# range_start=$range_i
|
||||
# range_i=$(($range_i + ${bias_arr[$i]}))
|
||||
# range_end=$(($range_i - 1))
|
||||
|
||||
# case ${bias_arr[$i]} in
|
||||
# 0)
|
||||
# echo "bias == 0‽"
|
||||
# ;;
|
||||
# 1)
|
||||
# the_map="$the_map$range_start: $gw, "
|
||||
# ;;
|
||||
# *)
|
||||
# the_map="$the_map$range_start-$range_end: $gw, "
|
||||
# ;;
|
||||
# esac
|
||||
# i=$(($i+1))
|
||||
# done
|
||||
# mod=$range_i
|
||||
|
||||
|
||||
# atomic rule replacement (no I'm not making a netfilter script, gargle my balls)
|
||||
handles="`nft -n -a list chain "$ipver" raw postrouting | grep 'oifname "'"$juggle_if"'" '"$ipver"' daddr '"$virt_gw"' '"$ipver"' daddr set numgen' | grep -oe '# handle [0-9]\+$' | grep -oe '[0-9]\+$'`"
|
||||
for handle in $handles; do
|
||||
echo "fuck your handle $handle"
|
||||
dnft replace rule "$ipver" raw postrouting handle "$handle" 'oifname '"$juggle_if"' '"$ipver"' daddr '"$virt_gw"' '"$ipver"' daddr set numgen random mod '"$mod"' map {'"$the_map"'}'
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
set -e
|
||||
|
||||
if ! [[ "$UP_TARGETS_V6" == "" ]]; then
|
||||
echo "updating IPv6 destination address translations"
|
||||
swap_map ip6 "$remote_juggler_ipv6" "$UP_TARGETS_V6" "$UP_TARGET_BIASES_V6"
|
||||
fi
|
||||
|
||||
echo ''
|
||||
echo postrouting chain:
|
||||
dnft -n -a list chain ip6 raw postrouting
|
||||
echo ''
|
||||
@@ -1,5 +1,5 @@
|
||||
TCP_PORTS='25,80,443,465,587,143,993,110,995,1359,2569,4190,25569 16901:16950'
|
||||
UDP_PORTS='42069,42000,42001,16902:16950'
|
||||
UDP_PORTS='42000,42001,16902:16950'
|
||||
IFNAME="wan0"
|
||||
|
||||
CLOWN_V6="fd69:c6:1055:cafe:10c:ba1::1"
|
||||
|
||||
Reference in New Issue
Block a user