X-Git-Url: https://git.distorted.org.uk/~mdw/qmail/blobdiff_plain/212b6f5da7c68d4577de2855da3c57ecf476dc96..bcb3f3eb8800267d6f324a1bf1a8fb972c00054a:/qmail-smtpd.c diff --git a/qmail-smtpd.c b/qmail-smtpd.c index 1e28c88..6f453ce 100644 --- a/qmail-smtpd.c +++ b/qmail-smtpd.c @@ -93,6 +93,9 @@ void dohelo(arg) char *arg; { int liphostok = 0; stralloc liphost = {0}; +int relayhostsok = 0; +stralloc relayhosts = {0}; +struct constmap maprelayhosts; int bmfok = 0; stralloc bmf = {0}; struct constmap mapbmf; @@ -116,6 +119,16 @@ void setup() if (bmfok == -1) die_control(); if (bmfok) if (!constmap_init(&mapbmf,bmf.s,bmf.len,0)) die_nomem(); + + switch (control_readfile(&relayhosts, "control/relayhosts", 0)) { + case -1: + die_control(); + case 1: + relayhostsok = 1; + if (!constmap_init(&maprelayhosts, relayhosts.s, relayhosts.len, 1)) + die_nomem(); + } + if (control_readint(&databytes,"control/databytes") == -1) die_control(); x = env_get("DATABYTES"); @@ -131,6 +144,18 @@ void setup() if (!remotehost) remotehost = "unknown"; remoteinfo = env_get("TCPREMOTEINFO"); relayclient = env_get("RELAYCLIENT"); + if (!relayclient && relayhostsok) { + int j; + int l = str_len(remotehost); + relayclient = constmap(&maprelayhosts, remotehost, l); + if (!relayclient) for (j = 0; j < l; ++j) { + if (remotehost[j] == '.' && + (relayclient = constmap(&maprelayhosts, + remotehost + j, + l - j)) != 0) + break; + } + } dohelo(remotehost); }