masaori335 commented on a change in pull request #7802:
URL: https://github.com/apache/trafficserver/pull/7802#discussion_r630638020
##########
File path: iocore/net/SSLUtils.cc
##########
@@ -299,7 +300,27 @@ set_context_cert(SSL *ssl)
IpEndpoint ip;
int namelen = sizeof(ip);
- if (0 == safe_getsockname(netvc->get_socket(), &ip.sa, &namelen)) {
+ SSLCertificateConfig::scoped_config lookup;
+ if (netvc->get_is_proxy_protocol() && netvc->get_proxy_protocol_version()
!= ProxyProtocolVersion::UNDEFINED) {
+ ip.sa = *(netvc->get_proxy_protocol_dst_addr());
+ ip_port_text_buffer ipb1;
Review comment:
Sorry for nitpicking, how's this? I think we don't need to call
`ats_ip_nptop(&ip, ipb1, sizeof(ipb1));` twice.
```
ip.sa = *(netvc->get_proxy_protocol_dst_addr());
cc = lookup->find(ip);
if (is_debug_tag_set("proxyprotocol")) {
IpEndpoint src;
int ip_len = sizeof(src);
if (0 != safe_getpeername(netvc->get_socket(), &src.sa, &ip_len)) {
Debug("proxyprotocol", "Failed to get src ip, errno = [%d]",
errno);
return EVENT_ERROR;
}
ip_port_text_buffer ipb1;
ip_port_text_buffer ipb2;
ats_ip_nptop(&ip, ipb1, sizeof(ipb1));
ats_ip_nptop(&src, ipb2, sizeof(ipb2));
Debug("proxyprotocol", "IP context is %p for [%s] -> [%s], default
context %p", cc, ipb2, ipb1, lookup->defaultContext());
}
```
If you want, I can open a PR after this is merged :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]