[nginx] Mail: output client port number on client connects (tick...

Ruslan Ermilov ru at nginx.com
Wed May 21 20:18:56 UTC 2014


details:   http://hg.nginx.org/nginx/rev/d5b8ee9f2201
branches:  
changeset: 5705:d5b8ee9f2201
user:      Ruslan Ermilov <ru at nginx.com>
date:      Thu May 22 00:16:17 2014 +0400
description:
Mail: output client port number on client connects (ticket #531).

diffstat:

 src/mail/ngx_mail_handler.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r 524741fd50ed -r d5b8ee9f2201 src/mail/ngx_mail_handler.c
--- a/src/mail/ngx_mail_handler.c	Thu May 22 00:16:09 2014 +0400
+++ b/src/mail/ngx_mail_handler.c	Thu May 22 00:16:17 2014 +0400
@@ -22,6 +22,7 @@ static void ngx_mail_ssl_handshake_handl
 void
 ngx_mail_init_connection(ngx_connection_t *c)
 {
+    size_t                 len;
     ngx_uint_t             i;
     ngx_mail_port_t       *port;
     struct sockaddr       *sa;
@@ -30,6 +31,7 @@ ngx_mail_init_connection(ngx_connection_
     ngx_mail_in_addr_t    *addr;
     ngx_mail_session_t    *s;
     ngx_mail_addr_conf_t  *addr_conf;
+    u_char                 text[NGX_SOCKADDR_STRLEN];
 #if (NGX_HAVE_INET6)
     struct sockaddr_in6   *sin6;
     ngx_mail_in6_addr_t   *addr6;
@@ -127,8 +129,10 @@ ngx_mail_init_connection(ngx_connection_
     c->data = s;
     s->connection = c;
 
-    ngx_log_error(NGX_LOG_INFO, c->log, 0, "*%uA client %V connected to %V",
-                  c->number, &c->addr_text, s->addr_text);
+    len = ngx_sock_ntop(c->sockaddr, c->socklen, text, NGX_SOCKADDR_STRLEN, 1);
+
+    ngx_log_error(NGX_LOG_INFO, c->log, 0, "*%uA client %*s connected to %V",
+                  c->number, len, text, s->addr_text);
 
     ctx = ngx_palloc(c->pool, sizeof(ngx_mail_log_ctx_t));
     if (ctx == NULL) {



More information about the nginx-devel mailing list