21#ifndef G_POP_SERVER_PROTOCOL_H
22#define G_POP_SERVER_PROTOCOL_H
37 class ServerProtocol ;
38 class ServerProtocolText ;
52 G_EXCEPTION( ProtocolDone ,
tx(
"pop protocol done") )
57 virtual bool protocolSend( std::string_view , std::size_t offset ) = 0 ;
64 virtual std::string greeting()
const = 0 ;
65 virtual std::string quit()
const = 0 ;
66 virtual std::string capa()
const = 0 ;
67 virtual std::string user(
const std::string &
id )
const = 0 ;
68 virtual ~Text() = default ;
73 bool crlf_only {
true} ;
74 std::string sasl_server_challenge_domain ;
75 Config & set_crlf_only(
bool =
true ) ;
76 Config & set_sasl_server_challenge_domain(
const std::string & ) ;
82 virtual bool securityEnabled()
const = 0 ;
83 virtual void securityStart() = 0 ;
103 void apply(
const std::string & line ) ;
150 using EventData =
const std::string & ;
154 ~ServerProtocol() = default ;
161 void doQuit(
const std::string & line ,
bool & ) ;
162 void doQuitEarly(
const std::string & line ,
bool & ) ;
163 void doStat(
const std::string & line ,
bool & ) ;
164 void doList(
const std::string & line ,
bool & ) ;
165 void doRetr(
const std::string & line ,
bool & ) ;
166 void doDele(
const std::string & line ,
bool & ) ;
167 void doRset(
const std::string & line ,
bool & ) ;
168 void doUser(
const std::string & line ,
bool & ) ;
169 void doPass(
const std::string & line ,
bool & ) ;
170 void doNoop(
const std::string & line ,
bool & ) ;
171 void doNothing(
const std::string & line ,
bool & ) ;
172 void doApop(
const std::string & line ,
bool & ) ;
173 void doTop(
const std::string & line ,
bool & ) ;
174 void doCapa(
const std::string & line ,
bool & ) ;
175 void doStls(
const std::string & line ,
bool & ) ;
176 void doAuth(
const std::string & line ,
bool & ) ;
177 void doAuthData(
const std::string & line ,
bool & ) ;
178 void doAuthComplete(
const std::string & line ,
bool & ) ;
179 void doUidl(
const std::string & line ,
bool & ) ;
182 void sendError(
const std::string & ) ;
184 int commandNumber(
const std::string & ,
int , std::size_t index = 1U )
const ;
185 void sendList(
const std::string & ,
bool ) ;
186 std::string commandWord(
const std::string & )
const ;
187 std::string commandParameter(
const std::string & , std::size_t index = 1U )
const ;
188 static std::string commandPart(
const std::string & , std::size_t index ) ;
189 static Event commandEvent( std::string_view ) ;
191 bool sendContentLine( std::string & ,
bool & ) ;
192 void sendLine( std::string_view ,
bool has_crlf =
false ) ;
193 void sendLine( std::string && ) ;
194 void sendLines( std::ostringstream & ) ;
195 void readStore(
const std::string & ) ;
196 std::string mechanisms()
const ;
197 bool mechanismsIncludePlain()
const ;
200 const Text & m_text ;
202 Security & m_security ;
205 std::unique_ptr<StoreUser> m_store_user ;
206 StoreList m_store_list ;
207 std::unique_ptr<GAuth::SaslServer> m_sasl ;
211 std::unique_ptr<std::istream> m_content ;
212 long m_body_limit {-1L} ;
213 bool m_in_body {
false} ;
214 bool m_secure {
false} ;
215 bool m_sasl_init_apop {
false} ;
235 std::string greeting()
const override ;
236 std::string quit()
const override ;
237 std::string capa()
const override ;
238 std::string user(
const std::string &
id )
const override ;
242inline GPop::ServerProtocol::Config & GPop::ServerProtocol::Config::set_sasl_server_challenge_domain(
const std::string & s ) { sasl_server_challenge_domain = s ;
return *this ; }
An interface used by GAuth::SaslServer to obtain authentication secrets.
The GNet::Address class encapsulates a TCP/UDP transport address.
A default implementation for the ServerProtocol::Text interface.
ServerProtocolText(const GNet::Address &peer)
Constructor.
An interface used by ServerProtocol to enable TLS.
An interface used by ServerProtocol to send protocol replies.
An interface used by ServerProtocol to provide response text strings.
Implements the POP server-side protocol.
void resume()
Called when the Sender can send again.
void secure()
Called when the server connection becomes secure.
void init()
Starts the protocol.
void apply(const std::string &line)
Called on receipt of a string from the client.
ServerProtocol(Sender &sender, Security &security, Store &store, const GAuth::SaslServerSecrets &server_secrets, const std::string &sasl_server_config, const Text &text, const GNet::Address &peer_address, const Config &config)
Constructor.
constexpr const char * tx(const char *p) noexcept
A briefer alternative to G::gettext_noop().
A structure containing configuration parameters for ServerProtocol.