32 const Secrets & secrets , unique_ptr<ServerProtocol::Text> ptext ,
34 GNet::BufferedServerPeer(peer_info,
GNet::LineBufferConfig::pop()) ,
36 m_ptext(ptext.release()) ,
37 m_protocol(*this,*this,store,secrets,*m_ptext.get(),peer_info.m_address,protocol_config)
39 G_LOG_S(
"GPop::ServerPeer: pop connection from " << peer_info.m_address.
displayString() ) ;
45 G_LOG_S(
"GPop::ServerPeer: pop connection closed: " << reason << (reason.empty()?
"":
": ")
46 << peerAddress().second.displayString() ) ;
51 processLine( std::string(line_data,line_size) ) ;
55 void GPop::ServerPeer::processLine(
const std::string & line )
57 m_protocol.apply( line ) ;
62 return send( line , offset ) ;
73 G_DEBUG(
"ServerPeer::securityEnabled: ssl library " << (enabled?
"enabled":
"disabled") ) ;
90 GNet::MultiServer(eh,
GNet::MultiServer::addressList(config.addresses,config.port)) ,
91 m_allow_remote(config.allow_remote) ,
105 serverReport(
"pop" ) ;
106 G_LOG_S(
"GPop::Server: pop authentication secrets from \"" << m_secrets.path() <<
"\"" ) ;
116 G_WARNING(
"GPop::Server: configured to reject non-local pop connection: " << reason ) ;
120 return new ServerPeer( peer_info , *
this , m_store , m_secrets ,
121 newProtocolText(peer_info.m_address) , ServerProtocol::Config() ) ;
123 catch( std::exception & e )
125 G_WARNING(
"GPop::Server: exception from new connection: " << e.what() ) ;
130 unique_ptr<GPop::ServerProtocol::Text> GPop::Server::newProtocolText(
GNet::Address peer_address )
const
132 return unique_ptr<ServerProtocol::Text>(
new ServerProtocolText(peer_address) ) ;
137 GPop::Server::Config::Config() :
138 allow_remote(false) ,
143 GPop::Server::Config::Config(
bool allow_remote_ ,
unsigned int port_ ,
const G::StringArray & addresses_ ) :
144 allow_remote(allow_remote_) ,
146 addresses(addresses_)
An abstract base class for the GNet::Server's connection to a remote client.
A simple interface to a store of secrets as used in authentication.
virtual void onSecure(const std::string &) override
Final override from GNet::SocketProtocolSink.
virtual void onSendComplete() override
Final override from GNet::BufferedServerPeer.
The GNet::Address class encapsulates a TCP/UDP transport address.
std::vector< std::string > StringArray
A std::vector of std::strings.
void report() const
Generates helpful diagnostics after construction.
ServerPeer(GNet::Server::PeerInfo, Server &, Store &, const Secrets &, unique_ptr< ServerProtocol::Text > ptext, ServerProtocol::Config)
Constructor.
A structure containing GPop::Server configuration parameters.
virtual bool onReceive(const char *, size_t, size_t) override
Final override from GNet::BufferedServerPeer.
void init()
Starts the protocol.
virtual void onDelete(const std::string &) override
Final override from GNet::ServerPeer.
An abstract interface for handling exceptions thrown out of event-loop callbacks (socket events...
A structure used in GNet::MultiServer::newPeer().
Server(GNet::ExceptionHandler &, Store &store, const Secrets &, Config)
Constructor. The 'secrets' reference is kept.
virtual ~Server()
Destructor.
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...
virtual bool securityEnabled() const override
Final override from GPop::ServerProtocol::Security.
A structure containing configuration parameters for ServerProtocol. NOT USED.
static bool secureAcceptCapable()
Returns true if the implementation supports TLS/SSL and a "server" profile has been configured...
virtual bool protocolSend(const std::string &line, size_t) override
Final override from GPop::ServerProtocol::Sender.
A structure used in GNet::Server::newPeer().
std::string displayString() const
Returns a string which represents the transport address for debugging and diagnostics purposes...
virtual void securityStart() override
Final override from GPop::ServerProtocol::Security.