src/ndns/platforms/resolv

Search:
Group by:
Source   Edit  

Minimal implementation to get System DNS Server (IPv4 and IPv6). This implementation is heavily influenced by glibc.

Implements a parser to capture the first nameserver in the resolver configuration file, which is, by default, /etc/resolv.conf. You can change this file by passing to compile -d:ndnsPathResConf=/etc/myresolv.conf.

Checking for changes in the ndnsPathResConf file performed at each new getSystemDnsServer() call makes the code 2x faster, if there is no change.

This implementation should work for systems that adopt resolver. Currently this implementation is imported into Linux and BSD. If your platform uses a resolver configuration file, compile with -d:ndnsUseResolver.

References:

Consts

ndnsPathResConf {.strdefine.} = "/etc/resolv.conf"
Resolver configuration file. You can change by compiling with -d:ndnsPathResConf=/etc/myresolv.conf. Source   Edit  

Procs

proc getSystemDnsServer(): string {....raises: [OSError, IOError],
                                    tags: [ReadDirEffect, ReadIOEffect],
                                    forbids: [].}
Returns the first nameserver found in the ndnsPathResConf file. Will return "" if not found. Source   Edit