Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
nsDNSService Class Reference

#include <nsDNSService2.h>

Inheritance diagram for nsDNSService:
Inheritance graph
[legend]
Collaboration diagram for nsDNSService:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSPIDNSSERVICE
NS_DECL_NSIDNSSERVICE
NS_DECL_NSIOBSERVER 
nsDNSService ()
 ~nsDNSService ()
void init ()
 called to initialize the DNS service.
void shutdown ()
 called to shutdown the DNS service.
nsICancelable asyncResolve (in AUTF8String aHostName, in unsigned long aFlags, in nsIDNSListener aListener, in nsIEventTarget aListenerEventTarget)
 kicks off an asynchronous host lookup.
nsIDNSRecord resolve (in AUTF8String aHostName, in unsigned long aFlags)
 called to synchronously resolve a hostname.
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.

Public Attributes

readonly attribute AUTF8String myHostName
const unsigned long RESOLVE_BYPASS_CACHE = (1 << 0)
 if set, this flag suppresses the internal DNS lookup cache.
const unsigned long RESOLVE_CANONICAL_NAME = (1 << 1)
 if set, the canonical name of the specified host will be queried.

Private Member Functions

PRUint16 GetAFForLookup (const nsACString &host)

Private Attributes

nsRefPtr< nsHostResolvermResolver
nsCOMPtr< nsIIDNServicemIDN
PRLockmLock
nsAdoptingCString mIPv4OnlyDomains
PRBool mDisableIPv6

Detailed Description

Definition at line 45 of file nsDNSService2.h.


Constructor & Destructor Documentation

Definition at line 280 of file nsDNSService2.cpp.

    : mLock(nsnull)
{
}

Definition at line 285 of file nsDNSService2.cpp.

Here is the call graph for this function:


Member Function Documentation

nsICancelable nsIDNSService::asyncResolve ( in AUTF8String  aHostName,
in unsigned long  aFlags,
in nsIDNSListener  aListener,
in nsIEventTarget  aListenerEventTarget 
) [inherited]

kicks off an asynchronous host lookup.

Parameters:
aHostNamethe hostname or IP-address-literal to resolve.
aFlagsa bitwise OR of the RESOLVE_ prefixed constants defined below.
aListenerthe listener to be notified when the result is available.
aListenerEventTargetoptional parameter (may be null). if non-null, this parameter specifies the nsIEventTarget of the thread on which the listener's onLookupComplete should be called. however, if this parameter is null, then onLookupComplete will be called on an unspecified thread (possibly recursively).
Returns:
An object that can be used to cancel the host lookup.
PRUint16 nsDNSService::GetAFForLookup ( const nsACString &  host) [private]

Definition at line 530 of file nsDNSService2.cpp.

{
    if (mDisableIPv6)
        return PR_AF_INET;

    nsAutoLock lock(mLock);

    PRUint16 af = PR_AF_UNSPEC;

    if (!mIPv4OnlyDomains.IsEmpty()) {
        const char *domain, *domainEnd, *end;
        PRUint32 hostLen, domainLen;

        // see if host is in one of the IPv4-only domains
        domain = mIPv4OnlyDomains.BeginReading();
        domainEnd = mIPv4OnlyDomains.EndReading(); 

        nsACString::const_iterator hostStart;
        host.BeginReading(hostStart);
        hostLen = host.Length();

        do {
            // skip any whitespace
            while (*domain == ' ' || *domain == '\t')
                ++domain;

            // find end of this domain in the string
            end = strchr(domain, ',');
            if (!end)
                end = domainEnd;

            // to see if the hostname is in the domain, check if the domain
            // matches the end of the hostname.
            domainLen = end - domain;
            if (domainLen && hostLen >= domainLen) {
                const char *hostTail = hostStart.get() + hostLen - domainLen;
                if (PL_strncasecmp(domain, hostTail, domainLen) == 0) {
                    // now, make sure either that the hostname is a direct match or
                    // that the hostname begins with a dot.
                    if (hostLen == domainLen ||
                            *hostTail == '.' || *(hostTail - 1) == '.') {
                        af = PR_AF_INET;
                        break;
                    }
                }
            }

            domain = end + 1;
        } while (*end);
    }

    return af;
}

Here is the call graph for this function:

void nsPIDNSService::init ( ) [inherited]

called to initialize the DNS service.

void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.
nsIDNSRecord nsIDNSService::resolve ( in AUTF8String  aHostName,
in unsigned long  aFlags 
) [inherited]

called to synchronously resolve a hostname.

warning this method may block the calling thread for a long period of time. it is extremely unwise to call this function on the UI thread of an application.

Parameters:
aHostNamethe hostname or IP-address-literal to resolve.
aFlagsa bitwise OR of the RESOLVE_ prefixed constants defined below.
Returns:
DNS record corresponding to the given hostname.
Exceptions:
NS_ERROR_UNKNOWN_HOSTif host could not be resolved.
void nsPIDNSService::shutdown ( ) [inherited]

called to shutdown the DNS service.

any pending asynchronous requests will be canceled, and the local cache of DNS records will be cleared. NOTE: the operating system may still have its own cache of DNS records, which would be unaffected by this method.


Member Data Documentation

Definition at line 70 of file nsDNSService2.h.

Definition at line 61 of file nsDNSService2.h.

nsAdoptingCString nsDNSService::mIPv4OnlyDomains [private]

Definition at line 69 of file nsDNSService2.h.

Definition at line 64 of file nsDNSService2.h.

Definition at line 60 of file nsDNSService2.h.

readonly attribute AUTF8String nsIDNSService::myHostName [inherited]
Returns:
the hostname of the operating system.

Definition at line 94 of file nsIDNSService.idl.

const unsigned long nsIDNSService::RESOLVE_BYPASS_CACHE = (1 << 0) [inherited]

if set, this flag suppresses the internal DNS lookup cache.

Definition at line 104 of file nsIDNSService.idl.

const unsigned long nsIDNSService::RESOLVE_CANONICAL_NAME = (1 << 1) [inherited]

if set, the canonical name of the specified host will be queried.

Definition at line 109 of file nsIDNSService.idl.


The documentation for this class was generated from the following files: