From 5150b2890ec6a38dbeae2e105fce6855ce0f589e Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 26 Aug 2018 16:55:49 +0200 Subject: tftp_server.py: fix indention and add more verbose comments --- src/conf_mode/tftp_server.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/conf_mode') diff --git a/src/conf_mode/tftp_server.py b/src/conf_mode/tftp_server.py index 8133ed215..8665f2964 100755 --- a/src/conf_mode/tftp_server.py +++ b/src/conf_mode/tftp_server.py @@ -59,12 +59,15 @@ default_config_data = { # Verify if an IP address is assigned to any interface, IPv4 and IPv6 def addrok(ipaddr, ipversion): + # For every available interface on this system for interface in netifaces.interfaces(): - # Retrieve IP address of network interfaces - if ipversion in netifaces.ifaddresses(interface).keys(): - for addr in netifaces.ifaddresses(interface)[ipversion]: - if addr['addr'] == ipaddr: - return True + # If it has any IPv4 or IPv6 address (depending on ipversion) configured + if ipversion in netifaces.ifaddresses(interface).keys(): + # For every configured IP address + for addr in netifaces.ifaddresses(interface)[ipversion]: + # Check if it matches to the address requested + if addr['addr'] == ipaddr: + return True return False -- cgit v1.2.3