From 106aa9136603aef6ff5c60011defec69724bdf1b Mon Sep 17 00:00:00 2001 From: Thor Harald Johansen Date: Sat, 6 Jun 2020 05:23:06 +0200 Subject: [PATCH] Added "junk" response to filter protocol --- include/protocol/protocol.hpp | 3 ++- src/protocol/protocol.cpp | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/protocol/protocol.hpp b/include/protocol/protocol.hpp index c92f957..49bcaf1 100644 --- a/include/protocol/protocol.hpp +++ b/include/protocol/protocol.hpp @@ -35,10 +35,11 @@ namespace protocol { void absorb(const std::string& input); void send(const token::list_t& tokens); + // TODO: Move these methods to a separate session_t class! void send_result(const session_key_t& session_key, token::list_t tokens); void proceed(const session_key_t& session_key); + void junk(const session_key_t& session_key); void fail(const session_key_t& session_key); - void submit_message(const session_key_t& session_key, const std::vector& header, const std::vector& body); protected: diff --git a/src/protocol/protocol.cpp b/src/protocol/protocol.cpp index bd74168..bb599cb 100644 --- a/src/protocol/protocol.cpp +++ b/src/protocol/protocol.cpp @@ -8,9 +8,8 @@ using namespace std; using namespace util; - //config|smtpd-version|6.6.1 - //config|smtp-session-timeout|300 - //config|subsystem|smtp-in +// OpenSMTPD filter protocol documentation: +// https://man7.org/linux/man-pages/man7/smtpd-filters.7.html const bool debug = true; @@ -24,10 +23,10 @@ namespace protocol { } } } + max_pattern_length = length; debug && cerr << "Maximum handler pattern length is " << length << endl; this->handlers = handlers; - max_pattern_length = length; } void protocol_t::send(const token::list_t& tokens) { @@ -59,6 +58,10 @@ namespace protocol { send_result(session_key, {"proceed"}); } + void protocol_t::junk(const session_key_t& session_key) { + send_result(session_key, {"junk"}); + } + void protocol_t::fail(const session_key_t& session_key) { send_result(session_key, {"disconnect", "451 Aborted"}); }