pike.git / lib / modules / Protocols.pmod / DNS.pmod

version» Context lines:

pike.git/lib/modules/Protocols.pmod/DNS.pmod:1: - // $Id: DNS.pmod,v 1.84 2005/01/03 11:07:28 grubba Exp $ + // $Id: DNS.pmod,v 1.85 2005/01/03 12:50:09 grubba Exp $   // Not yet finished -- Fredrik Hubinette      //! Domain Name System   //! RFC 1035      #pike __REAL_VERSION__      constant NOERROR=0;   constant FORMERR=1;   constant SERVFAIL=2;
pike.git/lib/modules/Protocols.pmod/DNS.pmod:557:    else    handle_query(q, m);    }       void create(int|void port)    {    if(!port)    port = 53;    if(!udp::bind(port))    error("DNS: failed to bind port "+port+".\n"); + #if 0    werror("Protocols.DNS.server(%O)\n"    "UDP Address: %s\n"    "%s\n", port, udp::query_address(),    describe_backtrace(backtrace())); -  + #endif /* 0 */    udp::set_read_callback(rec_data);    }      }         #define RETRIES 12   #define RETRY_DELAY 5      //! Synchronous DNS client.
pike.git/lib/modules/Protocols.pmod/DNS.pmod:805:   //! mapping containing query result or 0 on failure/timeout   //!   //! @example   //! // perform a hostname lookup, results stored in r->an   //! object d=Protocols.DNS.client();   //! mapping r=d->do_sync_query(d->mkquery("pike.ida.liu.se", C_IN, T_A));    mapping do_sync_query(string s)    {    object udp = Stdio.UDP();    udp->bind(0); + #if 0    werror("Protocols.DNS.client()->do_sync_query(%O)\n"    "UDP Address: %s\n"    "%s\n", s, udp->query_address(), describe_backtrace(backtrace())); -  + #endif /* 0 */    mapping m;    int i;    for (i=0; i < RETRIES; i++) {    udp->send(nameservers[i % sizeof(nameservers)], 53, s);       // upd->wait() can throw an error sometimes.    catch    {    while (udp->wait(RETRY_DELAY))    {
pike.git/lib/modules/Protocols.pmod/DNS.pmod:1267:    sort(column(mx, "preference"), a);    }    callback(a, @args);    }, callback, @args);    }       void create(void|string|array(string) server, void|string|array(string) domain)    {    if(!udp::bind(0))    error( "DNS: failed to bind a port.\n" ); + #if 0    werror("Protocols.DNS.async_client(%O, %O)\n"    "UDP Address: %s\n"    "%s\n", server, domain, udp::query_address(),    describe_backtrace(backtrace())); -  + #endif /* 0 */       udp::set_read_callback(rec_data);    ::create(server,domain);    }   };         async_client global_async_client;      #define GAC(X) \