Static Public Member Functions | List of all members
GNet::Local Class Reference

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

#include <glocal.h>

Static Public Member Functions

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

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

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

Returns the canonical address associated with hostname().

Definition at line 41 of file glocal.cpp.

References G_ASSERT.

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

Returns the fqdn()'s domainname.

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

Definition at line 51 of file glocal.cpp.

References G_DEBUG.

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 67 of file glocal.cpp.

Referenced by GAuth::SaslServerBasicImp::init(), GSmtp::ExecutableVerifier::verify(), and GSmtp::NetworkVerifier::verify().

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

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

Definition at line 76 of file glocal.cpp.

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

Returns the hostname.

On unix systems this ususally comes from uname().

Definition at line 33 of file glocal.cpp.

References G::hostname().

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 82 of file glocal.cpp.

Referenced by GPop::Server::newPeer(), GSmtp::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 88 of file glocal.cpp.

References GNet::Address::isLocal().

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

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

Definition at line 62 of file glocal.cpp.

References GNet::Address::localhost().


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