Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T4930: Allow WireGuard peers via DNS hostname #4200

Merged
merged 9 commits into from
Jan 24, 2025
4 changes: 4 additions & 0 deletions debian/vyos-1x.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,7 @@ update-alternatives --set regulatory.db /lib/firmware/regulatory.db-upstream
if systemctl is-active --quiet vyos-configd; then
systemctl restart vyos-configd
fi
# Restart vyos-domain-resolver if running
if systemctl is-active --quiet vyos-domain-resolver; then
systemctl restart vyos-domain-resolver
fi
25 changes: 25 additions & 0 deletions interface-definitions/interfaces_wireguard.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@
</properties>
<defaultValue>0</defaultValue>
</leafNode>
<leafNode name="max-dns-retry">
<properties>
<help>DNS retries when resolve fails</help>
<valueHelp>
<format>u32:1-15</format>
<description>Maximum number of retries</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-15"/>
</constraint>
</properties>
<defaultValue>3</defaultValue>
</leafNode>
<leafNode name="private-key">
<properties>
<help>Base64 encoded private key</help>
Expand Down Expand Up @@ -104,6 +117,18 @@
</constraint>
</properties>
</leafNode>
<leafNode name="host-name">
<properties>
<help>Hostname of tunnel endpoint</help>
<valueHelp>
sskaje marked this conversation as resolved.
Show resolved Hide resolved
<format>hostname</format>
<description>FQDN of WireGuard endpoint</description>
</valueHelp>
<constraint>
<validator name="fqdn"/>
</constraint>
</properties>
</leafNode>
#include <include/port-number.xml.i>
<leafNode name="persistent-keepalive">
<properties>
Expand Down
34 changes: 34 additions & 0 deletions op-mode-definitions/reset-wireguard.xml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0"?>
<interfaceDefinition>
<node name="reset">
<children>
<node name="wireguard">
<properties>
<help>Reset WireGuard Peers</help>
</properties>
<children>
<tagNode name="interface">
<properties>
<help>WireGuard interface name</help>
<completionHelp>
<path>interfaces wireguard</path>
</completionHelp>
</properties>
<command>sudo ${vyos_op_scripts_dir}/reset_wireguard.py reset_peer --interface="$4"</command>
<children>
<tagNode name="peer">
<properties>
<help>WireGuard peer name</help>
<completionHelp>
<path>interfaces wireguard ${COMP_WORDS[3]} peer</path>
</completionHelp>
</properties>
<command>sudo ${vyos_op_scripts_dir}/reset_wireguard.py reset_peer --interface="$4" --peer="$6"</command>
</tagNode>
</children>
</tagNode>
</children>
</node>
</children>
</node>
</interfaceDefinition>
9 changes: 6 additions & 3 deletions python/vyos/configquery.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021-2024 VyOS maintainers and contributors <[email protected]>
# Copyright 2021-2025 VyOS maintainers and contributors <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -120,11 +120,14 @@ def list_nodes(self, path: list):

def get_config_dict(self, path=[], effective=False, key_mangling=None,
get_first_key=False, no_multi_convert=False,
no_tag_node_value_mangle=False):
no_tag_node_value_mangle=False, with_defaults=False,
with_recursive_defaults=False):
return self.config.get_config_dict(path, effective=effective,
key_mangling=key_mangling, get_first_key=get_first_key,
no_multi_convert=no_multi_convert,
no_tag_node_value_mangle=no_tag_node_value_mangle)
no_tag_node_value_mangle=no_tag_node_value_mangle,
with_defaults=with_defaults,
with_recursive_defaults=with_recursive_defaults)

class VbashOpRun(GenericOpRun):
def __init__(self):
Expand Down
4 changes: 2 additions & 2 deletions python/vyos/ifconfig/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _debug_msg (self, message):
def _popen(self, command):
return popen(command, self.debug)

def _cmd(self, command):
def _cmd(self, command, env=None):
import re
if 'netns' in self.config:
# This command must be executed from default netns 'ip link set dev X netns X'
Expand All @@ -61,7 +61,7 @@ def _cmd(self, command):
command = command
else:
command = f'ip netns exec {self.config["netns"]} {command}'
return cmd(command, self.debug)
return cmd(command, self.debug, env=env)

def _get_command(self, config, name):
"""
Expand Down
Loading
Loading