zdns
zdns copied to clipboard
Windows not supported
The config line in main.go doesn't support the Windows operating system. I had to change the line to the following with a custom text file to register nameservers:
config_file := flags.String("conf-file", "c:\\Users\\Adhir\\Documents\\resolv.conf", "config file for DNS servers")
Ideally it should determine what OS you're on then select the file accordingly if possible
Perhaps it is convenient to incorporate a .conf file with default values inside the repository, and load it when the platform is Windows instead of "/etc/hosts" :thinking:
What do you think?
I think that's fine, though if there's a conf file, we'd want it to be able to handle all the options passed in on the command line. I don't think it makes sense to have a conf that only specifies the equivalent of /etc/hosts. None of the core maintainers of ZDNS use Windows, so this is something that would need an external contribution.
I do not use Windows as my main platform, but I can help by sending a pull request I think.
I'm thinking something like this:
config_file_path = "/etc/resolv.conf"
IF PLATFORM == Windows THEN
config_file_path = HOME_DIR + "\\resolv.conf.zmap"
IF path NOT EXISTS THEN
WRITE DEFAULT VALUES to HOME_DIR + "\\resolv.conf.zmap"
ENDIF
ENDIF
The default content for resolv.conf.zmap would be something like this:
nameserver 8.8.8.8
nameserver 8.8.4.4
Perhaps it would be appropriate to print a warning that the file was created with its default values.
I'm not sure if this really needs an extra conf file. We could just default to set a set of resolvers if nothing is passed in on the command line and we can't find an equivalent to /etc/resolv.conf.
There's also probably a way to just ask Windows what its resolvers are, similar to reading /etc/resolv.conf.
I do not use Windows as my main platform, but I can help by sending a pull request I think.
I'm thinking something like this:
config_file_path = "/etc/resolv.conf" IF PLATFORM == Windows THEN config_file_path = HOME_DIR + "\\resolv.conf.zmap" IF path NOT EXISTS THEN WRITE DEFAULT VALUES to HOME_DIR + "\\resolv.conf.zmap" ENDIF ENDIFThe default content for
resolv.conf.zmapwould be something like this:nameserver 8.8.8.8 nameserver 8.8.4.4Perhaps it would be appropriate to print a warning that the file was created with its default values.
var config_file_path = "/etc/resolv.conf"
if runtime.GOOS == "windows" {
// We don't have any resolv.conf in Windows
usr, err := user.Current()
if err != nil {
log.Fatal(err)
}
config_file_path = usr.HomeDir + "\\.resolv.conf.zmap"
if _, err := os.Stat(config_file_path);
os.IsNotExist(err) {
log.Warningf("Creating default configuration file for DNS servers in %s", config_file_path)
config_file_defaults := []byte("nameserver 8.8.8.8\nnameserver 8.8.4.4\n")
err := ioutil.WriteFile(config_file_path, config_file_defaults, 0644)
if err != nil {
log.Fatalf("Unable to write file (%s): %s", config_file_path, err.Error())
}
}
}
I'm not sure if this really needs an extra conf file. We could just default to set a set of resolvers if nothing is passed in on the command line and we can't find an equivalent to
/etc/resolv.conf.There's also probably a way to just ask Windows what its resolvers are, similar to reading
/etc/resolv.conf.
Good point, I will investigate a little
This would be great!
But please use the canonical Windows configuration directory NOT the user's home or documents directories - applications that cram these full of config files are super annoying as they are for documents and personal files, not configuration..
https://github.com/shibukawa/configdir is a good library for doing this cross-platform!
I believe this should be fixed in #257. Can you test and see if the problem is resolved in master?
This error has been fixed, it works on Windows
