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.83 2004/09/15 19:59:15 grubba Exp $ + // $Id: DNS.pmod,v 1.84 2005/01/03 11:07:28 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:412:    break;    case T_SOA:    m->mname=decode_domain(s,next);    m->rname=decode_domain(s,next);    m->serial=decode_int(s,next);    m->refresh=decode_int(s,next);    m->retry=decode_int(s,next);    m->expire=decode_int(s,next);    m->minimum=decode_int(s,next);    break; +  case T_TXT: +  m->txt = decode_string(s, next); +  break;    }       next[0]=tmp+m->len;    ret+=({m});    }    return ret;    }       mapping decode_res(string s)    {
pike.git/lib/modules/Protocols.pmod/DNS.pmod:554:    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"); +  werror("Protocols.DNS.server(%O)\n" +  "UDP Address: %s\n" +  "%s\n", port, udp::query_address(), +  describe_backtrace(backtrace()));    udp::set_read_callback(rec_data);    }      }         #define RETRIES 12   #define RETRY_DELAY 5      //! Synchronous DNS client.
pike.git/lib/modules/Protocols.pmod/DNS.pmod:798:   //! 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); +  werror("Protocols.DNS.client()->do_sync_query(%O)\n" +  "UDP Address: %s\n" +  "%s\n", s, udp->query_address(), describe_backtrace(backtrace()));    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:1257:    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" ); +  werror("Protocols.DNS.async_client(%O, %O)\n" +  "UDP Address: %s\n" +  "%s\n", server, domain, udp::query_address(), +  describe_backtrace(backtrace()));       udp::set_read_callback(rec_data);    ::create(server,domain);    }   };         async_client global_async_client;      #define GAC(X) \