32 m_ptext(ptext.release()) ,
33 m_protocol(*this,*this,store,server_secrets,sasl_server_config,*m_ptext,peer_info.m_address,protocol_config)
35 G_LOG_S(
"GPop::ServerPeer: pop connection from " << peer_info.m_address.
displayString() ) ;
39void GPop::ServerPeer::onDelete(
const std::string & reason )
41 G_LOG_S(
"GPop::ServerPeer: pop connection closed: " << reason << (reason.empty()?
"":
": ")
42 << peerAddress().second.displayString() ) ;
45bool GPop::ServerPeer::onReceive(
const char * line_data , std::size_t line_size , std::size_t , std::size_t ,
char )
47 processLine( std::string(line_data,line_size) ) ;
51void GPop::ServerPeer::processLine(
const std::string & line )
53 m_protocol.apply( line ) ;
56bool GPop::ServerPeer::protocolSend(
const std::string & line , std::size_t offset )
58 return send( line , offset ) ;
61void GPop::ServerPeer::onSendComplete()
66bool GPop::ServerPeer::securityEnabled()
const
70 G_DEBUG(
"ServerPeer::securityEnabled: tls library " << (enabled?
"enabled":
"disabled") ) ;
74void GPop::ServerPeer::securityStart()
79void GPop::ServerPeer::onSecure(
const std::string & ,
const std::string & ,
const std::string & )
87 GNet::MultiServer(es,config.addresses,config.port,
"pop",config.server_peer_config,config.server_config) ,
102 G_LOG_S(
"GPop::Server: pop authentication secrets from \"" << m_secrets.source() <<
"\"" ) ;
107 std::unique_ptr<GNet::ServerPeer> ptr ;
113 G_WARNING(
"GPop::Server: configured to reject non-local pop connection: " << reason ) ;
117 ptr = std::make_unique<ServerPeer>( esu , peer_info , m_store , m_secrets , m_config.sasl_server_config ,
118 newProtocolText(peer_info.m_address) , ServerProtocol::Config() ) ;
121 catch( std::exception & e )
123 G_WARNING(
"GPop::Server: new connection error: " << e.what() ) ;
128std::unique_ptr<GPop::ServerProtocol::Text> GPop::Server::newProtocolText(
const GNet::Address & peer_address )
const
130 return std::make_unique<ServerProtocolText>(peer_address) ;
135GPop::Server::Config::Config() :
136 server_peer_config(0U)
140GPop::Server::Config::Config(
bool allow_remote_ ,
unsigned int port_ ,
const G::StringArray & addresses_ ,
142 const std::string & sasl_server_config_ ) :
143 allow_remote(allow_remote_) ,
145 addresses(addresses_) ,
146 server_peer_config(server_peer_config_) ,
147 server_config(server_config_) ,
148 sasl_server_config(sasl_server_config_)
An interface used by GAuth::SaslServer to obtain authentication secrets.
The GNet::Address class encapsulates a TCP/UDP transport address.
std::string displayString(bool with_scope_id=false) const
Returns a string which represents the transport address.
A potential ExceptionSink that is realised by bind()ing an exception source pointer.
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
static bool isLocal(const Address &, std::string &reason)
Returns true if the given address appears to be 'local', or a helpful error message if not.
A structure that GNet::Server uses to configure its ServerPeer objects.
A structure used in GNet::Server::newPeer().
static bool secureAcceptCapable()
Returns true if the implementation supports TLS/SSL and a "server" profile has been configured.
Represents a connection from a POP client.
ServerPeer(GNet::ExceptionSinkUnbound, const GNet::ServerPeerInfo &, Store &, const GAuth::SaslServerSecrets &, const std::string &sasl_server_config, std::unique_ptr< ServerProtocol::Text > ptext, const ServerProtocol::Config &)
Constructor.
void init()
Starts the protocol.
Server(GNet::ExceptionSink, Store &store, const GAuth::SaslServerSecrets &, const Config &)
Constructor. The 'secrets' reference is kept.
~Server() override
Destructor.
void report() const
Generates helpful diagnostics after construction.
std::vector< std::string > StringArray
A std::vector of std::strings.
A structure used in GNet::MultiServer::newPeer().
A configuration structure for GNet::Server.
A structure containing configuration parameters for ServerProtocol, currently empty.
A structure containing GPop::Server configuration parameters.