Fix network interface detection in AutoInstaller GUI

- Fixed invalid regex pattern 'e(n|th)' in ethernet interface detection
- Changed to proper string matching ': e' for ethernet interfaces starting with 'e'
- Improved wireless interface detection with fallback to ip link for wlan interfaces
- Added proper interface name parsing to handle @ suffixes and extract clean names
- Enhanced error handling for both iw and ip commands
- Network interface detection should now work correctly on various systems

This resolves the issue where the GUI failed to detect network interfaces
due to incorrect string matching patterns in the detection logic.
parent 5d8d8e77
......@@ -179,23 +179,40 @@ class NetworkInterfaceDialog(QDialog):
result = subprocess.run(['ip', 'link', 'show'], capture_output=True, text=True, check=True)
ethernet_interfaces = []
for line in result.stdout.split('\n'):
if 'e(n|th)' in line and 'state' in line:
# Look for lines like: "2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP"
if ': e' in line and ('state' in line or '<' in line):
parts = line.split(':')
if len(parts) >= 2:
iface = parts[1].strip()
ethernet_interfaces.append(iface)
# Extract just the interface name (remove @ suffix if present)
iface = iface.split('@')[0].split()[0]
if iface.startswith('e') and iface not in ethernet_interfaces:
ethernet_interfaces.append(iface)
# Get wireless interfaces
wireless_interfaces = []
try:
result = subprocess.run(['iw', 'dev'], capture_output=True, text=True, check=True)
current_iface = None
for line in result.stdout.split('\n'):
if 'Interface' in line:
line = line.strip()
if line.startswith('Interface'):
parts = line.split()
if len(parts) >= 2:
wireless_interfaces.append(parts[1])
current_iface = parts[1]
elif line.startswith('type') and current_iface:
if 'managed' in line or 'AP' in line:
wireless_interfaces.append(current_iface)
current_iface = None
except subprocess.CalledProcessError:
pass # iw not available
# Fallback: try to detect wlan interfaces from ip link
for line in result.stdout.split('\n'):
if ': w' in line and ('state' in line or '<' in line):
parts = line.split(':')
if len(parts) >= 2:
iface = parts[1].strip().split()[0]
if iface.startswith('w') and iface not in wireless_interfaces:
wireless_interfaces.append(iface)
# Add to list
for iface in ethernet_interfaces:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment