View Issue Details

IDProjectCategoryView StatusLast Update
0000660XdebugStep Debuggingpublic2020-03-12 17:19
Reporterbjori Assigned Toderick  
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionfixed 
PlatformLinuxOSUbuntuOS Version10.10
Product Version2.2dev 
Fixed in Version2.2dev 
Summary0000660: Check X-HTTP-FORWARDED-FOR before falling back to REMOTE_ADDR
Description

Currently 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.
Attached Files
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)   
Operating SystemLinux
PHP Version5.3.3

Activities

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
2020-03-12 16:55 derick Severity minor => feature
2020-03-12 17:19 derick Category Feature/Change request => Step Debugging