mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2025-08-03 17:54:27 +02:00
Firewall settings form and small papercuts
This commit is contained in:
parent
5f8627e3f3
commit
1de3bd132f
8 changed files with 149 additions and 11 deletions
|
@ -1,4 +1,5 @@
|
|||
import ipaddress, re
|
||||
import subprocess
|
||||
|
||||
|
||||
def is_valid_ip_or_hostname(value):
|
||||
|
@ -15,3 +16,21 @@ def is_valid_ip_or_hostname(value):
|
|||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def list_network_interfaces():
|
||||
# Executa o comando 'ip link show' com grep para filtrar linhas com 'UP'
|
||||
cmd = "ip link show | grep UP"
|
||||
cmd_output = subprocess.check_output(cmd, shell=True, text=True)
|
||||
|
||||
# Processa a saída para extrair os nomes das interfaces
|
||||
interfaces = []
|
||||
for line in cmd_output.split('\n'):
|
||||
if line: # Verifica se a linha não está vazia
|
||||
parts = line.split(': ')
|
||||
if len(parts) > 1:
|
||||
# O nome da interface está na segunda posição após o split
|
||||
interface_name = parts[1].split('@')[0] # Remove qualquer coisa após '@'
|
||||
interfaces.append(interface_name)
|
||||
|
||||
return interfaces
|
Loading…
Add table
Add a link
Reference in a new issue