Implement IPAddress::getClientAddress()
It was a stub that always returned "", so everything keyed on the client address saw an empty string: SPF checks in BARANTMail were run against no IP at all, Received: headers had no address, and IPAddressList black/white lists could never match. getClientAddressAndPort() also used inet_ntoa() (a static buffer shared across threads) and printed the port in network byte order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0121tAhQVe4qbCwYgVjKQS4B
This commit is contained in:
1 parent
4bfede1342
commit
4918654715
1 file changed
+11
-4
+11
-4
@@ -38,15 +38,22 @@ namespace core {
|
|||||||
return (sockaddr *)&addr;
|
return (sockaddr *)&addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Was a stub that always returned "" - so everything keyed on the
|
||||||
|
// client address (SPF checks in BARANTMail, Received: headers,
|
||||||
|
// IPAddressList black/white lists) silently saw an empty string.
|
||||||
std::string IPAddress::getClientAddress() {
|
std::string IPAddress::getClientAddress() {
|
||||||
std::string result;
|
char text[INET_ADDRSTRLEN];
|
||||||
return result;
|
if (!inet_ntop(AF_INET, &addr.sin_addr, text, sizeof(text)))
|
||||||
|
return "";
|
||||||
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string IPAddress::getClientAddressAndPort() {
|
std::string IPAddress::getClientAddressAndPort() {
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
out << inet_ntoa(addr.sin_addr);
|
// inet_ntoa() returns a static buffer shared by every thread, and
|
||||||
out << ":" << addr.sin_port;
|
// sin_port is in network byte order.
|
||||||
|
out << getClientAddress();
|
||||||
|
out << ":" << ntohs(addr.sin_port);
|
||||||
return out.str();
|
return out.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user