mirror of
https://github.com/pyMC-dev/pyMC_Repeater.git
synced 2026-08-05 00:12:47 +02:00
Log system IP address
This commit is contained in:
@@ -2,6 +2,7 @@ import asyncio
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import socket
|
||||
|
||||
from repeater.config import get_radio_for_board, load_config
|
||||
from repeater.config_manager import ConfigManager
|
||||
@@ -52,6 +53,28 @@ class RepeaterDaemon:
|
||||
|
||||
logger.info(f"Initializing repeater: {self.config['repeater']['node_name']}")
|
||||
|
||||
#-----------------------------------------------
|
||||
# Get the actual Network IP Address
|
||||
try:
|
||||
# This looks for the IP assigned to the default hostname
|
||||
host_name = socket.gethostname()
|
||||
# We try to get the IP associated with the hostname
|
||||
self.network_ip = socket.gethostbyname(host_name)
|
||||
|
||||
# If that still gives 127.0.x.x, let's try a different internal method
|
||||
if self.network_ip.startswith("127."):
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
# We use a non-routable IP that doesn't require an actual connection
|
||||
s.connect(("10.255.255.255", 1))
|
||||
self.network_ip = s.getsockname()[0]
|
||||
s.close()
|
||||
except Exception as e:
|
||||
logger.warning(f"Could not determine network IP: {e}")
|
||||
self.network_ip = "Unknown"
|
||||
|
||||
logger.info(f"System Network IP: {self.network_ip}")
|
||||
#-----------------------------------------------
|
||||
|
||||
if self.radio is None:
|
||||
logger.info("Initializing radio hardware...")
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user