From 4b28f8cfe5860d426840383ce63130ac15eb14e0 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Mar 2026 12:27:29 +0000 Subject: [PATCH] Auto-set WG peer DNS profile from selected VLAN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - DNS profile no longer hardcoded to "house" - When selecting a single VLAN for a WG peer, auto-sets the DNS profile to that VLAN's name (e.g. select "Staff" VLAN → profile becomes "staff") - Multiple VLANs: keeps current profile, user can change manually - Input shows context: auto-set vs manual vs needs VLAN selection - Profile name matches ctrld upstream names so the correct ControlD profile applies to VPN DNS queries https://claude.ai/code/session_01Do9bsN39MTuy2GVv7yzSrE --- ers5952-manager.jsx | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/ers5952-manager.jsx b/ers5952-manager.jsx index 977f648..6545996 100644 --- a/ers5952-manager.jsx +++ b/ers5952-manager.jsx @@ -2208,7 +2208,7 @@ function WireGuardTab({ session, onNeedAuth, backendOk, vlans = [] }) { }); const [opnPeerName, setOpnPeerName] = useState(''); const [opnVlans, setOpnVlans] = useState([]); // checked VLAN IDs - const [opnDnsProfile, setOpnDnsProfile] = useState('house'); // ControlD profile for VPN clients + const [opnDnsProfile, setOpnDnsProfile] = useState(''); // ControlD profile for VPN clients — auto-set from VLAN const [opnAdding, setOpnAdding] = useState(false); const [opnQr, setOpnQr] = useState(null); // { config, name } @@ -2288,7 +2288,16 @@ function WireGuardTab({ session, onNeedAuth, backendOk, vlans = [] }) { }; const opnToggleVlan = (vid) => { - setOpnVlans(prev => prev.includes(vid) ? prev.filter(v=>v!==vid) : [...prev, vid]); + const next = opnVlans.includes(vid) ? opnVlans.filter(v=>v!==vid) : [...opnVlans, vid]; + setOpnVlans(next); + // Auto-set DNS profile from the VLAN (when single VLAN selected) + if (next.length === 1) { + const v = vlans.find(x => x.id === next[0]); + if (v) setOpnDnsProfile(v.name.toLowerCase()); + } else if (next.length === 0) { + setOpnDnsProfile(''); + } + // When multiple VLANs selected, keep whatever profile is set }; const opnAddPeer = async () => { @@ -2795,15 +2804,19 @@ function OPNsenseWGSection({
-
- +
+ setOpnDnsProfile(e.target.value)} - placeholder="house"/> + placeholder="auto-set from VLAN, or type a profile name"/>
- VPN clients use OPNsense DNS → Unbound → ctrld → ControlD. - This profile applies to the WireGuard tunnel subnet. + {opnVlans.length === 1 + ? `Auto-set to "${opnDnsProfile}" from selected VLAN. Change if needed.` + : opnVlans.length > 1 + ? "Multiple VLANs selected — set the profile manually." + : "Select a VLAN above to auto-fill, or type a ControlD profile name."} + {" "}VPN clients use OPNsense DNS → Unbound → ctrld → ControlD.