diff options
| author | jvoisin | 2021-04-28 18:27:59 +0200 |
|---|---|---|
| committer | jvoisin | 2021-04-28 18:27:59 +0200 |
| commit | 8496968ef07dadac2657206e059520675c5eb28a (patch) | |
| tree | ce6e4263a5f7813ec522af2b8939dd8252a8fe34 /src | |
| parent | 47e03e6ac921dc0f9250c3eafb06d08d33f35981 (diff) | |
Simplify a bit get_ip()
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp_utils.c | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/src/sp_utils.c b/src/sp_utils.c index a7a3d27..a1fa400 100644 --- a/src/sp_utils.c +++ b/src/sp_utils.c | |||
| @@ -19,25 +19,7 @@ const char* get_ipaddr() { | |||
| 19 | return fwd_ip; | 19 | return fwd_ip; |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | /* Some hosters (like heroku, see | 22 | return default_ipaddr; |
| 23 | * https://github.com/jvoisin/snuffleupagus/issues/336) are clearing the | ||
| 24 | * environment variables, so we don't have access to them, hence why we're | ||
| 25 | * resorting to $_SERVER['REMOTE_ADDR']. | ||
| 26 | */ | ||
| 27 | if (!Z_ISUNDEF(PG(http_globals)[TRACK_VARS_SERVER])) { | ||
| 28 | const zval* const globals_client_ip = | ||
| 29 | zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), | ||
| 30 | "REMOTE_ADDR", sizeof("REMOTE_ADDR") - 1); | ||
| 31 | if (globals_client_ip) { | ||
| 32 | if (Z_TYPE_P(globals_client_ip) == IS_STRING) { | ||
| 33 | if (Z_STRLEN_P(globals_client_ip) != 0) { | ||
| 34 | return estrdup(Z_STRVAL_P(globals_client_ip)); | ||
| 35 | } | ||
| 36 | } | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | return default_ipaddr; | ||
| 41 | } | 23 | } |
| 42 | 24 | ||
| 43 | void sp_log_msgf(char const* restrict feature, int level, int type, | 25 | void sp_log_msgf(char const* restrict feature, int level, int type, |
