Add support for smtp protocol detection

This commit is contained in:
Michael Scherer 2016-06-04 15:30:47 +02:00
parent 63a83cf041
commit ad6153eb88
2 changed files with 16 additions and 1 deletions

10
probe.c
View File

@ -40,6 +40,7 @@ static int is_xmpp_protocol(const char *p, int len, struct proto*);
static int is_http_protocol(const char *p, int len, struct proto*);
static int is_tls_protocol(const char *p, int len, struct proto*);
static int is_adb_protocol(const char *p, int len, struct proto*);
static int is_smtp_protocol(const char *p, int len, struct proto*);
static int is_true(const char *p, int len, struct proto* proto) { return 1; }
/* Table of protocols that have a built-in probe
@ -54,6 +55,7 @@ static struct proto builtins[] = {
{ "ssl", NULL, NULL, 1, 0, is_tls_protocol },
{ "tls", NULL, NULL, 1, 0, is_tls_protocol },
{ "adb", NULL, NULL, 1, 0, is_adb_protocol },
{ "smtp", NULL, NULL, 1, 0, is_smtp_protocol },
{ "anyprot", NULL, NULL, 1, 0, is_true }
};
@ -262,6 +264,14 @@ static int is_adb_protocol(const char *p, int len, struct proto *proto)
return !memcmp(&p[0], "CNXN", 4) && !memcmp(&p[24], "host:", 5);
}
static int is_smtp_protocol(const char *p, int len, struct proto *proto)
{
if (len < 5)
return PROBE_AGAIN;
return !strncmp(p, "HELO ", 5) || !strncmp(p, "EHLO ", 5);
}
static int regex_probe(const char *p, int len, struct proto *proto)
{
#ifdef ENABLE_REGEX

View File

@ -14,7 +14,7 @@ B<sslh> accepts connections on specified ports, and forwards
them further based on tests performed on the first data
packet sent by the remote client.
Probes for HTTP, SSL, SSH, OpenVPN, tinc, XMPP are
Probes for HTTP, SSL, SSH, OpenVPN, tinc, XMPP, SMTP are
implemented, and any other protocol that can be tested using
a regular expression, can be recognised. A typical use case
is to allow serving several services on port 443 (e.g. to
@ -146,6 +146,11 @@ typically I<localhost:5222>.
Interface and port on which to forward HTTP connections,
typically I<localhost:80>.
=item B<--smtp> I<target address>
Interface and port on which to forward SMTP connections,
typically I<localhost:25>.
=item B<--tinc> I<target address>
Interface and port on which to forward tinc connections,