Open K2IE opened 3 years ago
For later reference:
config.py
assumes that IP addresses are IPv4 and uses socket.gethostbyname() in order to resolve hostnames to IP addresses (but which only resolves to IPv4 addresses). IPv6 addresses put into the config file end up causing an error message:
Traceback (most recent call last):
File "bridge.py", line 747, in <module>
CONFIG = config.build_config(cli_args.CONFIG_FILE)
File "/opt/hblink3/config.py", line 274, in build_config
'TARGET_SOCK': (gethostbyname(config.get(section, 'TARGET_IP')), config.getint(section, 'TARGET_PORT')),
socket.gaierror: [Errno -9] Address family for hostname not supported
The likeliest approach is to use socket.getaddrinfo() which will resolve to a list of IP addresses (and ports, which are also required as part of the method) that meet the criteria given in the method call. Trouble is that using getaddrinfo() is not even close to a drop-in replacement for gethostbyname(), so there is some work to do here.
It's also worth noting that this is a lot of duplicated code. I'd like to start factoring this out into private methods or at least function calls that provide one place to make fixes, so that we're not doing find/replace all day long when discovering problems like this.
@randybuildsthings said in an HBlink message thread:
"We're using socket.gethostbyname() which only supports IPv4. We'll have to change that."
For context see https://dvswitch.groups.io/g/HBlink/topic/81430483