MEDIUM: log-format: backend source address %Bi %Bp
%Bi return the backend source IP
%Bp return the backend source port
Add a function pointer in logformat_type to do additional configuration
during the log-format variable parsing.
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index ea3692c..80f1e36 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -437,6 +437,14 @@
}
}
+ /* needs src ip/port for logging */
+ if (si->flags & SI_FL_SRC_ADDR) {
+ socklen_t addrlen = sizeof(si->addr.to);
+ if (getsockname(fd, (struct sockaddr *)&si->addr.from, &addrlen) == -1) {
+ Warning("Cannot get source address for logging.\n");
+ }
+ }
+
fdtab[fd].owner = si;
fdtab[fd].state = FD_STCONN; /* connection in progress */
fdtab[fd].flags = FD_FL_TCP | FD_FL_TCP_NODELAY;