E-MailRelay

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

glocal_dns_disabled.cpp
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2018 Graeme Walker <graeme_walker@users.sourceforge.net>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
17 //
18 // glocal_dns_disabled.cpp
19 //
20
21 #include "gdef.h"
22 #include "glocal.h"
23 #include "ghostname.h"
24
25 std::string GNet::Local::m_name_override ;
26 bool GNet::Local::m_name_override_set = false ;
27
28 std::string GNet::Local::hostname()
29 {
30 std::string name = G::hostname() ;
31 if( name.empty() )
32 throw Error("cannot determine the hostname for this machine" ) ;
33 return name ;
34 }
35
36 std::string GNet::Local::canonicalName()
37 {
38 return m_name_override_set ? m_name_override : hostname() ;
39 }
40
41 void GNet::Local::canonicalName( const std::string & override )
42 {
43 m_name_override = override ;
44 m_name_override_set = true ;
45 }
46
47 bool GNet::Local::isLocal( const Address & address , std::string & reason )
48 {
49 bool local = address.sameHost( Address::loopback() ) ;
50 }
51
52 /// \file glocal_dns_disabled.cpp
GNet::Address::loopback
static Address loopback(Family, unsigned int port=0U)
Returns a loopback address.
Definition: gaddress_ipv4.cpp:83
GNet::Local::canonicalName
static std::string canonicalName()
Returns the canonical network name assiciated with hostname().
Definition: glocal.cpp:54
GNet::Local::hostname
static std::string hostname()
Returns the local hostname. Returns "localhost" on error.
Definition: glocal.cpp:32
G::hostname
std::string hostname()
Returns the hostname.
Definition: ghostname_unix.cpp:27
ghostname.h
GNet::Local::isLocal
static bool isLocal(const Address &, std::string &reason)
Returns true if the given address appears to be associated with the local host, or a helpful error me...
Definition: glocal.cpp:65
glocal.h