pike.git
/
lib
/
modules
/
Protocols.pmod
/
DNS.pmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/lib/modules/Protocols.pmod/DNS.pmod:1:
// Not yet finished -- Fredrik Hubinette // RFC 1035
-
//!
module
Protocols
-
//
!
submodule
DNS
+
//!
$Id:
DNS.pmod,v 1.59 2001
/
04
/
27
13:38:40
grubba Exp $
-
//! $Id: DNS.pmod,v 1.58 2001/04/09 19:50:04 marcus Exp $
-
+
#pike __REAL_VERSION__ constant NOERROR=0; constant FORMERR=1; constant SERVFAIL=2; constant NXDOMAIN=3; constant NOTIMPL=4; constant NXRRSET=8; constant QUERY=0;
pike.git/lib/modules/Protocols.pmod/DNS.pmod:383:
throw(({"DNS: failed to bind port "+port+".\n",backtrace()})); udp::set_read_callback(rec_data); } } #define RETRIES 12 #define RETRY_DELAY 5
+
//! Synchronous DNS client.
class client {
-
//!
-
//! class client
-
//! Synchronous DNS client.
-
//!
+
inherit protocol; static private int is_ip(string ip) { return(replace(ip, ({ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "." }), ({ "", "", "", "", "", "", "", "", "", "", "" })) == ""); }
pike.git/lib/modules/Protocols.pmod/DNS.pmod:473:
} } } else { // Couldn't read /etc/hosts. } } } return(etc_hosts[lower_case(host)]); }
-
//!
-
//! method
void create()
-
//!
method
void create(void|string|array server, void|int|array domain)
-
//!
+
//!
@decl
void create()
+
//!
@decl
void create(void|string|array server, void|int|array domain)
array(string) nameservers = ({}); array domains = ({}); void create(void|string|array(string) server, void|int|array(string) domain) { if(!server) { #if __NT__ domains = get_tcpip_param("Domain", "") + get_tcpip_param("DhcpDomain", "") +
pike.git/lib/modules/Protocols.pmod/DNS.pmod:637:
return decode_res(m->data); } }; } }; } // Failure. return 0; }
-
//!
-
//! method
array gethostbyname(string hostname)
-
//!
method
array gethostbyaddr(string hostip)
+
//!
@decl
array gethostbyname(string hostname)
+
//!
@decl
array gethostbyaddr(string hostip)
//! Querys the host name or ip from the default or given
-
//! DNS server. The result is
a
mapping
with three elements,
-
//!
<data_description type=array>
-
//!
<elem
value=hostname
type=
string
>
hostname
<
/
elem>
-
//!
<elem
value=ip
type=
array(string)
>
ip number(s)
</elem>
-
//!
<elem
value=ip
type=
array(string)
>dns
name(s)
</elem>
-
//!
</data_description>
+
//! DNS server. The result is
an
array
with three elements,
+
//!
@array
+
//!
@elem
string
hostname
+
/
/! Hostname.
+
//!
@elem
array(string)
ip
+
//! IP
number(s)
.
+
//!
@elem
array(string)
aliases
+
//! DNS
name(s)
.
+
//!
@endarray
//! array gethostbyname(string s) { mapping m; if(sizeof(domains) && s[-1] != '.' && sizeof(s/".") < 3) { m = do_sync_query(mkquery(s, C_IN, T_A)); if(!m || !m->an || !sizeof(m->an)) foreach(domains, string domain) {
pike.git/lib/modules/Protocols.pmod/DNS.pmod:722:
sizeof(names)?names[0]:0, ips, names, }); } else { // Lookup failed. return({ 0, ({}), ({}) }); } }
-
//!
-
//! method
string get_primary_mx(string hostname)
+
//!
@decl
string get_primary_mx(string hostname)
//! Querys the primary mx for the host.
-
//!
returns
the hostname of the primary mail exchanger
+
//!
@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) { m=do_sync_query(mkquery(host+"."+domain, C_IN, T_MX)); if(m && m->an && sizeof(m->an))