add openbsd support

This commit is contained in:
Mark Puha 2023-09-29 11:56:01 +02:00
parent 10c65efeb0
commit adba8c59a0

View file

@ -27,6 +27,7 @@ SAVE_CONFIG=0
CONFIG_FILE="" CONFIG_FILE=""
PROGRAM="${0##*/}" PROGRAM="${0##*/}"
ARGS=( "$@" ) ARGS=( "$@" )
IS_ASESCURITY_ON=0
cmd() { cmd() {
echo "[#] $*" >&3 echo "[#] $*" >&3
@ -68,6 +69,17 @@ parse_options() {
PostDown) POST_DOWN+=( "$value" ); continue ;; PostDown) POST_DOWN+=( "$value" ); continue ;;
SaveConfig) read_bool SAVE_CONFIG "$value"; continue ;; SaveConfig) read_bool SAVE_CONFIG "$value"; continue ;;
esac esac
case "$key" in
Jc);&
Jmin);&
Jmax);&
S1);&
S2);&
H1);&
H2);&
H3);&
H4) IS_ASESCURITY_ON=1;;
esac
fi fi
WG_CONFIG+="$line"$'\n' WG_CONFIG+="$line"$'\n'
done < "$CONFIG_FILE" done < "$CONFIG_FILE"
@ -106,6 +118,10 @@ add_if() {
while true; do while true; do
local -A existing_ifs="( $(wg show interfaces | sed 's/\([^ ]*\)/[\1]=1/g') )" local -A existing_ifs="( $(wg show interfaces | sed 's/\([^ ]*\)/[\1]=1/g') )"
local index ret local index ret
if [[ $IS_ASESCURITY_ON == 1 ]]; then
cmd "wireguard-go "$INTERFACE"";
return $?
else
for ((index=0; index <= 2147483647; ++index)); do [[ -v existing_ifs[wg$index] ]] || break; done for ((index=0; index <= 2147483647; ++index)); do [[ -v existing_ifs[wg$index] ]] || break; done
if ret="$(cmd ifconfig wg$index create description "wg-quick: $INTERFACE" 2>&1)"; then if ret="$(cmd ifconfig wg$index create description "wg-quick: $INTERFACE" 2>&1)"; then
REAL_INTERFACE="wg$index" REAL_INTERFACE="wg$index"
@ -114,6 +130,7 @@ add_if() {
[[ $ret == *"ifconfig: SIOCIFCREATE: File exists"* ]] && continue [[ $ret == *"ifconfig: SIOCIFCREATE: File exists"* ]] && continue
echo "$ret" >&3 echo "$ret" >&3
return 1 return 1
fi
done done
} }