WAN IP fix: IPv4 bevorzugen, PPPoE-Interfaces korrekt erkennen
This commit is contained in:
parent
983ecf390c
commit
5d26158b53
@ -136,12 +136,14 @@ export default function Agents() {
|
||||
: null
|
||||
const gateways = sys?.gateways || []
|
||||
|
||||
// WAN IP: prefer gateway with WAN role, fallback to interface with WAN role, fallback to a.ip
|
||||
// WAN IP: find interface with WAN role AND a valid IPv4 address
|
||||
const ifaces = sys?.network_interfaces || []
|
||||
const wanIface = ifaces.find(i => (i.role || '').toUpperCase() === 'WAN')
|
||||
const lanIface = ifaces.find(i => (i.role || '').toUpperCase() === 'LAN')
|
||||
const wanGw = gateways.find(g => (g.name || '').toUpperCase().includes('WAN'))
|
||||
const wanIp = wanIface?.ip || wanGw?.address || a.ip || ''
|
||||
const isIPv4 = (ip) => ip && /^\d+\.\d+\.\d+\.\d+/.test(ip)
|
||||
const wanIface = ifaces.find(i => (i.role || '').toUpperCase() === 'WAN' && isIPv4(i.ip))
|
||||
|| ifaces.find(i => (i.role || '').toUpperCase() === 'WAN' && i.ip)
|
||||
const lanIface = ifaces.find(i => (i.role || '').toUpperCase() === 'LAN' && isIPv4(i.ip))
|
||||
|| ifaces.find(i => (i.role || '').toUpperCase() === 'LAN' && i.ip)
|
||||
const wanIp = wanIface?.ip || a.ip || ''
|
||||
const lanIp = lanIface?.ip || ''
|
||||
|
||||
return {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user