diff options
author | Stef Walter <stef@memberwebs.com> | 2007-03-20 02:36:52 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2007-03-20 02:36:52 +0000 |
commit | 00aa6f6162ec2e181a6e97a47f3c8c5c69188ab4 (patch) | |
tree | d82f6919a5d00d2289cea3e6281875d15713d148 /common/smtppass.c | |
parent | cc384c282d16ee733d2971c3ecf16a866babeeec (diff) |
- Resolve any DNS name for each connection.
Diffstat (limited to 'common/smtppass.c')
-rw-r--r-- | common/smtppass.c | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/common/smtppass.c b/common/smtppass.c index a783bac..96fe0b1 100644 --- a/common/smtppass.c +++ b/common/smtppass.c @@ -767,30 +767,38 @@ static int make_connections(spctx_t* ctx, int client) outaddr = &addr; } - /* No transparent proxy but check for loopback option */ - else + /* Check for loopback option */ + else if(SANY_TYPE(*outaddr) == AF_INET && + outaddr->s.in.sin_addr.s_addr == 0) { - if(SANY_TYPE(*outaddr) == AF_INET && - outaddr->s.in.sin_addr.s_addr == 0) - { - /* Use the incoming IP as the default */ - memcpy(&addr, &(g_state.outaddr), sizeof(addr)); - memcpy(&(addr.s.in.sin_addr), &(peeraddr.s.in.sin_addr), sizeof(addr.s.in.sin_addr)); - outaddr = &addr; - } + /* Use the incoming IP as the default */ + memcpy(&addr, &(g_state.outaddr), sizeof(addr)); + memcpy(&(addr.s.in.sin_addr), &(peeraddr.s.in.sin_addr), sizeof(addr.s.in.sin_addr)); + outaddr = &addr; + } #ifdef HAVE_INET6 - else if(SANY_TYPE(*outaddr) == AF_INET6 && - outaddr->s.in.in6.sin_addr.s_addr == 0) - { - /* Use the incoming IP as the default */ - memcpy(&addr, &(g_state.outaddr), sizeof(addr)); - memcpy(&(addr.s.in.sin6_addr), &(peeraddr.s.in.sin6_addr), sizeof(addr.s.in.sin6_addr)); - outaddr = &addr; - } + /* IPv6 loopback? */ + else if(SANY_TYPE(*outaddr) == AF_INET6 && + outaddr->s.in.in6.sin_addr.s_addr == 0) + { + /* Use the incoming IP as the default */ + memcpy(&addr, &(g_state.outaddr), sizeof(addr)); + memcpy(&(addr.s.in.sin6_addr), &(peeraddr.s.in.sin6_addr), sizeof(addr.s.in.sin6_addr)); + outaddr = &addr; + } #endif + + /* Not transparent proxy or loopback */ + else + { + /* Resolve any DNS name again */ + if(sock_any_pton(g_state.outname, &addr, SANY_OPT_DEFPORT(25)) != -1) + memcpy(&(g_state.outaddr), &addr, sizeof(g_state.outaddr)); + else + sp_messagex(ctx, LOG_WARNING, "couldn't resolve " CFG_OUTADDR ": %s", g_state.outname); } - /* Reparse name if possible */ + /* Reparse name if needed */ if(outaddr != &(g_state.outaddr)) { if(sock_any_ntop(outaddr, buf, MAXPATHLEN, 0) != -1) |