GNet::Local Class Reference

A static class for getting information about the local machine's network name and address. More...

#include <glocal.h>

List of all members.

Static Public Member Functions

static std::string hostname ()
 Returns the hostname.
static Address canonicalAddress ()
 Returns the canonical address associated with hostname().
static std::string fqdn ()
 Returns the fully-qualified-domain-name.
static std::string domainname ()
 Returns the fqdn()'s domainname.
static void fqdn (const std::string &fqdn_override)
 Sets the fqdn() (and therefore domainname()) override.
static Address localhostAddress ()
 A convenience function that returns the "127.0.0.1:0" address.
static bool isLocal (const Address &)
 Returns true if the given address appears to be local.
static bool isLocal (const Address &, std::string &reason)
 An override that returns a helpful message by reference if the address not local.


Detailed Description

A static class for getting information about the local machine's network name and address.

Definition at line 39 of file glocal.h.


Member Function Documentation

std::string GNet::Local::hostname (  )  [static]

Returns the hostname.

On unix systems this ususally comes from uname().

Definition at line 32 of file glocal.cpp.

References G::hostname().

GNet::Address GNet::Local::canonicalAddress (  )  [static]

Returns the canonical address associated with hostname().

Definition at line 40 of file glocal.cpp.

References G_ASSERT, and GNet::Address::port().

Referenced by isLocal().

std::string GNet::Local::fqdn (  )  [static]

Returns the fully-qualified-domain-name.

This is typically implemented by doing a DNS lookup on hostname(), but it is overridable by calling fdqn(string).

Definition at line 66 of file glocal.cpp.

Referenced by domainname(), GSmtp::SaslServerImp::init(), GSmtp::NetworkVerifier::verify(), and GSmtp::ExecutableVerifier::verify().

std::string GNet::Local::domainname (  )  [static]

Returns the fqdn()'s domainname.

Throws if the fqdn() does not contain a domain part.

Definition at line 50 of file glocal.cpp.

References fqdn(), and G_DEBUG.

void GNet::Local::fqdn ( const std::string &  fqdn_override  )  [static]

Sets the fqdn() (and therefore domainname()) override.

Definition at line 75 of file glocal.cpp.

GNet::Address GNet::Local::localhostAddress (  )  [static]

A convenience function that returns the "127.0.0.1:0" address.

Definition at line 61 of file glocal.cpp.

References GNet::Address::localhost().

bool GNet::Local::isLocal ( const Address address  )  [static]

Returns true if the given address appears to be local.

A simple implementation may compare the given address with localhostAddress() and canonicalAddress().

Definition at line 80 of file glocal.cpp.

Referenced by GSmtp::Server::newPeer(), GPop::Server::newPeer(), and GSmtp::AdminServer::newPeer().

bool GNet::Local::isLocal ( const Address address,
std::string &  reason 
) [static]

An override that returns a helpful message by reference if the address not local.

Definition at line 86 of file glocal.cpp.

References canonicalAddress(), and GNet::Address::isLocal().


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

Generated on Fri Apr 18 15:56:13 2008 for E-MailRelay by  doxygen 1.5.5