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

version» Context lines:

pike.git/lib/modules/Protocols.pmod/DNS.pmod:8:       protected void send_reply(mapping r, mapping q, mapping m, Stdio.UDP udp);      #pike __REAL_VERSION__      // documentation taken from RFC 2136      //! No error condition.   final constant NOERROR=0;    - //! The name server was unable to interpret the request due to a format error. + //! The name server was unable to interpret the request due to a + //! format error.   final constant FORMERR=1;    - //!The name server encountered an internal failure while processing this request, for example an operating system error or a forwarding timeout. + //! The name server encountered an internal failure while processing + //! this request, for example an operating system error or a + //! forwarding timeout.   final constant SERVFAIL=2;      //! Some name that ought to exist, does not exist.   final constant NXDOMAIN=3;      //! The name server does not support the specified Opcode.   final constant NOTIMPL=4;    - //! The name server refuses to perform the specified operation for policy or security reasons. + //! The name server refuses to perform the specified operation for + //! policy or security reasons.   final constant REFUSED=5;      //! Some RRset that ought to exist, does not exist.   final constant NXRRSET=8;      final constant QUERY=0;      //! Resource classes   enum ResourceClass   {
pike.git/lib/modules/Protocols.pmod/DNS.pmod:224:    case T_NAPTR:    string rnaptr = sprintf("%2c%2c", entry->order, entry->preference);    rnaptr += sprintf("%1H%1H%1H%s",    entry->flags || "",    entry->service || "",    entry->regexp || "",    mkname(entry->replacement, pos, c));    return rnaptr;       case T_TXT: -  return Array.map(stringp(entry->txt)? ({entry->txt}):(entry->txt||({})), +  return map(stringp(entry->txt)? ({entry->txt}):(entry->txt||({})),    lambda(string t) {    return sprintf("%1H", t);    })*"";    case T_SPF: -  return Array.map(stringp(entry->spf)? ({entry->spf}):(entry->spf||({})), +  return map(stringp(entry->spf)? ({entry->spf}):(entry->spf||({})),    lambda(string t) {    return sprintf("%1H", t);    })*"";    case T_LOC:    // FIXME: Not implemented yet.    default:    return "";    }    }   
pike.git/lib/modules/Protocols.pmod/DNS.pmod:297:    return low_low_mkquery((["id":id, "rd":1,    "qd":(["name":dname, "cl":cl, "type":type])]));    }      //! create a DNS query PDU   //!   //! @param dnameorquery   //! @param cl   //! record class such as Protocols.DNS.C_IN   //! @param type - //! query type such Protocols.DNS.T_A +  //! query type such Protocols.DNS.T_A   //!   //! @returns   //! data suitable for use with   //! @[Protocols.DNS.client.do_sync_query]   //!   //! @example   //! // generate a query PDU for a address lookup on the hostname pike.lysator.liu.se   //! string q=Protocols.DNS.protocol()->mkquery("pike.lysator.liu.se", Protocols.DNS.C_IN, Protocols.DNS.T_A);    string mkquery(string|mapping dnameorquery, int|void cl, int|void type)    {
pike.git/lib/modules/Protocols.pmod/DNS.pmod:1083:    for(int i;i<sizeof(args);i+=2) {    Stdio.Port port;       if(args[i]) {    port = Stdio.Port(args[i+1], accept, args[i]);    } else {    port = Stdio.Port(args[i+1], accept);    }       port->set_id(port); -  // port objects are stored for destruction when the server object is destroyed. +  // Port objects are stored for destruction when the server +  // object is destroyed.    ports += ({ port });    }    }       protected void destroy()    {    foreach (connections; Connection con;) {    destruct(con);    }   
pike.git/lib/modules/Protocols.pmod/DNS.pmod:1109:   class dual_server {    inherit server : UDP;    inherit tcp_server : TCP;       protected void send_reply(mapping r, mapping q, mapping m,    Connection|Stdio.UDP con) {    string rpl = low_send_reply(r, q, m);       if (!con->tcp_connection) {    if (sizeof(rpl) > 512) { -  rpl = sprintf("%s%8c", rpl[..3], 0); // truncate after header and +  rpl = sprintf("%s%8c", rpl[..3], 0); // Truncate after header and    // send empty response    // ("dnscache strategy") -  rpl[2] |= 2; // set TC bit +  rpl[2] |= 2; // Set TC bit    }    con->send(m->ip, m->port, rpl);    } else    con->send(rpl);    }       protected void create(int|string|void arg1, string|int ... args)    {    ::create(arg1, @args);    }
pike.git/lib/modules/Protocols.pmod/DNS.pmod:1134:    protected void destroy()    {    ::destroy();    }   }         #define RETRIES 12   #define RETRY_DELAY 5    - //! Synchronous DNS client. + //! Synchronous DNS client.   class client   {    inherit protocol;      #ifdef __NT__    array(string) get_tcpip_param(string val, void|string fallbackvalue)    {    array(string) res = ({});    foreach(({    "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
pike.git/lib/modules/Protocols.pmod/DNS.pmod:1366:       if(domain)    domains = ({ domain }) + domains;   #endif    nameservers -= ({ "" });    if (!sizeof(nameservers)) {    /* Try localhost... */    nameservers = ({ "127.0.0.1" });    }    domains -= ({ "" }); -  domains = Array.map(domains, lambda(string d) { +  domains = map(domains, lambda(string d) {    if (d[-1] == '.') {    return d[..<1];    }    return d;    });    }    else    {    if(arrayp(server))    nameservers = server;
pike.git/lib/modules/Protocols.pmod/DNS.pmod:1393:    if(stringp(domain))    domains = ({ domain });    }    }      //! Perform a synchronous DNS query.   //!   //! @param s   //! Result of @[Protocols.DNS.protocol.mkquery]   //! @returns - //! mapping containing query result or 0 on failure/timeout +  //! mapping containing query result or 0 on failure/timeout   //!   //! @example   //! @code   //! // Perform a hostname lookup, results stored in r->an   //! object d=Protocols.DNS.client();   //! mapping r=d->do_sync_query(d->mkquery("pike.lysator.liu.se", C_IN, T_A));   //! @endcode    mapping do_sync_query(string s)    {    int i;
pike.git/lib/modules/Protocols.pmod/DNS.pmod:1587:    } else {    m = do_sync_query(    mkquery("_" + service +"._"+ protocol + "." + name, C_IN, T_SRV));    }       if (!m) { // no entries.    return ({});    }       array res=({}); -  +     foreach(m->an, mapping x)    {    res+=({({x->priority, x->weight, x->port, x->target})});    }       // now we sort the array by priority as a convenience    array y=({});    foreach(res, array t)    y+=({t[0]});    sort(y, res);