32 m_ptext(ptext.release()) ,
33 m_protocol(*this,*this,store,server_secrets,sasl_server_config,*m_ptext,peerAddress(),protocol_config)
35 G_LOG_S(
"GPop::ServerPeer: pop connection from " <<
peerAddress().displayString() ) ;
39void GPop::ServerPeer::onDelete(
const std::string & reason )
41 G_LOG_S(
"GPop::ServerPeer: pop connection closed: " << reason << (reason.empty()?
"":
": ")
42 << peerAddress().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( std::string_view line , std::size_t offset )
58 std::string_view output = line.substr( std::min(offset,line.size()) ) ;
59 return output.empty() ? true : send( output ) ;
62void GPop::ServerPeer::onSendComplete()
67bool GPop::ServerPeer::securityEnabled()
const
70 bool enabled = secureAcceptCapable() ;
71 G_DEBUG(
"ServerPeer::securityEnabled: tls library " << (
enabled?
"enabled":
"disabled") ) ;
75void GPop::ServerPeer::securityStart()
80void GPop::ServerPeer::onSecure(
const std::string & ,
const std::string & ,
const std::string & )
88 GNet::MultiServer(es,config.addresses,config.port,
"pop",config.net_server_peer_config,config.net_server_config) ,
102 serverReport( group ) ;
103 G_LOG_S(
"GPop::Server: " << (group.empty()?
"":
"[") << group << (group.empty()?
"":
"] ")
104 <<
"pop server authentication secrets from \"" << m_secrets.source() <<
"\"" ) ;
109 std::unique_ptr<GNet::ServerPeer> ptr ;
113 if( !m_config.allow_remote && !peer_info.m_address.isLocal(reason) )
115 G_WARNING(
"GPop::Server: configured to reject non-local pop connection: " << reason ) ;
120 ptr = std::make_unique<ServerPeer>( esu , std::move(peer_info) , m_store , m_secrets ,
121 m_config.sasl_server_config , newProtocolText(peer_address) , m_config.protocol_config ) ;
124 catch( std::exception & e )
126 G_WARNING(
"GPop::Server: new connection error: " << e.what() ) ;
131std::unique_ptr<GPop::ServerProtocol::Text> GPop::Server::newProtocolText(
const GNet::Address & peer_address )
const
133 return std::make_unique<ServerProtocolText>(peer_address) ;
An interface used by GAuth::SaslServer to obtain authentication secrets.
The GNet::Address class encapsulates a TCP/UDP transport address.
The EventStateUnbound class is used as a device to force factory methods to plumb-in an ExceptionSour...
A lightweight object containing an ExceptionHandler pointer, optional ExceptionSource pointer and opt...
A move-only structure used in GNet::Server::newPeer() and containing the new socket.
Address peerAddress() const override
Returns the peer address.
Represents a connection from a POP client.
ServerPeer(GNet::EventStateUnbound, 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.
void report(const std::string &group={}) const
Generates helpful diagnostics after construction.
~Server() override
Destructor.
Server(GNet::EventState, Store &store, const GAuth::SaslServerSecrets &, const Config &)
Constructor. The 'secrets' reference is kept.
bool enabled() noexcept
Returns true if pop code is built in.
A structure used in GNet::MultiServer::newPeer().
A configuration structure for GNet::ServerPeer.
A structure containing configuration parameters for ServerProtocol.
A structure containing GPop::Server configuration parameters.