Skip to content

Commit

Permalink
Use defines instead of magic numbers for default ports
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Aug 24, 2022
1 parent fb69b11 commit 453f79f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/debugger/com.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,8 @@ static void xdebug_init_cloud_debugger(const char *cloud_id)

host = xdebug_sprintf("%c.cloud.xdebug.com", (crc & 0x0f) + 'a');

xdebug_log(XLOG_CHAN_DEBUG, XLOG_INFO, "Connecting to configured address/port: %s:%ld.", host, 9020L);
XG_DBG(context).socket = xdebug_create_socket(host, 9020, XINI_DBG(connect_timeout_ms));
xdebug_log(XLOG_CHAN_DEBUG, XLOG_INFO, "Connecting to configured address/port: %s:%ld.", host, XDEBUG_CLOUD_PORT);
XG_DBG(context).socket = xdebug_create_socket(host, XDEBUG_CLOUD_PORT, XINI_DBG(connect_timeout_ms));

xdfree(host);
}
Expand Down
3 changes: 3 additions & 0 deletions src/debugger/com.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

#include "handlers.h"

#define XDEBUG_CLIENT_PORT_S "9003"
#define XDEBUG_CLOUD_PORT 9020L

#if WIN32|WINNT
# define SOCK_ERR INVALID_SOCKET
# define SOCK_CONN_ERR SOCKET_ERROR
Expand Down
2 changes: 1 addition & 1 deletion src/debugger/debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ typedef struct _xdebug_debugger_settings_t {
char *cloud_shared_key;

/* Step Debugger */
zend_long client_port; /* 9000 */
zend_long client_port; /* 9003 */
char *client_host; /* localhost */
zend_bool discover_client_host; /* (try to) connect back to the HTTP requestor */
char *client_discovery_header; /* User configured header to check for forwarded IP address */
Expand Down
15 changes: 8 additions & 7 deletions xdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "develop/monitor.h"
#include "develop/stack.h"
#include "develop/superglobals.h"
#include "debugger/com.h"
#include "gcstats/gc_stats.h"
#include "lib/usefulstuff.h"
#include "lib/lib.h"
Expand Down Expand Up @@ -316,13 +317,13 @@ PHP_INI_BEGIN()
/* Xdebug Cloud */
STD_PHP_INI_ENTRY("xdebug.cloud_id", "", PHP_INI_SYSTEM, OnUpdateString, settings.debugger.cloud_id, zend_xdebug_globals, xdebug_globals)

/* Remote debugger settings */
STD_PHP_INI_ENTRY("xdebug.client_host", "localhost", PHP_INI_ALL, OnUpdateString, settings.debugger.client_host, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.client_port", "9003", PHP_INI_ALL, OnUpdateLong, settings.debugger.client_port, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_BOOLEAN("xdebug.discover_client_host", "0", PHP_INI_ALL, OnUpdateBool, settings.debugger.discover_client_host, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.client_discovery_header", "HTTP_X_FORWARDED_FOR,REMOTE_ADDR", PHP_INI_ALL, OnUpdateString, settings.debugger.client_discovery_header, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.idekey", "", PHP_INI_ALL, OnUpdateString, settings.debugger.ide_key_setting, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.connect_timeout_ms", "200", PHP_INI_ALL, OnUpdateLong, settings.debugger.connect_timeout_ms, zend_xdebug_globals, xdebug_globals)
/* Step debugger settings */
STD_PHP_INI_ENTRY("xdebug.client_host", "localhost", PHP_INI_ALL, OnUpdateString, settings.debugger.client_host, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.client_port", XDEBUG_CLIENT_PORT_S, PHP_INI_ALL, OnUpdateLong, settings.debugger.client_port, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_BOOLEAN("xdebug.discover_client_host", "0", PHP_INI_ALL, OnUpdateBool, settings.debugger.discover_client_host, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.client_discovery_header", "HTTP_X_FORWARDED_FOR,REMOTE_ADDR", PHP_INI_ALL, OnUpdateString, settings.debugger.client_discovery_header, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.idekey", "", PHP_INI_ALL, OnUpdateString, settings.debugger.ide_key_setting, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.connect_timeout_ms", "200", PHP_INI_ALL, OnUpdateLong, settings.debugger.connect_timeout_ms, zend_xdebug_globals, xdebug_globals)

/* Scream support */
STD_PHP_INI_BOOLEAN("xdebug.scream", "0", PHP_INI_ALL, OnUpdateBool, settings.develop.do_scream, zend_xdebug_globals, xdebug_globals)
Expand Down

0 comments on commit 453f79f

Please sign in to comment.