E-MailRelay

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

A class that holds a host/service name pair and the preferred address family (if any), and also the results of a name-to-address lookup, ie. More...

`#include <glocation.h>`

## Public Member Functions
| Location (const std::string &host, const std::string &service, int family=AF_UNSPEC)
| Constructor taking a host/service string.
| Location (const std::string &socks_host, const std::string &socks_service, const std::string &far_host, const std::string &far_service, int family=AF_UNSPEC)
| Constructor for socks. More...
| Location (const std::string &location_string, int family=AF_UNSPEC)
| Constructor taking a formatted host/service string. More...
bool | socks () const
| Returns true if a socks location.
std::string | host () const
| Returns the remote host name, as passed in to the constructor.
std::string | service () const
| Returns the remote service name, as passed in to the constructor.
void | resolveTrivially ()
| If host() and service() are already in address format then do a trivial update() so that the location is immediately resolved(), albeit with an empty canonical name(). More...
void | update (const Address &address, const std::string &canonical_name)
| Updates the address and canonical name, typically after doing a name lookup on host() and service(). More...
int | family () const
| Returns the preferred name resolution address family, or AF_UNSPEC.
bool | dgram () const
| Returns true if the name resolution should be specifically for datagram sockets. More...
bool | resolved () const
| Returns true after update() has been called.
Address | address () const
| Returns the remote address.
std::string | name () const
| Returns the remote canonical name. More...
std::string | displayString () const
| Returns a string representation for logging and debug.
G::EpochTime | updateTime () const
| Returns the time of the last update() or zero if never update()d.
unsigned int | socksFarPort () const
| Returns the port number for the socks far server. More...
std::string | socksFarHost () const
| Returns the port for the socks far server. More...

## Detailed Description

A class that holds a host/service name pair and the preferred address family (if any), and also the results of a name-to-address lookup, ie.

the remote address and canonical host name. The actual name-to-address lookup is done externally, and the results are deposited into the Location object with update().

One of the constructors allows an extended host/service format for transparent SOCKS support: before the "@" separator is the host/service pair passed verbatim to the socks server for it to resolve (see socksFarHost()); after the "@" is the host/service pair for the socks server itself, which we resolve and connect to (see host()).

See also
  GNet::ClientPtr

Definition at line 50 of file glocation.h.

## Constructor & Destructor Documentation

GNet::Location::Location | ( | const std::string & | socks_host,
|  | const std::string & | socks_service,
|  | const std::string & | far_host,
|  | const std::string & | far_service,
|  | int | family = `AF_UNSPEC`
| ) |  |

Constructor for socks.

The first pair of parameters are for the socks server, and the second pair are for the target server.

Definition at line 46 of file glocation.cpp.

GNet::Location::Location | ( | const std::string & | location_string,
|  | int | family = `AF_UNSPEC`
| ) |  |
| explicit

Constructor taking a formatted host/service string.

The format supports the extended format for socks as "far-host:far-service@socks-host:socks-service". Throws if incorrectly formatted.

Definition at line 68 of file glocation.cpp.

## Member Function Documentation

bool GNet::Location::dgram | ( |  | ) | const

Returns true if the name resolution should be specifically for datagram sockets.

Definition at line 131 of file glocation.cpp.

std::string GNet::Location::name | ( |  | ) | const

Returns the remote canonical name.

Returns the empty string if not available.

Definition at line 164 of file glocation.cpp.

void GNet::Location::resolveTrivially | ( |  | ) |

If host() and service() are already in address format then do a trivial update() so that the location is immediately resolved(), albeit with an empty canonical name().

Definition at line 136 of file glocation.cpp.

std::string GNet::Location::socksFarHost | ( |  | ) | const

Returns the port for the socks far server.

Precondition: socks()

Definition at line 190 of file glocation.cpp.

unsigned int GNet::Location::socksFarPort | ( |  | ) | const

Returns the port number for the socks far server.

Precondition: socks()

Definition at line 185 of file glocation.cpp.

void GNet::Location::update | ( | const Address & | address,
|  | const std::string & | canonical_name
| ) |  |

Updates the address and canonical name, typically after doing a name lookup on host() and service().

Definition at line 153 of file glocation.cpp.

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

- /tmp/slackrepo/SBo/slackrepo.S3SYfd/build_emailrelay/emailrelay-2.0.1/src/gnet/glocation.h
- /tmp/slackrepo/SBo/slackrepo.S3SYfd/build_emailrelay/emailrelay-2.0.1/src/gnet/glocation.cpp