diff --git a/contact/ui/control_ui.py b/contact/ui/control_ui.py index 235655e..d4cf1fe 100644 --- a/contact/ui/control_ui.py +++ b/contact/ui/control_ui.py @@ -126,12 +126,16 @@ def display_menu() -> tuple[object, object]: if full_key.startswith("config.network.ipv4_config.") and option in {"ip", "gateway", "subnet", "dns"}: if isinstance(current_value, int): try: - current_value = str(ipaddress.IPv4Address(current_value)) + current_value = str( + ipaddress.IPv4Address(int(current_value).to_bytes(4, "little", signed=False)) + ) except ipaddress.AddressValueError: pass elif isinstance(current_value, str) and current_value.isdigit(): try: - current_value = str(ipaddress.IPv4Address(int(current_value))) + current_value = str( + ipaddress.IPv4Address(int(current_value).to_bytes(4, "little", signed=False)) + ) except ipaddress.AddressValueError: pass diff --git a/contact/utilities/input_handlers.py b/contact/utilities/input_handlers.py index edb9d7c..b75de61 100644 --- a/contact/utilities/input_handlers.py +++ b/contact/utilities/input_handlers.py @@ -462,7 +462,10 @@ from contact.utilities.singleton import menu_state # Ensure this is imported def get_fixed32_input(current_value: int) -> int: original_value = current_value - ip_string = str(ipaddress.IPv4Address(current_value)) + try: + ip_string = str(ipaddress.IPv4Address(int(current_value).to_bytes(4, "little", signed=False))) + except Exception: + ip_string = str(ipaddress.IPv4Address(current_value)) height = 10 width = get_dialog_width() start_y = max(0, (curses.LINES - height) // 2) @@ -524,7 +527,7 @@ def get_fixed32_input(current_value: int) -> int: if len(octets) == 4 and all(octet.isdigit() and 0 <= int(octet) <= 255 for octet in octets): curses.noecho() curses.curs_set(0) - return int(ipaddress.ip_address(user_input)) + return int.from_bytes(ipaddress.IPv4Address(user_input).packed, "little", signed=False) else: fixed32_win.addstr( 7,