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

version» Context lines:

pike.git/lib/modules/Protocols.pmod/DNS.pmod:1:   // Not yet finished -- Fredrik Hubinette   // RFC 1035    - //! $Id: DNS.pmod,v 1.64 2002/11/26 21:59:50 bill Exp $ + //! $Id: DNS.pmod,v 1.65 2002/11/27 01:10:35 grendel Exp $      #pike __REAL_VERSION__      constant NOERROR=0;   constant FORMERR=1;   constant SERVFAIL=2;   constant NXDOMAIN=3;   constant NOTIMPL=4;   constant NXRRSET=8;   
pike.git/lib/modules/Protocols.pmod/DNS.pmod:661:    }    };    }    };    }    // Failure.    return 0;    }       //! @decl array gethostbyname(string hostname) -  //! @decl array gethostbyaddr(string hostip) -  //! Querys the host name or ip from the default or given +  //! Queries the host name from the default or given    //! DNS server. The result is an array with three elements, -  +  //! +  //! @returns +  //! An array with the requested information about the specified +  //! host. +  //!    //! @array    //! @elem string hostname    //! Hostname.    //! @elem array(string) ip    //! IP number(s).    //! @elem array(string) aliases    //! DNS name(s).    //! @endarray    //!    array gethostbyname(string s)
pike.git/lib/modules/Protocols.pmod/DNS.pmod:709:    if(x->a)    ips+=({x->a});    }    return ({    sizeof(names)?names[0]:0,    ips,    names,    });    }    -  //! Querys the service record from the default or given +  //! Queries the service record from the default or given    //! DNS server. The result is an array of arrays with the    //! following six elements for each record. The array is    //! sorted according to the priority of each record.    //!    //! Each element of the array returned represents a service    //! record. Each service record contains the following: -  +  //! +  //! @returns +  //! An array with the requested information about the specified +  //! service. +  //!    //! @array    //! @elem int priority    //! Priority    //! @elem int weight    //! Weight in event of multiple records with same priority.    //! @elem int port    //! port number    //! @elem string target    //! target dns name    //! @endarray
pike.git/lib/modules/Protocols.pmod/DNS.pmod:782:    string arpa_from_ip(string ip)    {    return reverse(ip/".")*"."+".IN-ADDR.ARPA";    }       string ip_from_arpa(string arpa)    {    return reverse(arpa/".")[2..]*".";    }    -  array gethostbyaddr(string s) +  //! @decl array gethostbyaddr(string hostip) +  //! Queries the host name or ip from the default or given +  //! DNS server. The result is an array with three elements, +  //! +  //! @returns +  //! The requested data about the specified host. +  //! +  //! @array +  //! @elem string hostip +  //! The host IP. +  //! @elem array(string) ip +  //! IP number(s). +  //! @elem array(string) aliases +  //! DNS name(s). +  //! @endarray +  //! +  array gethostbyaddr(string hostip)    {    mapping m=do_sync_query(mkquery(arpa_from_ip(s), C_IN, T_PTR));    if (m) {    array(string) names=({});    array(string) ips=({});       foreach(m->an, mapping x)    {    if(x->ptr)    names+=({x->ptr});
pike.git/lib/modules/Protocols.pmod/DNS.pmod:810:    ips,    names,    });    } else {    // Lookup failed.    return({ 0, ({}), ({}) });    }    }       //! @decl string get_primary_mx(string hostname) -  //! Querys the primary mx for the host. +  //! Queries the primary mx for the host.    //! @returns    //! Returns the hostname of the primary mail exchanger.    //!    string get_primary_mx(string host)    {    mapping m;    if(sizeof(domains) && host[-1] != '.' && sizeof(host/".") < 3) {    m=do_sync_query(mkquery(host, C_IN, T_MX));    if(!m || !m->an || !sizeof(m->an))    foreach(domains, string domain)