py-mine/mcstatus

Crashes if it cannot open `/etc/resolv.conf`

ShockedCoder opened this issue · 6 comments

It'd be great if there could default setting in the program or if it let you choose which to file read from.

Could you please give traceback and/or more information about the error?

In the under hood library, that we use for DNS resolving, this option already is. See this.

So you can use

import mcstatus
import dns.resolver

dns.resolver.default_resolver = dns.resolver.Resolver(configure=False)
dns.resolver.default_resolver.nameservers = ["8.8.8.8"]
server = mcstatus.JavaServer.lookup(...)

Note that if your resolv.conf doesn't work, something is really wrong. I rarely see an option for configuring custom DNS server only inside application, instead of using system ones.


P.S. Without traceback, I cannot be sure that it will help, but you can try.

Fix your system. Not an mcstatus issue.

I'm using Termux, not a Linux system.

btw, my bad for not checking Github for so long, it usually takes a few days or weeks for a response to an issue on gh

We can't support every possible OS and platform, as we have no good ways of testing whether the code works on these platforms, and there's just way too many different platforms to support. We fully support mac os, windows and linux, however if you're using anything else, you're on your own.

As @PerchunPak suggested, there is a workaround which you can use, and if you want to see a better fix for this, where the proper platform-specific solution is used to pick up the DNS servers (wherever they are on Termux), report this issue to dnspython, as mcstatus wouldn't be responsible for fixing this issue anyway. However, I kind of doubt that they will add support for Termux, for similar reason to why we won't explicitly support it.

Also, it's actually possible that Termux doesn't even have any such file/place where DNS server are defined. If that's the case, this isn't even fixable and you will have to specify the dns servers manually. If this is the case, maybe try reporting this to Termux and get them to start using resolv.conf properly.