ahodges9 / LedFx

LedFx is a network based LED effect controller with support for advanced real-time audio effects! LedFx can control multiple devices and works great with cheap ESP8266 nodes allowing for cost effectvice syncronized effects across your entire house!
MIT License
384 stars 91 forks source link

Revert "auto-detect ip" and add default host #70

Closed KF5JWC closed 4 years ago

KF5JWC commented 4 years ago

This reverts commit d7f07be888f5f97d237e11bdbaecf6d4fff5eb3e and adds a default for host.

When a lookup occurs for $hostname on my machine, ledfx crashes. I do not keep the hostname of my machine in /etc/hosts nor in DNS fed by DHCP leases.

Traceback (most recent call last):
  File "~/.local/bin/ledfx", line 8, in <module>
    sys.exit(main())
  File "~/.local/lib/python3.7/site-packages/ledfx/__main__.py", line 88, in main
    ledfx = LedFxCore(config_dir = args.config)
  File "~/.local/lib/python3.7/site-packages/ledfx/core.py", line 42, in __init__
    port=port)
  File "~/.local/lib/python3.7/site-packages/ledfx/http.py", line 26, in __init__
    host = socket.gethostbyname(socket.gethostname())
socket.gaierror: [Errno -2] Name or service not known

This change will resolve an inconsistency in behavior.

While the vast majority of cases resolve $hostname to 127.0.0.1, this may resolve to the DHCP address or not at all, instead, if /etc/hosts and the local resolver are set up just right.

Defaulting to 127.0.0.1 seems like the intended behavior, coincident with how binding to $hostname normally works, and is consistent with the previous behavior, too. If the intended behavior is to be available on an IP of the machine by default, a default of 0.0.0.0 would be more appropriate.