View Issue Details

IDProjectCategoryView StatusLast Update
0000660XdebugFeature/Change requestpublic2011-06-14 16:04
ReporterbjoriAssigned Toderick 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformLinuxOSUbuntuOS Version10.10
Product Version2.2dev 
Target VersionFixed in Version2.2dev 
Summary0000660: Check X-HTTP-FORWARDED-FOR before falling back to REMOTE_ADDR
DescriptionCurrently xdebug has the option of connecting back to REMOTE_ADDR.
Loving that feature, but it doesn't account for proxy loving.

Attached is a patch to check for (and use if provided) X_HTTP_FORWARDED_FOR before checking REMOTE_ADDR.
TagsNo tags attached.
Operating SystemLinux
PHP Version5.3.3

Activities

bjori

2011-02-01 15:04

reporter  

xdebug.patch (1,862 bytes)
Index: xdebug_stack.c
===================================================================
--- xdebug_stack.c	(revision 3392)
+++ xdebug_stack.c	(working copy)
@@ -447,8 +447,14 @@
 	if (!XG(remote_enabled) && XG(remote_enable) && (XG(remote_mode) == XDEBUG_JIT)) {
 		if (XG(remote_connect_back)) {
 			zval **remote_addr = NULL;
-			zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "REMOTE_ADDR", 12, (void**)&remote_addr);
-			XG(context).socket = xdebug_create_socket(Z_STRVAL_PP(remote_addr), XG(remote_port));
+			if (zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "X_HTTP_FORWARDED_FOR", 21, (void**)&remote_addr) == FAILURE) {
+				zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "REMOTE_ADDR", 12, (void**)&remote_addr);
+			}
+			if (remote_addr) {
+				XG(context).socket = xdebug_create_socket(Z_STRVAL_PP(remote_addr), XG(remote_port));
+			} else {
+				XG(context).socket = xdebug_create_socket(XG(remote_host), XG(remote_port));
+			}
 		} else {
 			XG(context).socket = xdebug_create_socket(XG(remote_host), XG(remote_port));
 		}
Index: xdebug.c
===================================================================
--- xdebug.c	(revision 3392)
+++ xdebug.c	(working copy)
@@ -1197,7 +1197,9 @@
 			/* Initialize debugging session */
 			if (XG(remote_connect_back)) {
 				zval **remote_addr = NULL;
-				zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "REMOTE_ADDR", 12, (void**)&remote_addr);
+				if (zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "X_HTTP_FORWARDED_FOR", 21, (void**)&remote_addr) == FAILURE) {
+					zend_hash_find(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "REMOTE_ADDR", 12, (void**)&remote_addr);
+				}
 				if (remote_addr) {
 					XG(context).socket = xdebug_create_socket(Z_STRVAL_PP(remote_addr), XG(remote_port));
 				} else {
xdebug.patch (1,862 bytes)

derick

2011-02-10 23:37

administrator   ~0001669

Thanks for the patch!

Issue History

Date Modified Username Field Change
2011-02-01 15:04 bjori New Issue
2011-02-01 15:04 bjori File Added: xdebug.patch
2011-02-10 23:37 derick Note Added: 0001669
2011-02-10 23:37 derick Status new => closed
2011-02-10 23:37 derick Assigned To => derick
2011-02-10 23:37 derick Resolution open => fixed
2011-02-10 23:37 derick Fixed in Version => 2.2dev