Module: ngircd.git Branch: master Commit: 54879b432b99bb22df905b8e22c3f83205ea8d60 URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=54879...
Author: Alexander Barton alex@barton.de Date: Fri Apr 10 13:22:03 2009 +0200
Display IPv6 addresses as "[<addr>]" when accepting connections.
With this patch ngIRCd displays IPv6 addresses as "[<addr>]:<port>" when accepting new connections and later, if no successful DNS lookup could be made (or DNS is disabled altogether).
---
src/ngircd/conn.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index bd1a5bd..5b52511 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -1261,14 +1261,21 @@ New_Connection( int Sock ) My_Connections[new_sock].addr = new_addr; My_Connections[new_sock].client = c;
- Log( LOG_INFO, "Accepted connection %d from %s:%d on socket %d.", new_sock, - ip_str, ng_ipaddr_getport(&new_addr), Sock); - - /* Hostnamen ermitteln */ - strlcpy(My_Connections[new_sock].host, ip_str, sizeof(My_Connections[new_sock].host)); + /* Set initial hostname to IP address. This becomes overwritten when + * the DNS lookup is enabled and succeeds, but is used otherwise. */ + if (ng_ipaddr_af(&new_addr) != AF_INET) + snprintf(My_Connections[new_sock].host, + sizeof(My_Connections[new_sock].host), "[%s]", ip_str); + else + strlcpy(My_Connections[new_sock].host, ip_str, + sizeof(My_Connections[new_sock].host));
Client_SetHostname(c, My_Connections[new_sock].host);
+ Log(LOG_INFO, "Accepted connection %d from %s:%d on socket %d.", + new_sock, My_Connections[new_sock].host, + ng_ipaddr_getport(&new_addr), Sock); + identsock = new_sock; #ifdef IDENTAUTH if (Conf_NoIdent)