-
Notifications
You must be signed in to change notification settings - Fork 279
Use cloudflare DNS for session server IP lookup #1010
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
Conversation
Nice find, but is it possible to use the system's configured DNS server? I don't believe we should be ignoring what is configured in the system. Alternatively, if it's not possible to use the system's configured DNS, we should change these to be configurable rather than hardcoding defaults to a single provider that, for one reason or another, someone may object to. |
Will address that as soon as i got time again (hopefully tomorrow). It seems like // Using jndi-dns to obtain the default name servers.
//
// See:
// - http://docs.oracle.com/javase/8/docs/technotes/guides/jndi/jndi-dns.html
// - http://mail.openjdk.java.net/pipermail/net-dev/2017-March/010695.html
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory");
env.put("java.naming.provider.url", "dns://");
try {
DirContext ctx = new InitialDirContext(env);
String dnsUrls = (String) ctx.getEnvironment().get("java.naming.provider.url");
// Only try if not empty as otherwise we will produce an exception
if (dnsUrls != null && !dnsUrls.isEmpty()) {
String[] servers = dnsUrls.split(" "); But this raises the question why it wouldn't be able to resolve the session servers: |
The docs suggest otherwise. |
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.
I would recommend using a MultiDnsServerAddressStreamProvider
collection of the following:
SequentialDnsServerAddressStreamProvider
initialized fromglowstone.yml
optional user overrides.UnixResolverDnsServerAddressStreamProvider
to attempt to use the system DNS servers on Linux.SequentialDnsServerAddressStreamProvider
of1.1.1.1
,1.0.0.1
,8.8.8.8
,8.8.4.4
.
Appearantly, I was able to reach the sessionserver both with using cloudflare and google dns servers... The error seems to be the java excerpt I posted above. I looked into the matter and there is literally no way of solving the issue on Window using pure Java. If we decide it to be worth the effort I could write a C lib and do some JNI magic... However I'm not familiar with Maven at all and don't know how I tell Maven to compile this mess. |
That can be done later, but for now, I think what I proposed above is fine. |
Superseded by d486808. |
This PR fixes an issue where the client would be kicked with the message: internal error during login. The server complains about not being able to reach the mojang session server, failing with a timeout exception. This is because netty's
DefaultDnsServerAddressStreamProvider
which uses Googles DNS servers (8.8.8.8 and 8.8.4.4) for IP lookup. This PR changes the DNS servers tou cloudflare's (1.1.1.1) thus resolving the issue.This has been tested many times (it was frustrating to not be able to play on my server for 2 months now) and is proven to solve my issue (Thanks for your fast support on Discord, that really helped :D)