You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
#ifndef _SMTPD_PROTOCOL_
|
|
#define _SMTPD_PROTOCOL_
|
|
|
|
#include <smtpd/session.hpp>
|
|
#include <smtpd/message.hpp>
|
|
#include <smtpd/token.hpp>
|
|
#include <smtpd/types.hpp>
|
|
|
|
#include <string>
|
|
#include <memory>
|
|
#include <functional>
|
|
#include <map>
|
|
#include <any>
|
|
|
|
namespace smtpd {
|
|
class Protocol;
|
|
class Request;
|
|
|
|
using ProtocolListener = std::function<void(Protocol & protocol, const Message & message)>;
|
|
using SessionMap = std::unordered_map<SessionID, Session>;
|
|
|
|
class Protocol {
|
|
public:
|
|
std::string version;
|
|
|
|
Protocol();
|
|
|
|
void addListener(const TokenPattern & pattern, ProtocolListener listener);
|
|
void send(const TokenPattern & pattern);
|
|
|
|
SessionMap sessions;
|
|
|
|
protected:
|
|
virtual void emit(std::string output) = 0;
|
|
void absorb(std::string input);
|
|
|
|
private:
|
|
std::multimap<TokenPattern, ProtocolListener> listeners;
|
|
|
|
static void configListener(Protocol & protocol, const Message & message);
|
|
static void sessionListener(Protocol & protocol, const Message & message);
|
|
static void requestListener(Protocol & protocol, const Message & message);
|
|
};
|
|
|
|
}
|
|
|
|
#endif |