mirror of
https://github.com/amnezia-vpn/amneziawg-tools.git
synced 2025-08-01 17:12:50 +02:00
fix: minor issues with new params
This commit is contained in:
parent
211a6d196a
commit
dbd48bde71
7 changed files with 30 additions and 23 deletions
|
@ -11,7 +11,7 @@ while read -r -d $'\t' device; do
|
|||
if [[ $device != "$last_device" ]]; then
|
||||
[[ -z $last_device ]] && printf '\n' || printf '%s,\n' "$end"
|
||||
last_device="$device"
|
||||
read -r private_key public_key listen_port jc jmin jmax s1 s2 h1 h2 h3 h4 i1 i2 i3 i4 i5 j1 j2 j3 itime fwmark
|
||||
read -r private_key public_key listen_port jc jmin jmax s1 s2 s3 s4 h1 h2 h3 h4 i1 i2 i3 i4 i5 j1 j2 j3 itime fwmark
|
||||
printf '\t"%s": {' "$device"
|
||||
delim=$'\n'
|
||||
[[ $private_key == "(none)" ]] || { printf '%s\t\t"privateKey": "%s"' "$delim" "$private_key"; delim=$',\n'; }
|
||||
|
@ -22,6 +22,8 @@ while read -r -d $'\t' device; do
|
|||
[[ $jmax == "0" ]] || { printf '%s\t\t"jmax": %u' "$delim" $(( $jmax )); delim=$',\n'; }
|
||||
[[ $s1 == "0" ]] || { printf '%s\t\t"s1": %u' "$delim" $(( $s1 )); delim=$',\n'; }
|
||||
[[ $s2 == "0" ]] || { printf '%s\t\t"s2": %u' "$delim" $(( $s2 )); delim=$',\n'; }
|
||||
[[ $s3 == "0" ]] || { printf '%s\t\t"s3": %u' "$delim" $(( $s3 )); delim=$',\n'; }
|
||||
[[ $s4 == "0" ]] || { printf '%s\t\t"s4": %u' "$delim" $(( $s4 )); delim=$',\n'; }
|
||||
[[ $h1 == "1" ]] || { printf '%s\t\t"h1": %u' "$delim" $(( $h1 )); delim=$',\n'; }
|
||||
[[ $h2 == "2" ]] || { printf '%s\t\t"h2": %u' "$delim" $(( $h2 )); delim=$',\n'; }
|
||||
[[ $h3 == "3" ]] || { printf '%s\t\t"h3": %u' "$delim" $(( $h3 )); delim=$',\n'; }
|
||||
|
|
|
@ -653,7 +653,7 @@ static int parse_device(const struct nlattr *attr, void *data)
|
|||
}
|
||||
break;
|
||||
case WGDEVICE_A_ITIME:
|
||||
if (!mnl_attr_validate(attr, MNL_TYPE_STRING))
|
||||
if (!mnl_attr_validate(attr, MNL_TYPE_U32))
|
||||
{
|
||||
device->itime = mnl_attr_get_u32(attr);
|
||||
device->flags |= WGDEVICE_HAS_ITIME;
|
||||
|
|
|
@ -215,7 +215,7 @@ static int kernel_get_device(struct wgdevice **device, const char *iface)
|
|||
|
||||
if (wg_iface->i_flags & WG_INTERFACE_DEVICE_HAS_ITIME)
|
||||
{
|
||||
dev->itime = wg_iface->i_itime ;
|
||||
dev->itime = wg_iface->i_itime;
|
||||
dev->flags |= WGDEVICE_HAS_ITIME;
|
||||
}
|
||||
|
||||
|
|
|
@ -307,64 +307,55 @@ static int kernel_get_device(struct wgdevice **device, const char *iface)
|
|||
dev->transport_packet_magic_header = wg_iface->TransportPacketMagicHeader;
|
||||
dev->flags |= WGDEVICE_HAS_H4;
|
||||
}
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_I1)
|
||||
{
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_I1) {
|
||||
const size_t i1_size = strlen((char*)wg_iface->I1) + 1;
|
||||
dev->i1 = (char*)malloc(i1_size);
|
||||
memcpy(dev->i1, wg_iface->I1, i1_size);
|
||||
dev->flags |= WGDEVICE_HAS_I1;
|
||||
}
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_I2)
|
||||
{
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_I2) {
|
||||
const size_t i2_size = strlen((char*)wg_iface->I2) + 1;
|
||||
dev->i2 = (char*)malloc(i2_size);
|
||||
memcpy(dev->i2, wg_iface->I2, i2_size);
|
||||
dev->flags |= WGDEVICE_HAS_I2;
|
||||
}
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_I3)
|
||||
{
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_I3) {
|
||||
const size_t i3_size = strlen((char*)wg_iface->I3) + 1;
|
||||
dev->i3 = (char*)malloc(i3_size);
|
||||
memcpy(dev->i3, wg_iface->I3, i3_size);
|
||||
dev->flags |= WGDEVICE_HAS_I3;
|
||||
}
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_I4)
|
||||
{
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_I4) {
|
||||
const size_t i4_size = strlen((char*)wg_iface->I4) + 1;
|
||||
dev->i4 = (char*)malloc(i4_size);
|
||||
memcpy(dev->i4, wg_iface->I4, i4_size);
|
||||
dev->flags |= WGDEVICE_HAS_I4;
|
||||
}
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_I5)
|
||||
{
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_I5) {
|
||||
const size_t i5_size = strlen((char*)wg_iface->I5) + 1;
|
||||
dev->i5 = (char*)malloc(i5_size);
|
||||
memcpy(dev->i5, wg_iface->I5, i5_size);
|
||||
dev->flags |= WGDEVICE_HAS_I5;
|
||||
}
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_J1)
|
||||
{
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_J1) {
|
||||
const size_t j1_size = strlen((char*)wg_iface->J1) + 1;
|
||||
dev->j1 = (char*)malloc(j1_size);
|
||||
memcpy(dev->j1, wg_iface->J1, j1_size);
|
||||
dev->flags |= WGDEVICE_HAS_J1;
|
||||
}
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_J2)
|
||||
{
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_J2) {
|
||||
const size_t j2_size = strlen((char*)wg_iface->J2) + 1;
|
||||
dev->j2 = (char*)malloc(j2_size);
|
||||
memcpy(dev->j2, wg_iface->J2, j2_size);
|
||||
dev->flags |= WGDEVICE_HAS_J2;
|
||||
}
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_J3)
|
||||
{
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_J3) {
|
||||
const size_t j3_size = strlen((char*)wg_iface->J3) + 1;
|
||||
dev->j3 = (char*)malloc(j3_size);
|
||||
memcpy(dev->j3, wg_iface->J3, j3_size);
|
||||
dev->flags |= WGDEVICE_HAS_J3;
|
||||
}
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_ITIME)
|
||||
{
|
||||
if (wg_iface->Flags & WG_IOCTL_INTERFACE_ITIME) {
|
||||
dev->itime = wg_iface->Itime;
|
||||
dev->flags |= WGDEVICE_HAS_ITIME;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ int set_main(int argc, const char *argv[])
|
|||
int ret = 1;
|
||||
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "Usage: %s %s <interface> [listen-port <port>] [fwmark <mark>] [private-key <file path>] [jc <junk_count>] [jmin <min_value>] [jmax <max_value>] [s1 <init_junk>] [s2 <resp_junk>] [h1 <init_header>] [h2 <resp_header>] [h3 <cookie_header>] [h4 <transp_header>] [i1 \"<taged_junk>\"] [i2 \"<taged_junk>\"] [i3 \"<taged_junk>\"] [i4 \"<taged_junk>\"] [i5 \"<taged_junk>\"] [j1 \"<taged_junk>\"] [j2 \"<taged_junk>\"] [j3 \"<taged_junk>\"] [itime <itimeout>][peer <base64 public key> [remove] [preshared-key <file path>] [endpoint <ip>:<port>] [persistent-keepalive <interval seconds>] [allowed-ips <ip1>/<cidr1>[,<ip2>/<cidr2>] [advanced-security <on|off>]...] ]...\n", PROG_NAME, argv[0]);
|
||||
fprintf(stderr, "Usage: %s %s <interface> [listen-port <port>] [fwmark <mark>] [private-key <file path>] [jc <junk_count>] [jmin <min_value>] [jmax <max_value>] [s1 <init_junk>] [s2 <resp_junk>] [s3 <cookie_junk>] [s4 <trans_junk>] [h1 <init_header>] [h2 <resp_header>] [h3 <cookie_header>] [h4 <transp_header>] [i1 \"<taged_junk>\"] [i2 \"<taged_junk>\"] [i3 \"<taged_junk>\"] [i4 \"<taged_junk>\"] [i5 \"<taged_junk>\"] [j1 \"<taged_junk>\"] [j2 \"<taged_junk>\"] [j3 \"<taged_junk>\"] [itime <itimeout>][peer <base64 public key> [remove] [preshared-key <file path>] [endpoint <ip>:<port>] [persistent-keepalive <interval seconds>] [allowed-ips <ip1>/<cidr1>[,<ip2>/<cidr2>] [advanced-security <on|off>]...] ]...\n", PROG_NAME, argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
12
src/show.c
12
src/show.c
|
@ -202,7 +202,7 @@ static char *bytes(uint64_t b)
|
|||
static const char *COMMAND_NAME;
|
||||
static void show_usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s %s { <interface> | all | interfaces } [public-key | private-key | listen-port | fwmark | peers | preshared-keys | endpoints | allowed-ips | latest-handshakes | transfer | persistent-keepalive | dump | jc | jmin | jmax | s1 | s2 | h1 | h2 | h3 | h4 | i1 | i2 | i3 | i4 | i5 | j1 | j2 | j3 | itime]\n", PROG_NAME, COMMAND_NAME);
|
||||
fprintf(stderr, "Usage: %s %s { <interface> | all | interfaces } [public-key | private-key | listen-port | fwmark | peers | preshared-keys | endpoints | allowed-ips | latest-handshakes | transfer | persistent-keepalive | dump | jc | jmin | jmax | s1 | s2 | s3 | s4 | h1 | h2 | h3 | h4 | i1 | i2 | i3 | i4 | i5 | j1 | j2 | j3 | itime]\n", PROG_NAME, COMMAND_NAME);
|
||||
}
|
||||
|
||||
static void pretty_print(struct wgdevice *device)
|
||||
|
@ -306,6 +306,8 @@ static void dump_print(struct wgdevice *device, bool with_interface)
|
|||
printf("%u\t", device->junk_packet_max_size);
|
||||
printf("%u\t", device->init_packet_junk_size);
|
||||
printf("%u\t", device->response_packet_junk_size);
|
||||
printf("%u\t", device->cookie_reply_packet_junk_size);
|
||||
printf("%u\t", device->transport_packet_junk_size);
|
||||
printf("%u\t", device->init_packet_magic_header);
|
||||
printf("%u\t", device->response_packet_magic_header);
|
||||
printf("%u\t", device->underload_packet_magic_header);
|
||||
|
@ -391,6 +393,14 @@ static bool ugly_print(struct wgdevice *device, const char *param, bool with_int
|
|||
if (with_interface)
|
||||
printf("%s\t", device->name);
|
||||
printf("%u\n", device->response_packet_junk_size);
|
||||
} else if(!strcmp(param, "s3")) {
|
||||
if (with_interface)
|
||||
printf("%s\t", device->name);
|
||||
printf("%u\n", device->cookie_reply_packet_junk_size);
|
||||
} else if(!strcmp(param, "s4")) {
|
||||
if (with_interface)
|
||||
printf("%s\t", device->name);
|
||||
printf("%u\n", device->transport_packet_junk_size);
|
||||
} else if(!strcmp(param, "h1")) {
|
||||
if (with_interface)
|
||||
printf("%s\t", device->name);
|
||||
|
|
|
@ -1271,6 +1271,10 @@ static void parse_options(char **iface, char **config, unsigned int *mtu, char *
|
|||
is_asecurity_on = true;
|
||||
} else if (!strncasecmp(clean, "S2=", 3) && j > 4) {
|
||||
is_asecurity_on = true;
|
||||
} else if (!strncasecmp(clean, "S3=", 3) && j > 4) {
|
||||
is_asecurity_on = true;
|
||||
} else if (!strncasecmp(clean, "S4=", 3) && j > 4) {
|
||||
is_asecurity_on = true;
|
||||
} else if (!strncasecmp(clean, "H1=", 3) && j > 4) {
|
||||
is_asecurity_on = true;
|
||||
} else if (!strncasecmp(clean, "H2=", 3) && j > 4) {
|
||||
|
|
Loading…
Add table
Reference in a new issue