int dns_srv_get(char *domain, size_t dsize, struct sa *srvv, uint32_t *n) { int err; /* Try them all in prioritized order */ #ifdef HAVE_LIBRESOLV err = get_resolv_dns(domain, dsize, srvv, n); if (!err) return 0; #endif #ifdef DARWIN err = get_darwin_dns(domain, dsize, srvv, n); if (!err) return 0; #endif err = parse_resolv_conf(domain, dsize, srvv, n); if (!err) return 0; #ifdef WIN32 err = get_windns(domain, dsize, srvv, n); #endif #ifdef __SYMBIAN32__ err = get_symbiandns(srvv, n); #endif return err; }
int main(int argc, char *argv[]) { if (argc == 1) parse_config("dns_proxy.conf"); else if (argc == 2) { if (!strcmp(argv[1], "-h")) { printf("Usage: %s [options]\n", argv[0]); printf(" * With no parameters, the configuration file is read from 'dns_proxy.conf'.\n\n"); printf(" -n -- No configuration file (socks: 127.0.0.1:9999, listener: 0.0.0.0:53).\n"); printf(" -h -- Print this message and exit.\n"); printf(" config_file -- Read from specified configuration file.\n\n"); printf(" * The configuration file should contain any of the following options (and ignores lines that begin with '#'):\n"); printf(" * socks_addr -- socks listener address\n"); printf(" * socks_port -- socks listener port\n"); printf(" * listen_addr -- address for the dns proxy to listen on\n"); printf(" * listen_port -- port for the dns proxy to listen on (most cases 53)\n"); printf(" * resolv_conf -- location of resolv.conf to read from\n"); printf(" * log_file -- location to log server IPs to. (only necessary for debugging)\n\n"); printf(" * Configuration directives should be of the format:\n"); printf(" option = value\n\n"); printf(" * Any non-specified options will be set to their defaults:\n"); printf(" * socks_addr = 127.0.0.1\n"); printf(" * socks_port = 9050\n"); printf(" * listen_addr = 0.0.0.0\n"); printf(" * listen_port = 53\n"); printf(" * resolv_conf = resolv.conf\n"); printf(" * log_file = /dev/null\n"); exit(0); } else { parse_config(argv[1]); } } // if (getuid() != 0) { // printf("Error: this program must be run as root! Quitting\n"); // exit(1); // } printf("[*] Listening on: %s:%d\n", LISTEN_ADDR, LISTEN_PORT); printf("[*] Using SOCKS proxy: %s:%d\n", SOCKS_ADDR, SOCKS_PORT); parse_resolv_conf(); printf("[*] Loaded %d DNS servers from %s.\n\n", NUM_DNS, RESOLVCONF); // start the dns proxy udp_listener(); exit(EXIT_SUCCESS); }