richonguzman / LoRa_APRS_iGate

LoRa APRS iGATE for ESP32 Based Board with Rx + Tx capabilities
MIT License
208 stars 65 forks source link

Set client hostname same as callsign. #167

Closed S57PNX closed 3 weeks ago

S57PNX commented 4 weeks ago

This changes the client hostname from ESP32-XXXXXX to Callsign. The idea is to make DHCP server log less confusing, as on a big network it can have many ESP32-XXXXXX entries.

Developed and tested together with S54B.

richonguzman commented 4 weeks ago

white space is correct in the commit?

S57PNX commented 4 weeks ago

What do you mean? The indentation with tabs is correct.

richonguzman commented 4 weeks ago

after WiFi.setHostName is a whitespace in the commit info, that's all

S57PNX commented 4 weeks ago

Ah I didn't see it, thanks for spotting. It compiles correctly, even though it is better to remove the whitespace, you're correct.

richonguzman commented 4 weeks ago

just to understand it completely:

if (Config.callsign.length() > 0) { WiFi.mode(WIFI_MODE_NULL); WiFi.setHostname(Config.callsign.c_str()); }

1) why this validate length? as it should be NOCALL or NOCALL-10 by default , or is this to avoid having " " saved?

2) WiFi.mode(WIFI_MODE_NULL); is set at Wifi AP start, why again?

3) WiFi.setHostname(Config.callsign.c_str()); can you explain me more about what or where does it appear to be changed? when other see them in the net or router?

S57PNX commented 4 weeks ago
  1. is a precaution, to avoid setting hostname to "" for any reason. If you are confident that it is impossible to have empty callsign, this check can be removed.

  2. expressif library is very problematic to accept setHostname call, because it only changes a string in memory and the name change only happens after wifi mode changes - if the card is already in station mode, the call will succeed but the hostname will not change. It is requred to change the mode after setHostname, so I though it is better to put it to MODE_NULL so we have a clean change to MODE_STA. Since we are doing this immediately after reboot so I am sure the card is not in Station mode, but again it is here as a precaution since it doesn't hurt. See https://github.com/esp8266/Arduino/discussions/8816#discussioncomment-4751623

  3. I see this change in DHCP request (visible in wireshark) and in the DHCP server logs. People will see that on the router, in wifi network management and other network tools. But this does not impact mDNS so you still need to access the device by IP address in the browser.

  4. if desired, I can also prepare a mDNS functionality so you can automatically access the device by http://S57PNX-10.local instead of 192.168.5.5

richonguzman commented 3 weeks ago

I avoided the initial revision as the Callsing is always validated to be "non" NULL

please test the updated Main.

S57PNX commented 3 weeks ago

The RFC standards for hostnames only allow a-z, numbers and -. Space and underscore are not allowed (as it can cause problems later on in DNS). Case is not sensitive.

I suggest to change the hostname to "IGATE-"+Config.callsign.

richonguzman commented 3 weeks ago

nice info (did not know it... updated!)

S57PNX commented 3 weeks ago

No worries, it's a standard from 1985 :) RFC952

Testing looks good here, OK to close this PR.

richonguzman commented 3 weeks ago

added to iGate