Auto-set WG peer DNS profile from selected VLAN
- 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
This commit is contained in:
+20
-7
@@ -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({
|
||||
</div>
|
||||
|
||||
<div style={{marginTop:10}}>
|
||||
<div className="field" style={{margin:0,maxWidth:260}}>
|
||||
<label>ControlD DNS Profile (applied via ctrld)</label>
|
||||
<div className="field" style={{margin:0,maxWidth:300}}>
|
||||
<label>ControlD DNS Profile</label>
|
||||
<input value={opnDnsProfile}
|
||||
onChange={e=>setOpnDnsProfile(e.target.value)}
|
||||
placeholder="house"/>
|
||||
placeholder="auto-set from VLAN, or type a profile name"/>
|
||||
</div>
|
||||
<div style={{fontSize:11,color:"var(--dm)",marginTop:4}}>
|
||||
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.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user