Mercurial > dnsbl
diff src/context.cpp @ 311:f5547e7b3a09
enable smtp verify logging
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 19 Sep 2016 09:11:30 -0700 |
parents | 802e2b779ed1 |
children | ef5a6099cbe7 |
line wrap: on
line diff
--- a/src/context.cpp Sun Sep 18 18:32:37 2016 -0700 +++ b/src/context.cpp Mon Sep 19 09:11:30 2016 -0700 @@ -175,6 +175,7 @@ flush_line(r); continue; } + log("read_response() sees line with %s", buffer); return atoi(buffer); } return 0; @@ -216,6 +217,7 @@ if (strncmp(efrom, f, maxlen)) { rset(); strncpy(efrom, f, maxlen); + efrom[maxlen-1] = '\0'; // ensure null termination init(); append("MAIL FROM:<"); if (*f != '<') append(f); @@ -246,7 +248,6 @@ } -#ifdef VERIFY_DEBUG void SMTP::log(const char *m, int v) { char buf[maxlen]; snprintf(buf, maxlen, m, v); @@ -259,7 +260,6 @@ snprintf(buf, maxlen, m, v); my_syslog(queueid, buf); } -#endif //////////////////////////////////////////////// @@ -304,11 +304,12 @@ } -SMTP* VERIFY::get_connection() { +SMTP* VERIFY::get_connection(const char *queueid) { SMTP *conn = NULL; pthread_mutex_lock(&mutex); if (!connections.empty()) { conn = connections.front(); + conn->set_id(queueid); connections.pop_front(); #ifdef VERIFY_DEBUG conn->log("get_connection() %d from cache", conn->get_fd()); @@ -341,10 +342,13 @@ } if (sock != NULL_SOCKET) { conn = new SMTP(sock); + conn->set_id(queueid); #ifdef VERIFY_DEBUG conn->log("get_connection() %d new socket", conn->get_fd()); #endif - if (conn->helo() == 250) return conn; + int rc = conn->helo(); + conn->log("verify::get_connection() helo sees %d", rc); + if (rc == 250) return conn; delete conn; } return NULL; @@ -373,23 +377,17 @@ bool VERIFY::ok(const char *queueid, const char *from, const char *to) { if (host == token_myhostname) return true; - SMTP *conn = get_connection(); + SMTP *conn = get_connection(queueid); if (!conn) return true; // cannot verify right now, we have socket errors int rc; - conn->set_id(queueid); rc = conn->from(from); - #ifdef VERIFY_DEBUG conn->log("verify::ok() from sees %d", rc); - #endif if (rc != 250) { - conn->rset(); put_connection(conn); return (rc >= 500) ? false : true; } rc = conn->rcpt(to); - #ifdef VERIFY_DEBUG conn->log("verify::ok() rcpt sees %d", rc); - #endif put_connection(conn); return (rc >= 500) ? false : true; }