28 std::string GNet::Local::m_fqdn ;
29 std::string GNet::Local::m_fqdn_override ;
30 bool GNet::Local::m_fqdn_override_set = false ;
37 throw Error(
"hostname") ;
43 if( m_canonical_address.port() == 1U )
45 m_canonical_address = canonicalAddressImp() ;
46 G_ASSERT( m_canonical_address.port() != 1U ) ;
48 return m_canonical_address ;
53 std::string full = fqdn() ;
55 if( pos == std::string::npos )
56 throw Error( std::string() +
"invalid fqdn: no dot in \"" + full +
"\"" ) ;
58 G_DEBUG(
"GNet::Local::domainname: \"" << full.substr(pos+1U) <<
"\"" ) ;
59 return full.substr( pos+1U ) ;
69 if( m_fqdn_override_set )
70 m_fqdn = m_fqdn_override ;
71 else if( m_fqdn.empty() )
78 m_fqdn_override = override ;
79 m_fqdn_override_set = true ;
85 return isLocal( address , reason ) ;
90 return address.
isLocal(reason,canonicalAddress()) ;
static Address localhostAddress()
A convenience function that returns the "127.0.0.1:0" address.
static Address localhost(unsigned int port=0U)
Returns a localhost ("loopback") address.
static std::string hostname()
Returns the hostname.
The Address class encapsulates an IP transport address.
static bool isLocal(const Address &)
Returns true if the given address appears to be local.
static std::string fqdn()
Returns the fully-qualified-domain-name.
std::string::size_type size_type
A std::size_t type.
std::string hostname()
Returns the hostname.
static std::string domainname()
Returns the fqdn()'s domainname.
bool isLocal(std::string &reason) const
Returns true if the address is definitely local.
static Address canonicalAddress()
Returns the canonical address associated with hostname().