g3-dpi: add port for On-Demand Mail Relay protocol

This commit is contained in:
Zhang Jingqiang 2024-05-15 19:21:08 +08:00
parent ca80f9df27
commit 2a64efcc3a
12 changed files with 16 additions and 1 deletions

View file

@ -300,6 +300,8 @@ The code should comply to these, but should be more compliant to existing popula
: Simple Mail Transfer Protocol
- [rfc6409](https://datatracker.ietf.org/doc/html/rfc6409)
: Message Submission for Mail
- [rfc2645](https://datatracker.ietf.org/doc/html/rfc2645)
: ON-DEMAND MAIL RELAY (ODMR) SMTP with Dynamic IP Addresses
- [rfc6152](https://datatracker.ietf.org/doc/html/rfc6152)
: SMTP Service Extension for 8-bit MIME Transport
- [rfc3030](https://datatracker.ietf.org/doc/html/rfc3030)

View file

@ -197,6 +197,7 @@ impl Initiation {
"RRVS" => true, // Require Recipient Valid Since, RFC7293, add a RCPT param key
"REQUIRETLS" => true, // Require TLS, RFC8689, add a MAIL param key
"LIMITS" => true, // LIMITS, RFC9422
"ATRN" => true, // On-Demand Mail Relay, RFC2645, change the protocol
_ => false,
}
}

View file

@ -40,6 +40,7 @@ impl ProtocolInspectState {
self.exclude_other(MaybeProtocol::Ftp);
self.exclude_other(MaybeProtocol::Ssh);
self.exclude_other(MaybeProtocol::Smtp);
self.exclude_other(MaybeProtocol::Odmr);
self.exclude_other(MaybeProtocol::Pop3);
self.exclude_other(MaybeProtocol::Imap);
self.exclude_other(MaybeProtocol::Http);

View file

@ -38,6 +38,7 @@ impl ProtocolInspectState {
// 0x31
self.ftp_exclude_by_byte0();
self.exclude_other(MaybeProtocol::Smtp);
self.exclude_other(MaybeProtocol::Odmr);
self.exclude_other(MaybeProtocol::Nntp);
if &data[0..3] == b"120" {
@ -63,6 +64,7 @@ impl ProtocolInspectState {
// 0x34
self.ftp_exclude_by_byte0();
self.exclude_other(MaybeProtocol::Smtp);
self.exclude_other(MaybeProtocol::Odmr);
self.exclude_other(MaybeProtocol::Nntp);
if &data[0..3] == b"421" {

View file

@ -43,6 +43,7 @@ impl ProtocolInspectState {
self.exclude_other(MaybeProtocol::Ftp);
self.exclude_other(MaybeProtocol::Ssh);
self.exclude_other(MaybeProtocol::Smtp);
self.exclude_other(MaybeProtocol::Odmr);
self.exclude_other(MaybeProtocol::Pop3);
self.exclude_other(MaybeProtocol::Nntp);
self.exclude_other(MaybeProtocol::Nats);

View file

@ -110,6 +110,7 @@ impl ProtocolInspectState {
MaybeProtocol::BitTorrent => self.check_bittorrent_tcp_handshake(data),
MaybeProtocol::Ftp
| MaybeProtocol::Smtp
| MaybeProtocol::Odmr
| MaybeProtocol::Pop3
| MaybeProtocol::Nntp
| MaybeProtocol::Nnsp
@ -147,7 +148,7 @@ impl ProtocolInspectState {
match proto {
MaybeProtocol::Ftp => self.check_ftp_server_greeting(data, size_limit),
MaybeProtocol::Ssh => self.check_ssh_server_protocol_version_exchange(data),
MaybeProtocol::Smtp => self.check_smtp_server_greeting(data),
MaybeProtocol::Smtp | MaybeProtocol::Odmr => self.check_smtp_server_greeting(data),
MaybeProtocol::Pop3 => self.check_pop3_server_greeting(data),
MaybeProtocol::Nntp | MaybeProtocol::Nnsp => self.check_nntp_server_greeting(data),
MaybeProtocol::Imap => self.check_imap_server_greeting(data, size_limit),

View file

@ -31,6 +31,7 @@ pub use portmap::{ProtocolPortMap, ProtocolPortMapValue};
pub enum MaybeProtocol {
Http,
Smtp,
Odmr, // On-Demand Mail Relay, a restricted profile of SMTP
Ssh,
Ftp,
Dns,
@ -88,6 +89,7 @@ impl FromStr for MaybeProtocol {
match s.to_lowercase().as_str() {
"http" => Ok(MaybeProtocol::Http),
"smtp" => Ok(MaybeProtocol::Smtp),
"odmr" => Ok(MaybeProtocol::Odmr),
"ssh" => Ok(MaybeProtocol::Ssh),
"ftp" => Ok(MaybeProtocol::Ftp),
"pop3" => Ok(MaybeProtocol::Pop3),

View file

@ -42,6 +42,7 @@ impl ProtocolInspectState {
self.exclude_other(MaybeProtocol::Ftp);
self.exclude_other(MaybeProtocol::Ssh);
self.exclude_other(MaybeProtocol::Smtp);
self.exclude_other(MaybeProtocol::Odmr);
self.exclude_other(MaybeProtocol::Pop3);
self.exclude_other(MaybeProtocol::Nntp);
self.exclude_other(MaybeProtocol::Imap);

View file

@ -57,6 +57,7 @@ impl ProtocolInspectState {
// exclude impossible protocols
self.exclude_other(MaybeProtocol::Ftp);
self.exclude_other(MaybeProtocol::Smtp);
self.exclude_other(MaybeProtocol::Odmr);
if !matches!(data[2], b'0' | b'1') {
self.exclude_current();

View file

@ -46,6 +46,7 @@ impl ProtocolInspectState {
self.exclude_other(MaybeProtocol::Ftp);
self.exclude_other(MaybeProtocol::Ssh);
self.exclude_other(MaybeProtocol::Smtp);
self.exclude_other(MaybeProtocol::Odmr);
self.exclude_other(MaybeProtocol::Nntp);
self.exclude_other(MaybeProtocol::Imap);
self.exclude_other(MaybeProtocol::Nats);

View file

@ -128,6 +128,7 @@ impl ProtocolPortMap {
map.insert(119, MaybeProtocol::Nntp);
map.insert(143, MaybeProtocol::Imap);
map.insert(322, MaybeProtocol::Rtsps);
map.insert(366, MaybeProtocol::Odmr);
map.insert(433, MaybeProtocol::Nnsp);
map.insert(443, MaybeProtocol::Https);
map.insert(465, MaybeProtocol::Submissions);

View file

@ -118,6 +118,7 @@ impl ProtocolInspectState {
// exclude impossible protocols
self.exclude_other(MaybeProtocol::Ftp);
self.exclude_other(MaybeProtocol::Smtp);
self.exclude_other(MaybeProtocol::Odmr);
self.exclude_other(MaybeProtocol::Pop3);
self.exclude_other(MaybeProtocol::Nntp);
self.exclude_other(MaybeProtocol::Imap);