diff --git a/contrib/embeddable-wg-library/wireguard.c b/contrib/embeddable-wg-library/wireguard.c index 4941549a..196fa328 100644 --- a/contrib/embeddable-wg-library/wireguard.c +++ b/contrib/embeddable-wg-library/wireguard.c @@ -26,7 +26,7 @@ /* wireguard.h netlink uapi: */ -#define WG_GENL_NAME "wireguard" +#define WG_GENL_NAME "amnezia" #define WG_GENL_VERSION 1 enum wg_cmd { @@ -48,6 +48,15 @@ enum wgdevice_attribute { WGDEVICE_A_LISTEN_PORT, WGDEVICE_A_FWMARK, WGDEVICE_A_PEERS, + WGDEVICE_A_JC, + WGDEVICE_A_JMIN, + WGDEVICE_A_JMAX, + WGDEVICE_A_S1, + WGDEVICE_A_S2, + WGDEVICE_A_H1, + WGDEVICE_A_H2, + WGDEVICE_A_H3, + WGDEVICE_A_H4, __WGDEVICE_A_LAST }; diff --git a/src/ipc-linux.h b/src/ipc-linux.h index 21cf205d..c6550db7 100644 --- a/src/ipc-linux.h +++ b/src/ipc-linux.h @@ -459,41 +459,59 @@ static int parse_device(const struct nlattr *attr, void *data) break; case WGDEVICE_A_PEERS: return mnl_attr_parse_nested(attr, parse_peers, device); - case WGDEVICE_HAS_JC: - if (!mnl_attr_validate(attr, MNL_TYPE_U16)) - device->junk_packet_count = mnl_attr_get_u16(attr); + case WGDEVICE_A_JC: + if (!mnl_attr_validate(attr, MNL_TYPE_U16)) { + device->junk_packet_count = mnl_attr_get_u16(attr); + device->flags |= WGDEVICE_HAS_JC; + } break; - case WGDEVICE_HAS_JMIN: - if (!mnl_attr_validate(attr, MNL_TYPE_U16)) - device->junk_packet_min_size = mnl_attr_get_u16(attr); + case WGDEVICE_A_JMIN: + if (!mnl_attr_validate(attr, MNL_TYPE_U16)) { + device->junk_packet_min_size = mnl_attr_get_u16(attr); + device->flags |= WGDEVICE_HAS_JMIN; + } break; - case WGDEVICE_HAS_JMAX: - if (!mnl_attr_validate(attr, MNL_TYPE_U16)) - device->junk_packet_max_size = mnl_attr_get_u16(attr); + case WGDEVICE_A_JMAX: + if (!mnl_attr_validate(attr, MNL_TYPE_U16)) { + device->junk_packet_max_size = mnl_attr_get_u16(attr); + device->flags |= WGDEVICE_HAS_JMAX; + } break; - case WGDEVICE_HAS_S1: - if (!mnl_attr_validate(attr, MNL_TYPE_U16)) - device->init_packet_junk_size = mnl_attr_get_u16(attr); + case WGDEVICE_A_S1: + if (!mnl_attr_validate(attr, MNL_TYPE_U16)) { + device->init_packet_junk_size = mnl_attr_get_u16(attr); + device->flags |= WGDEVICE_HAS_S1; + } break; - case WGDEVICE_HAS_S2: - if (!mnl_attr_validate(attr, MNL_TYPE_U16)) - device->response_packet_junk_size = mnl_attr_get_u16(attr); + case WGDEVICE_A_S2: + if (!mnl_attr_validate(attr, MNL_TYPE_U16)) { + device->response_packet_junk_size = mnl_attr_get_u16(attr); + device->flags |= WGDEVICE_HAS_S2; + } break; - case WGDEVICE_HAS_H1: - if (!mnl_attr_validate(attr, MNL_TYPE_U32)) - device->init_packet_magic_header = mnl_attr_get_u32(attr); + case WGDEVICE_A_H1: + if (!mnl_attr_validate(attr, MNL_TYPE_U32)) { + device->init_packet_magic_header = mnl_attr_get_u32(attr); + device->flags |= WGDEVICE_HAS_H1; + } break; - case WGDEVICE_HAS_H2: - if (!mnl_attr_validate(attr, MNL_TYPE_U32)) - device->response_packet_magic_header = mnl_attr_get_u32(attr); + case WGDEVICE_A_H2: + if (!mnl_attr_validate(attr, MNL_TYPE_U32)) { + device->response_packet_magic_header = mnl_attr_get_u32(attr); + device->flags |= WGDEVICE_HAS_H2; + } break; - case WGDEVICE_HAS_H3: - if (!mnl_attr_validate(attr, MNL_TYPE_U32)) - device->underload_packet_magic_header = mnl_attr_get_u32(attr); + case WGDEVICE_A_H3: + if (!mnl_attr_validate(attr, MNL_TYPE_U32)) { + device->underload_packet_magic_header = mnl_attr_get_u32(attr); + device->flags |= WGDEVICE_HAS_H3; + } break; - case WGDEVICE_HAS_H4: - if (!mnl_attr_validate(attr, MNL_TYPE_U32)) - device->transport_packet_magic_header = mnl_attr_get_u32(attr); + case WGDEVICE_A_H4: + if (!mnl_attr_validate(attr, MNL_TYPE_U32)) { + device->transport_packet_magic_header = mnl_attr_get_u32(attr); + device->flags |= WGDEVICE_HAS_H4; + } break; } diff --git a/src/uapi/linux/linux/wireguard.h b/src/uapi/linux/linux/wireguard.h index 33d9d660..4c2eb25e 100644 --- a/src/uapi/linux/linux/wireguard.h +++ b/src/uapi/linux/linux/wireguard.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT */ + /* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT */ /* * Copyright (C) 2015-2020 Jason A. Donenfeld . All Rights Reserved. * @@ -131,7 +131,7 @@ #ifndef _WG_UAPI_WIREGUARD_H #define _WG_UAPI_WIREGUARD_H -#define WG_GENL_NAME "wireguard" +#define WG_GENL_NAME "amnezia" #define WG_GENL_VERSION 1 #define WG_KEY_LEN 32 diff --git a/src/wg-quick/linux.bash b/src/wg-quick/linux.bash index 4193ce58..6ef40628 100755 --- a/src/wg-quick/linux.bash +++ b/src/wg-quick/linux.bash @@ -40,7 +40,7 @@ die() { parse_options() { local interface_section=0 line key value stripped v CONFIG_FILE="$1" - [[ $CONFIG_FILE =~ ^[a-zA-Z0-9_=+.-]{1,15}$ ]] && CONFIG_FILE="/etc/wireguard/$CONFIG_FILE.conf" + [[ $CONFIG_FILE =~ ^[a-zA-Z0-9_=+.-]{1,15}$ ]] && CONFIG_FILE="/etc/amnezia/$CONFIG_FILE.conf" [[ -e $CONFIG_FILE ]] || die "\`$CONFIG_FILE' does not exist" [[ $CONFIG_FILE =~ (^|/)([a-zA-Z0-9_=+.-]{1,15})\.conf$ ]] || die "The config file must be a valid interface name, followed by .conf" CONFIG_FILE="$(readlink -f "$CONFIG_FILE")" @@ -87,10 +87,10 @@ auto_su() { add_if() { local ret - if ! cmd ip link add "$INTERFACE" type wireguard; then + if ! cmd ip link add "$INTERFACE" type amnezia; 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 + [[ -e /sys/module/amnezia ]] || ! command -v "${WG_QUICK_USERSPACE_IMPLEMENTATION:-wireguard-go}" >/dev/null && exit $ret + echo "[!] Missing WireGuard (Amnezia VPN) kernel module. Falling back to slow userspace implementation." >&2 cmd "${WG_QUICK_USERSPACE_IMPLEMENTATION:-wireguard-go}" "$INTERFACE" fi } @@ -302,7 +302,7 @@ cmd_usage() { CONFIG_FILE is a configuration file, whose filename is the interface name followed by \`.conf'. Otherwise, INTERFACE is an interface name, with - configuration found at /etc/wireguard/INTERFACE.conf. It is to be readable + configuration found at /etc/amnezia/INTERFACE.conf. It is to be readable by wg(8)'s \`setconf' sub-command, with the exception of the following additions to the [Interface] section, which are handled by $PROGRAM: