diff options
author | rmax <rmax> | 2010-10-26 13:14:08 (GMT) |
---|---|---|
committer | rmax <rmax> | 2010-10-26 13:14:08 (GMT) |
commit | 74c67fdfe6a0ffd668bac120a258b398bd2feb97 (patch) | |
tree | bb5d12bd4765004fd99c1273f20a567b3ecf825e /unix/tclUnixSock.c | |
parent | e2b1415b27c47fed243c2c335fb46306497f4020 (diff) | |
download | tcl-74c67fdfe6a0ffd668bac120a258b398bd2feb97.zip tcl-74c67fdfe6a0ffd668bac120a258b398bd2feb97.tar.gz tcl-74c67fdfe6a0ffd668bac120a258b398bd2feb97.tar.bz2 |
Add support for ::tcl::unsupported::noReverseDNS
Diffstat (limited to 'unix/tclUnixSock.c')
-rw-r--r-- | unix/tclUnixSock.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c index 6c434ab..7507356 100644 --- a/unix/tclUnixSock.c +++ b/unix/tclUnixSock.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: tclUnixSock.c,v 1.28 2010/10/12 11:37:22 rmax Exp $ + * RCS: @(#) $Id: tclUnixSock.c,v 1.29 2010/10/26 13:14:09 rmax Exp $ */ #include "tclInt.h" @@ -623,6 +623,7 @@ TcpGetOptionProc( char host[NI_MAXHOST], port[NI_MAXSERV]; size_t len = 0; + int reverseDNS = 0; if (optionName != NULL) { len = strlen(optionName); @@ -644,6 +645,10 @@ TcpGetOptionProc( return TCL_OK; } + if (Tcl_GetVar(interp, "::tcl::unsupported::noReverseDNS", 0) != NULL) { + reverseDNS = NI_NUMERICHOST; + } + if ((len == 0) || ((len > 1) && (optionName[1] == 'p') && (strncmp(optionName, "-peername", len) == 0))) { @@ -660,7 +665,7 @@ TcpGetOptionProc( NI_NUMERICHOST); Tcl_DStringAppendElement(dsPtr, host); getnameinfo(&peername.sa, size, host, sizeof(host), port, - sizeof(port), NI_NUMERICSERV); + sizeof(port), reverseDNS | NI_NUMERICSERV); Tcl_DStringAppendElement(dsPtr, host); Tcl_DStringAppendElement(dsPtr, port); if (len == 0) { @@ -701,7 +706,7 @@ TcpGetOptionProc( for (fds = statePtr->fds; fds != NULL; fds = fds->next) { size = sizeof(sockname); if (getsockname(fds->fd, &(sockname.sa), &size) >= 0) { - int flags; + int flags = reverseDNS; found = 1; getnameinfo(&sockname.sa, size, host, sizeof(host), NULL, 0, @@ -713,7 +718,7 @@ TcpGetOptionProc( * 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; |