mirror of
https://github.com/amnezia-vpn/amneziawg-tools.git
synced 2025-07-31 17:02:50 +02:00
wg-quick for linux and openbsd
This commit is contained in:
parent
18901ddeaf
commit
837235f51f
2 changed files with 36 additions and 2 deletions
|
@ -28,6 +28,8 @@ CONFIG_FILE=""
|
|||
PROGRAM="${0##*/}"
|
||||
ARGS=( "$@" )
|
||||
|
||||
IS_ASESCURITY_ON=0
|
||||
|
||||
cmd() {
|
||||
echo "[#] $*" >&3
|
||||
"$@"
|
||||
|
@ -96,6 +98,17 @@ parse_options() {
|
|||
PostDown) POST_DOWN+=( "$value" ); continue ;;
|
||||
SaveConfig) read_bool SAVE_CONFIG "$value"; continue ;;
|
||||
esac
|
||||
case "$key" in
|
||||
Jc);&
|
||||
Jmin);&
|
||||
Jmax);&
|
||||
S1);&
|
||||
S2);&
|
||||
H1);&
|
||||
H2);&
|
||||
H3);&
|
||||
H4) IS_ASESCURITY_ON=1;;
|
||||
esac
|
||||
fi
|
||||
WG_CONFIG+="$line"$'\n'
|
||||
done < "$CONFIG_FILE"
|
||||
|
@ -116,7 +129,11 @@ auto_su() {
|
|||
|
||||
add_if() {
|
||||
local ret rc
|
||||
if ret="$(cmd ifconfig wg create name "$INTERFACE" 2>&1 >/dev/null)"; then
|
||||
local cmd="ifconfig wg create name "$INTERFACE""
|
||||
if [[ $IS_ASESCURITY_ON == 1 ]]; then
|
||||
cmd="wireguard-go "$INTERFACE"";
|
||||
fi
|
||||
if ret="$(cmd $cmd 2>&1 >/dev/null)"; then
|
||||
return 0
|
||||
fi
|
||||
rc=$?
|
||||
|
|
|
@ -26,6 +26,7 @@ SAVE_CONFIG=0
|
|||
CONFIG_FILE=""
|
||||
PROGRAM="${0##*/}"
|
||||
ARGS=( "$@" )
|
||||
IS_ASESCURITY_ON=0
|
||||
|
||||
cmd() {
|
||||
echo "[#] $*" >&2
|
||||
|
@ -37,6 +38,7 @@ die() {
|
|||
exit 1
|
||||
}
|
||||
|
||||
|
||||
parse_options() {
|
||||
local interface_section=0 line key value stripped v
|
||||
CONFIG_FILE="$1"
|
||||
|
@ -67,6 +69,17 @@ parse_options() {
|
|||
PostDown) POST_DOWN+=( "$value" ); continue ;;
|
||||
SaveConfig) read_bool SAVE_CONFIG "$value"; continue ;;
|
||||
esac
|
||||
case "$key" in
|
||||
Jc);&
|
||||
Jmin);&
|
||||
Jmax);&
|
||||
S1);&
|
||||
S2);&
|
||||
H1);&
|
||||
H2);&
|
||||
H3);&
|
||||
H4) IS_ASESCURITY_ON=1;;
|
||||
esac
|
||||
fi
|
||||
WG_CONFIG+="$line"$'\n'
|
||||
done < "$CONFIG_FILE"
|
||||
|
@ -87,7 +100,11 @@ auto_su() {
|
|||
|
||||
add_if() {
|
||||
local ret
|
||||
if ! cmd ip link add "$INTERFACE" type wireguard; then
|
||||
local cmd="ip link add "$INTERFACE" type wireguard"
|
||||
if [[ $IS_ASESCURITY_ON == 1 ]]; then
|
||||
cmd="wireguard-go "$INTERFACE"";
|
||||
fi
|
||||
if ! cmd $cmd; then
|
||||
ret=$?
|
||||
[[ -e /sys/module/wireguard ]] || ! command -v "${WG_QUICK_USERSPACE_IMPLEMENTATION:-wireguard-go}" >/dev/null && exit $ret
|
||||
echo "[!] Missing WireGuard kernel module. Falling back to slow userspace implementation." >&2
|
||||
|
|
Loading…
Add table
Reference in a new issue