mirror of
https://github.com/amnezia-vpn/amneziawg-tools.git
synced 2025-07-31 00:42:50 +02:00
add openbsd support
This commit is contained in:
parent
10c65efeb0
commit
adba8c59a0
1 changed files with 24 additions and 7 deletions
|
@ -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,14 +118,19 @@ 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
|
||||||
for ((index=0; index <= 2147483647; ++index)); do [[ -v existing_ifs[wg$index] ]] || break; done
|
if [[ $IS_ASESCURITY_ON == 1 ]]; then
|
||||||
if ret="$(cmd ifconfig wg$index create description "wg-quick: $INTERFACE" 2>&1)"; then
|
cmd "wireguard-go "$INTERFACE"";
|
||||||
REAL_INTERFACE="wg$index"
|
return $?
|
||||||
return 0
|
else
|
||||||
|
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
|
||||||
|
REAL_INTERFACE="wg$index"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
[[ $ret == *"ifconfig: SIOCIFCREATE: File exists"* ]] && continue
|
||||||
|
echo "$ret" >&3
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
[[ $ret == *"ifconfig: SIOCIFCREATE: File exists"* ]] && continue
|
|
||||||
echo "$ret" >&3
|
|
||||||
return 1
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue