mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-24 23:31:40 +02:00
MINOR: frontend: Rely on client src and dst addresses at stream level
For now, stream-interface or session addresses are never set. So, thanks to the fallback mechanism, no changes are expected with this patch. But its purpose is to rely on the client addresses at the stream level, when set, instead of those at the connection level. The addresses are retrieved from the frontend stream-interface.
This commit is contained in:
parent
859ff84f8c
commit
c9c8e1cc01
@ -47,6 +47,7 @@
|
||||
*/
|
||||
int frontend_accept(struct stream *s)
|
||||
{
|
||||
const struct sockaddr_storage *src, *dst;
|
||||
struct session *sess = s->sess;
|
||||
struct connection *conn = objt_conn(sess->origin);
|
||||
struct listener *l = sess->listener;
|
||||
@ -60,26 +61,28 @@ int frontend_accept(struct stream *s)
|
||||
if (!(s->logs.logwait &= ~(LW_CLIP|LW_INIT)))
|
||||
s->do_log(s);
|
||||
}
|
||||
else if (conn && !conn_get_src(conn)) {
|
||||
else if (conn) {
|
||||
src = si_src(&s->si[0]);
|
||||
if (!src)
|
||||
send_log(fe, LOG_INFO, "Connect from unknown source to listener %d (%s/%s)\n",
|
||||
l->luid, fe->id, (fe->mode == PR_MODE_HTTP) ? "HTTP" : "TCP");
|
||||
}
|
||||
else if (conn) {
|
||||
else {
|
||||
char pn[INET6_ADDRSTRLEN], sn[INET6_ADDRSTRLEN];
|
||||
int port;
|
||||
|
||||
switch (addr_to_str(conn->src, pn, sizeof(pn))) {
|
||||
switch (addr_to_str(src, pn, sizeof(pn))) {
|
||||
case AF_INET:
|
||||
case AF_INET6:
|
||||
if (conn_get_dst(conn)) {
|
||||
addr_to_str(conn->dst, sn, sizeof(sn));
|
||||
port = get_host_port(conn->dst);
|
||||
dst = si_dst(&s->si[0]);
|
||||
if (dst) {
|
||||
addr_to_str(dst, sn, sizeof(sn));
|
||||
port = get_host_port(dst);
|
||||
} else {
|
||||
strcpy(sn, "undetermined address");
|
||||
port = 0;
|
||||
}
|
||||
send_log(fe, LOG_INFO, "Connect from %s:%d to %s:%d (%s/%s)\n",
|
||||
pn, get_host_port(conn->src),
|
||||
pn, get_host_port(src),
|
||||
sn, port,
|
||||
fe->id, (fe->mode == PR_MODE_HTTP) ? "HTTP" : "TCP");
|
||||
break;
|
||||
@ -92,6 +95,7 @@ int frontend_accept(struct stream *s)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (unlikely((global.mode & MODE_DEBUG) && conn &&
|
||||
(!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)))) {
|
||||
@ -109,17 +113,18 @@ int frontend_accept(struct stream *s)
|
||||
}
|
||||
}
|
||||
|
||||
if (!conn_get_src(conn)) {
|
||||
src = si_src(&s->si[0]);
|
||||
if (!src) {
|
||||
chunk_printf(&trash, "%08x:%s.accept(%04x)=%04x from [listener:%d] ALPN=%s\n",
|
||||
s->uniq_id, fe->id, (unsigned short)l->rx.fd, (unsigned short)conn->handle.fd,
|
||||
l->luid, alpn);
|
||||
}
|
||||
else switch (addr_to_str(conn->src, pn, sizeof(pn))) {
|
||||
else switch (addr_to_str(src, pn, sizeof(pn))) {
|
||||
case AF_INET:
|
||||
case AF_INET6:
|
||||
chunk_printf(&trash, "%08x:%s.accept(%04x)=%04x from [%s:%d] ALPN=%s\n",
|
||||
s->uniq_id, fe->id, (unsigned short)l->rx.fd, (unsigned short)conn->handle.fd,
|
||||
pn, get_host_port(conn->src), alpn);
|
||||
pn, get_host_port(src), alpn);
|
||||
break;
|
||||
case AF_UNIX:
|
||||
/* UNIX socket, only the destination is known */
|
||||
|
Loading…
x
Reference in New Issue
Block a user