feature: Support use of FQDN resolution with DNS and mDNS - #1760
Conversation
16c499c to
b676386
Compare
|
Need to add:
|
|
Thanks a lot for this pr. I really appreciate all the work you have done in the last days/weeks! Some general issues i found accross this pr is the formatting for go files. All indentation is done with 2 spaces. You can use go's build in formattor called cd backend/
go fmt ./...Which will format all files automatically. Depending on your editor you can enable Also using I've left comments on all the parts where I'd make changes. I have not yet tested the implementation (just quickly changed the IP from my pi to Regarding the feedback you requested:
How do we handle changes in interfaces? When we store nics in the database and those nics become unavailable (new host or other network card) it will cause issues.
I've tested this a couple days back and resolution failed on timeouts below 100ms on my local network. I think setting it to 1-2 seconds should be plenty. Again, thank you for your work :) |
|
I will take care of all the formatting and try
We can identify the interface by the IP assigned to the host/server itself, so the optional input field on the form would take an IP. Or we can just leave it at broadcasting on all interfaces, but the OCD in me doesn't like the idea of sending so many packets out at once unnecessarily. BUT from what I can tell from Googling, there is 0 harm in keeping it this way. Packets are very small, and the occurrences of this (when a WOL is triggered) is rare.
Great! I'll set the context timeout to 2 then.
❤️ |
RFC 6762 says |
|
@seriousm4x Earlier in the other thread we spoke about mDNS queries flooding the network but I realized I made an oversight in my calculations. With 13 devices that are powered on, responses are going to be cached for the TTL (80% of 120 secs) which mitigates the spam factor a bit. However, if all the devices are powered off, there is nothing to cache and UpSnap will send out 260 mDNS queries per minute, which is a pretty high number. Any ideas on how to better handle when devices are off? |
We could save the last known ip address and ping that. When a device is offline, we could only do an mdns request every x ping. Ip leases don't change that often so it's quite likely that once the device comes back up it will get the same ip. So only quering mdns every x ping would reduce the amount of queries. |
In my experience, that varies a lot, depending on the network configuration and how many devices are joining/leaving the network. The longer the device is powered off, the greater the likelihood its IP will be handed out by the DHCP server to some other random device that needs an IP. In a busy network, it can happen very quickly. Example: I manage a family member's network in his coffee shop, and that is high traffic, high turnover for DHCP, so IPs get reassigned very, very quickly. But even if I were to save the previous IP and continue using that when it goes offline, if/when the IP were to get reassigned to another device, then we're just stuck in the same boat again with flooding queries trying to get the new IP. I'm going to keep thinking about a way to fix this. I've made the other changes discussed above, but am going to hold off on pushing the update. |
|
Still being worked on. Noticed some sort of memory leak and I'm not sure why it's happening. Checking to see if it's related to any changes from this PR. The test instance of Docker UpSnap starts with 1 device configured and using about 40-60MB but over the course of several days of idling it has ballooned to 928MB. My test device has no wake or shutdown crons configured either. |
Signed-off-by: invario <67800603+invario@users.noreply.github.com>
|
I've rebased to the latest |
- refactored lots of the new code and fixed errors - added validation functions into `validate.go` to handle unicode FQDN and punycode - fixed memory leak from not closing avahi server connection by establishing permanent connection - updated regex used in on device form and PB validation pattern to accept international unicode FQDN or IPv4 addresses - updated regex used for netmask validation on form - timeout mDNS queries after 2 seconds Signed-off-by: invario <67800603+invario@users.noreply.github.com>
b676386 to
23215aa
Compare
|
Latest push does the following:
I haven't done anything new to mitigate the potential network flooding problem that would occur if someone has a lot of devices all offline and using |
Signed-off-by: invario <67800603+invario@users.noreply.github.com>
|
Thanks! I will have a look in the next days when I have time 👍🏼 |
|
Something I completely overlooked: I'm going to have to go through the newly added code from the IP tracking feature since the edit: Completed on the frontend and pushed. But need to add a check somewhere in the backend in case a FQDN slips into the field somehow. edit2: Good news, I tested it by forcing a FQDN into the field and IP tracking logs an error (as it should.) |
Signed-off-by: invario <67800603+invario@users.noreply.github.com>
597a116 to
f7155ea
Compare
Signed-off-by: invario <67800603+invario@users.noreply.github.com>
8ac4a15 to
34502d3
Compare
|
So, I've tested this PR on my local Mac. Seems to work so far. I just added 3 small fixes:
Will merge and push a beta so I can test it on Windows and Linux as well. Thank you :) |
|
Excellent! I look forward to hearing back from you (and others) with good or bad results! In the meantime, I'm going to draw up some notes to add to the readme or Wiki indicating that a static IP address is really the way to go and that FQDN resolution via mDNS should be used sparingly. FQDN using actual DNS resolution shouldn't have any problems at all. |
|
Just a heads up: I had removed 255.255.255.255 for a reason, but it's been so long I can't remember why anymore apart from my note above:
I don't remember if it results in an error and that's why I took it out. |
I see. Removed it again. I thought is was gone by accident and couldn't remember any reason not to send. So far I've tested the beta on Mac/arm64, Windows/amd64 and Linux/amd64 and found no issues. Hostnames resolved everywhere without issues. I think I will push a release in the next hours. |
Resolves: #1753
Submitting as a DRAFT since it is still being worked on:
ResolveToIPAddrfunction that takes one string parameter - either FQDN or IP.net.DefaultResolveris made.net.DefaultResolverwill perform both a DNS and mNDS lookup.ResolveToIPAddrand added valid actions if the IP string is""wakeUDPno longer sends 6 packets for WOL..localname cannot be resolved via mDNS, and as a result there is no IP address. Without an IP address of the device, we cannot send a unicast (routed) packet, and we also cannot determine the broadcast address. Broadcasting to 255.255.255.255 does not work (reliably) because the OS will send the packet to either the default network interface, or the one with the lowest metric (behavior varies depending on the OS.).localdevice,wakeUDPwill send (2) WOL packets (ports 7 and 9) to every interface (except loopback, non-broadcast capable, and inactive/down).To Do/Need Feedback:
Interfacethat would allow specifying the local/host interface for broadcasting the WOL packet.