Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow adjusting DNS Cache Timeout #22267

Open
calumapplepie opened this issue Feb 10, 2025 · 4 comments
Open

Allow adjusting DNS Cache Timeout #22267

calumapplepie opened this issue Feb 10, 2025 · 4 comments

Comments

@calumapplepie
Copy link

Suggestion

Libtorrent exposes a method to change the timeout of it's internal DNS cache. This internal cache is very important, but has some issues; it doesn't reset in some cases. Allowing the value of cache timeout to be tweaked by the user would fix these issues. I think this might be as simple as calling void resolver::set_cache_timeout(seconds const timeout), but I'm not clear enough on the qBittorrent/libtorrent interface to implement it myself.

This is possibly related to the request for improving the DNDS cache generally, but my request is much more specific, and easier to implement.

Use case

I run qbittorrent on my laptop, which uses systemd-resolved as the DNS provider. This is great, but when I first wake my computer from hibernation or sleep, qbittorrent attempts to refresh tracker information before a network connection is established. Thus, the DNS resolver returns "host not found (non-authoritative)", since there are no DNS servers for it to contact. That would be fine, except that the libtorrent DNS cache retains all those failed querys; so when the qBittorrent automatically reannounces a minute or two later, it still sees all those failed DNS entries. In fact, even repeated force reannounces will fail for the next 20-odd minutes; only a qBittorrent restart clears the cache.

I'm sure there are other solutions, but I think this is the easiest all-around. Clearing the cache on a force reannounce might be another solution. For my system, I would set this timeout to a very low value, and just rely on systemd-resolved for a cache.

Extra info/examples/attachments

Imagine a screenshot with a boatload of torrents, all showing 'host not found (non-authoritative)' for every single one of their trackers. Or a short video showing how force-reannounces don't propagate the DNS lookups to the system DNS server.

@glassez
Copy link
Member

glassez commented Feb 11, 2025

Libtorrent exposes a method to change the timeout of it's internal DNS cache.

It looks like this is possible via the resolver_cache_timeout setting.
But I doubt that this can be considered as a solution to the problem (maybe as a workaround).

@glassez
Copy link
Member

glassez commented Feb 11, 2025

@arvidn
Does libtorrent try to somehow handle the case of computer standby/hibernation? It seems that some subsystems are in an inconsistent state after waking up.

@calumapplepie
Copy link
Author

It looks like this is possible via the resolver_cache_timeout setting.
But I doubt that this can be considered as a solution to the problem (maybe as a workaround).

If what I suspect is true, and the problem only occurs when you are using a system-local DNS resolver which will return 'NXDOMAIN' if you send it requests while it is still negotiating an internet connection, then it might just be a valid solution. After all, such a resolver would almost certainly support caching. Indeed, the problem is probably even more specific; only systems which are on networks which require more than a WPA PSK handshake to be authenticated to.

Problem is, I can't figure out how to set that setting for qBittorrent.

@glassez
Copy link
Member

glassez commented Feb 12, 2025

Problem is, I can't figure out how to set that setting for qBittorrent.

AFAIK, qBittorrent doesn't expose such a setting currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants