Disabling proxies on local networks
I'm working on the networking code in F-Droid right now and have a question.
There is some code in the HttpDownloader
class which attempt to decipher whether the download is for a URL belonging to a swap repo or not. It does this by checking if the URL is:
- An IPv4 address rather than a domain name
- On a port >= 1024
- On the same subnet as the device
private boolean isSwapUrl() {
String host = sourceUrl.getHost();
return sourceUrl.getPort() > 1023 // only root can use <= 1023, so never a swap repo
&& host.matches("[0-9.]+") // host must be an IP address
&& FDroidApp.subnetInfo.isInRange(host); // on the same subnet as we are
}
If this is the case, proxies are disabled for the HTTP request.
My question is:
Does it ever make sense to enable proxies when talking between two devices on the same subnet?
To me the only time it would make sense is if the proxy was also on the same subnet.
So I have at least four options:
- Leave the code as before, but that is not quite right because it is possible to have non-swap repos on the loal network with a port > 1024.
- Check the fdroid_repo database table to see if the URL we connect to matches that of a swap repo (there is a flag in the database for whether a repo is a swap repo or not now).
- Disable proxying for all network on the same subnet
- Disable proxying for all neetwork on the same subnet except if the proxy is also on the same subnet.
Any thoughts?