View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update | 
|---|---|---|---|---|---|
| 0000660 | Xdebug | Step Debugging | public | 2011-02-01 15:04 | 2020-03-12 17:19 | 
| Reporter | bjori | Assigned To | derick | ||
| Priority | normal | Severity | feature | Reproducibility | always | 
| Status | closed | Resolution | fixed | ||
| Platform | Linux | OS | Ubuntu | OS Version | 10.10 | 
| Product Version | 2.2dev | ||||
| Fixed in Version | 2.2dev | ||||
| Summary | 0000660: Check X-HTTP-FORWARDED-FOR before falling back to REMOTE_ADDR | ||||
| Description | Currently xdebug has the option of connecting back to REMOTE_ADDR. Attached is a patch to check for (and use if provided) X_HTTP_FORWARDED_FOR before checking REMOTE_ADDR.  | ||||
| Tags | No 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 {
 | ||||
| Operating System | Linux | ||||
| PHP Version | 5.3.3 | ||||
| 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 |