diff options
Diffstat (limited to 'win/tclWinSock.c')
-rw-r--r-- | win/tclWinSock.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/win/tclWinSock.c b/win/tclWinSock.c index 4f50a91..66c988a 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinSock.c,v 1.74.2.3 2010/10/20 01:50:19 kennykb Exp $ + * RCS: @(#) $Id: tclWinSock.c,v 1.74.2.4 2010/10/28 19:42:20 kennykb Exp $ * * ----------------------------------------------------------------------- * @@ -2078,6 +2078,8 @@ TcpGetOptionProc( char host[NI_MAXHOST], port[NI_MAXSERV]; SOCKET sock; size_t len = 0; + int reverseDNS = 0; +#define SUPPRESS_RDNS_VAR "::tcl::unsupported::noReverseDNS" /* * Check that WinSock is initialized; do not call it if not, to prevent @@ -2117,6 +2119,10 @@ TcpGetOptionProc( return TCL_OK; } + if (interp != NULL && Tcl_GetVar(interp, SUPPRESS_RDNS_VAR, 0) != NULL) { + reverseDNS = NI_NUMERICHOST; + } + if ((len == 0) || ((len > 1) && (optionName[1] == 'p') && (strncmp(optionName, "-peername", len) == 0))) { address peername; @@ -2131,7 +2137,7 @@ TcpGetOptionProc( NULL, 0, NI_NUMERICHOST); Tcl_DStringAppendElement(dsPtr, host); getnameinfo(&(peername.sa), size, host, sizeof(host), - port, sizeof(port), NI_NUMERICSERV); + port, sizeof(port), reverseDNS | NI_NUMERICSERV); Tcl_DStringAppendElement(dsPtr, host); Tcl_DStringAppendElement(dsPtr, port); if (len == 0) { @@ -2174,7 +2180,7 @@ TcpGetOptionProc( sock = fds->fd; size = sizeof(sockname); if (getsockname(sock, &(sockname.sa), &size) >= 0) { - int flags; + int flags = reverseDNS; found = 1; getnameinfo(&sockname.sa, size, host, sizeof(host), @@ -2185,7 +2191,7 @@ TcpGetOptionProc( * We don't want to resolve INADDR_ANY and sin6addr_any; they * can sometimes cause problems (and never have a name). */ - flags = NI_NUMERICSERV; + flags |= NI_NUMERICSERV; if (sockname.sa.sa_family == AF_INET) { if (sockname.sa4.sin_addr.s_addr == INADDR_ANY) { flags |= NI_NUMERICHOST; |