int main (int argc, char *argv[]) { int n = 0; char *x = NULL; dns_random_init (seed); prog = strdup ((x = strrchr (argv[0], '/')) != NULL ? x + 1 : argv[0]); n = check_option (argc, argv); argv += n; argc -= n; while (*argv) { if (!ip4_scan (*argv, ip)) errx (-1, "could not parse IP address `%s'", *argv); if (dns_name4 (&out, ip) == -1) errx (-1, "could not find host name for `%s'", *argv); buffer_put (buffer_1, out.s, out.len); buffer_puts (buffer_1,"\n"); ++argv; } buffer_flush (buffer_1); return 0; }
void doit(const ipv4addr* addr) { struct dns_result out = {0}; debugfn(dns_name4(&out, addr)); obuf_putf(&outbuf, "s{: count=}d{\n}", ipv4_format(addr), out.count); dump_rrs(out.count, &out.rr); obuf_flush(&outbuf); }
int main () { stralloc out ={0}; stralloc sa ={0}; char ip[4]; char *dn =0; stralloc_copys(&sa, "abcdefg"); dns_ip4(&out, &sa); dns_ip4_qualify(&out, &sa, &sa); dns_name4(&out, ip); dns_mx(&out, &sa); dns_txt(&out, &sa); dns_domain_length(sa.s); dns_domain_equal(sa.s, sa.s); dns_domain_copy(&dn, sa.s); dns_domain_fromdot(&dn, sa.s, sa.len); return 0; }
int main(int argc,char **argv) { dns_random_init(seed); if (*argv) ++argv; while (*argv) { if (!ip4_scan(*argv,ip)) strerr_die3x(111,FATAL,"unable to parse IP address ",*argv); if (dns_name4(&out,ip) == -1) strerr_die4sys(111,FATAL,"unable to find host name for ",*argv,": "); buffer_put(buffer_1,out.s,out.len); buffer_puts(buffer_1,"\n"); ++argv; } buffer_flush(buffer_1); _exit(0); }
void connection_accept(int c) { int ac; const char **run; const char *args[4]; char *ip =(char*)&socka.sin_addr; remote_ip[ipsvd_fmt_ip(remote_ip, ip)] =0; if (verbose) { out(INFO); out("pid "); bufnum[fmt_ulong(bufnum, getpid())] =0; out(bufnum); out(" from "); outfix(remote_ip); flush("\n"); } remote_port[ipsvd_fmt_port(remote_port, (char*)&socka.sin_port)] =0; if (lookuphost) { if (ipsvd_hostname(&remote_hostname, ip, paranoid) == -1) warn2("unable to look up hostname", remote_ip); if (! stralloc_0(&remote_hostname)) drop_nomem(); } socka_size =sizeof(socka); if (getsockname(c, (struct sockaddr*)&socka, &socka_size) == -1) drop("unable to get local address"); if (! local_hostname.len) { if (dns_name4(&local_hostname, (char*)&socka.sin_addr) == -1) drop("unable to look up local hostname"); if (! stralloc_0(&local_hostname)) die_nomem(); } local_ip[ipsvd_fmt_ip(local_ip, (char*)&socka.sin_addr)] =0; if (ucspi) ucspi_env(); if (instructs) { ac =ipsvd_check(iscdb, &inst, &match, (char*)instructs, remote_ip, remote_hostname.s, timeout); if (ac == -1) drop2("unable to check inst", remote_ip); if (ac == IPSVD_ERR) drop2("unable to read", (char*)instructs); } else ac =IPSVD_DEFAULT; if (phccmax) { if (phcc > phccmax) { ac =IPSVD_DENY; if (phccmsg) { ndelay_on(c); if (write(c, phccmsg, str_len(phccmsg)) == -1) warn("unable to write concurrency message"); } } if (verbose) { bufnum[fmt_ulong(bufnum, getpid())] =0; out(INFO); out("concurrency "); out(bufnum); out(" "); outfix(remote_ip); out(" "); bufnum[fmt_ulong(bufnum, phcc)] =0; out(bufnum); out("/"); bufnum[fmt_ulong(bufnum, phccmax)] =0; out(bufnum); out("\n"); } } if (verbose) { out(INFO); switch(ac) { case IPSVD_DENY: out("deny "); break; case IPSVD_DEFAULT: case IPSVD_INSTRUCT: out("start "); break; case IPSVD_EXEC: out("exec "); break; } bufnum[fmt_ulong(bufnum, getpid())] =0; out(bufnum); out(" "); outfix(local_hostname.s); out(":"); out(local_ip); out(" :"); outfix(remote_hostname.s); out(":"); outfix(remote_ip); out(":"); outfix(remote_port); if (instructs) { out(" "); if (iscdb) { out((char*)instructs); out("/"); } outfix(match.s); if(inst.s && inst.len && (verbose > 1)) { out(": "); outinst(&inst); } } flush("\n"); } if (ac == IPSVD_DENY) { close(c); _exit(100); } if (ac == IPSVD_EXEC) { args[0] ="/bin/sh"; args[1] ="-c"; args[2] =inst.s; args[3] =0; run =args; } else run =prog; if ((fd_move(0, c) == -1) || (fd_copy(1, 0) == -1)) drop("unable to set filedescriptor"); sig_uncatch(sig_term); sig_uncatch(sig_pipe); sig_uncatch(sig_child); sig_unblock(sig_child); #ifdef SSLSVD pid =getpid(); id[fmt_ulong(id, pid)] =0; ssl_io(0, run); #else pathexec(run); #endif drop2("unable to run", (char *)*prog); }