use sorted when iterating over network interfaces

this helps for unneeded rewrites if dhcpd.conf
This commit is contained in:
l_samenv
2024-03-20 13:25:37 +01:00
parent 5dc4f8a984
commit 4bed174abd
2 changed files with 1 additions and 2 deletions

View File

@ -17,7 +17,6 @@ import re
import types import types
import socket import socket
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from glob import glob
from ipaddress import IPv4Interface from ipaddress import IPv4Interface
from configparser import ConfigParser from configparser import ConfigParser
from os.path import join, getmtime, exists, basename from os.path import join, getmtime, exists, basename

View File

@ -32,7 +32,7 @@ class BoxInfo:
self.config = None self.config = None
self.macaddr = {} self.macaddr = {}
self.main_if = None self.main_if = None
for ifdev in glob('/sys/class/net/*/address'): for ifdev in sorted(glob('/sys/class/net/*/address')):
ifname = ifdev.split('/')[-2] ifname = ifdev.split('/')[-2]
if ifname == 'lo': # do not consider loopback interface if ifname == 'lo': # do not consider loopback interface
continue continue