-
Notifications
You must be signed in to change notification settings - Fork 61
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 DNSServerLookupMechanism to specify ports for the servers #82
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially MiniDNS's DNSServerLookupMechanism
was designed with the information retrieved from typical system's DNS settings (think of e.g. /etc/resolv.conf
). Those just return IP addresses, and nothing more.
I'm hesitantly to change this right now without a good reason or motivation. I'm not saying that we shouldn't do something like this in the future. But then we should go the full way through and hve DNSServerLokupMechanism return a DnsServer
type (akin to your UpstreamDnsServer class), which includes not only the IP and port, but also the servers capabilities (if available). Capabilities could be
- unknown
- traditional DNS
- DNS over TLS
* All redistributions of this software in source code must retain this copyright header | ||
* All redistributions of this software in binary form must visibly inform users about usage of this software | ||
* <p> | ||
* development@frostnerd.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this added by accident? If so, please remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it was. I'm removing it.
@@ -29,6 +29,6 @@ | |||
* | |||
* @return a List of Strings presenting hopefully IP addresses. | |||
*/ | |||
public List<String> getDnsServerAddresses(); | |||
public List<IPPortPair> getDnsServerAddressesWithPorts(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to rename the method, just changing the return type is fine.
Using non-default ports is pretty rare. My initial thought was to add support for non-default ports without breaking too much existing stuff. If this doesn't get merged (and is done properly some time in the future) I'm totally fine with it as I can just use my fork. I've changed the reviewed parts. The copyright header was auto-generated by Android studio and slipped through my sight. |
I merged everything into this PR. If wanted/needed I can integrate the suggested changes regarding server capabilities as well, but that'd require more changes as DNS over TLS (or other capabilities as DNS over HTTPS) most of the time isn't wanted as it increases traffic by a lot - there'd need to be some sort of input from the developer then if those capabilities should be used |
I'm in support of having alternative port support. This is something we use to get around wireless carriers who like to intercept dns and redirect to their own servers (transparent dns proxying at the carrier level) |
As far as I can see there currently is no way to alter the port a query is sent to when using ResolverAPI or DnssecResolverApi. This would be possible if DNSServerLookupMechanism specified ports for the servers.
As this is a breaking change for projects using
DNSServerLookupMechanism
orAbstractDNSServerLookupMechanism
it might be useful to keep the oldgetDnsServerAddresses()
insideAbstractDNSServerLookupMechanism
and mark it as deprecated, returning an empty list by default. A possible alteration could look like this:This however would break the concept of abstract classes as you would no longer be forced to implement getDnsServerAddressesWithPorts() in a subclass - that's why it isn't included in this commit.
Another way could be using REGEX to parse strings returned with
getDnsServerAddresses()
, extract possible ports from them (or fallback to 53) and return these for getDnsServerAddressesWithPorts by default.