From 531970d9c6c6d4ed0c7e286ba905d1b17c191816 Mon Sep 17 00:00:00 2001 From: billz Date: Wed, 1 Jan 2025 00:41:56 -0800 Subject: [PATCH] Extend wg peer endpoint validation w/ subdomain + hostname --- includes/wireguard.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/wireguard.php b/includes/wireguard.php index ed47a6e1..2cca31db 100755 --- a/includes/wireguard.php +++ b/includes/wireguard.php @@ -207,7 +207,10 @@ function SaveWireGuardConfig($status) } if (isset($_POST['wg_pendpoint']) && strlen(trim($_POST['wg_pendpoint']) >0 )) { $wg_pendpoint_seg = substr($_POST['wg_pendpoint'],0,strpos($_POST['wg_pendpoint'],':')); - if (!filter_var($wg_pendpoint_seg,FILTER_VALIDATE_IP)) { + $host_port = explode(':', $wg_pendpoint_seg); + $hostname = $host_port[0]; + if (!filter_var($hostname, FILTER_VALIDATE_IP) && + !filter_var($hostname, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) { $status->addMessage('Invalid value for endpoint address', 'danger'); $good_input = false; }