summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrmax <rmax>2010-10-26 13:14:08 (GMT)
committerrmax <rmax>2010-10-26 13:14:08 (GMT)
commit74c67fdfe6a0ffd668bac120a258b398bd2feb97 (patch)
treebb5d12bd4765004fd99c1273f20a567b3ecf825e
parente2b1415b27c47fed243c2c335fb46306497f4020 (diff)
downloadtcl-74c67fdfe6a0ffd668bac120a258b398bd2feb97.zip
tcl-74c67fdfe6a0ffd668bac120a258b398bd2feb97.tar.gz
tcl-74c67fdfe6a0ffd668bac120a258b398bd2feb97.tar.bz2
Add support for ::tcl::unsupported::noReverseDNS
-rw-r--r--ChangeLog7
-rw-r--r--unix/tclUnixSock.c13
-rw-r--r--win/tclWinSock.c13
3 files changed, 25 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 8ac09fd..39f8f9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-10-26 Reinhard Max <max@suse.de>
+
+ * unix/tclUnixSock.c (TcpGetOptionProc): Added support for
+ ::tcl::unsupported::noReverseDNS, which if set, prevents
+ [fconfigure -sockname] and [fconfigure -peername] from doing
+ reverse DNS queries.
+
2010-10-17 Alexandre Ferrieux <ferrieux@users.sourceforge.net>
* doc/info.n : [Patch 2995655] :
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;
diff --git a/win/tclWinSock.c b/win/tclWinSock.c
index 1976d4b..7f3dbac 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.77 2010/10/12 10:21:55 nijtmans Exp $
+ * RCS: @(#) $Id: tclWinSock.c,v 1.78 2010/10/26 13:14:09 rmax Exp $
*
* -----------------------------------------------------------------------
*
@@ -2078,6 +2078,7 @@ TcpGetOptionProc(
char host[NI_MAXHOST], port[NI_MAXSERV];
SOCKET sock;
size_t len = 0;
+ int reverseDNS = 0;
/*
* Check that WinSock is initialized; do not call it if not, to prevent
@@ -2117,6 +2118,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))) {
address peername;
@@ -2131,7 +2136,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 +2179,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 +2190,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;