1717
1818#include "httpd.h"
1919#include "http_config.h"
20- #include "http_protocol.h"
20+ #include "http_protocol.h"
2121#include "http_log.h"
2222#include "ap_config.h"
2323#include "apr_strings.h"
@@ -30,7 +30,7 @@ static const int ALL_SET_MODE = 0x0003;
3030typedef struct {
3131 int enabled ;
3232 int detectReverseProxy ;
33- int setMode ;
33+ int setMode ;
3434 char * dbFile ;
3535 IP2Proxy * ip2proxyObj ;
3636} ip2proxy_server_config ;
@@ -50,9 +50,9 @@ static int ip2proxy_post_read_request(request_rec *r) {
5050 ip2proxy_server_config * config ;
5151 IP2ProxyRecord * record ;
5252 char buff [20 ];
53-
53+
5454 config = (ip2proxy_server_config * ) ap_get_module_config (r -> server -> module_config , & IP2Proxy_module );
55-
55+
5656 if (!config -> enabled )
5757 return OK ;
5858
@@ -86,20 +86,20 @@ static int ip2proxy_post_read_request(request_rec *r) {
8686 else {
8787 #if (((AP_SERVER_MAJORVERSION_NUMBER == 2 ) && (AP_SERVER_MINORVERSION_NUMBER >= 4 )) || (AP_SERVER_MAJORVERSION_NUMBER > 2 ))
8888 ipaddr = r -> connection -> client_ip ;
89- #else
89+ #else
9090 ipaddr = r -> connection -> remote_ip ;
91- #endif
91+ #endif
9292 }
9393
9494 record = IP2Proxy_get_all (config -> ip2proxyObj , ipaddr );
9595
9696 if (record ) {
9797 if (config -> setMode & ENV_SET_MODE ) {
98- apr_table_set (r -> subprocess_env , "IP2PROXY_COUNTRY_SHORT" , record -> country_short );
99- apr_table_set (r -> subprocess_env , "IP2PROXY_COUNTRY_LONG" , record -> country_long );
100- apr_table_set (r -> subprocess_env , "IP2PROXY_REGION" , record -> region );
101- apr_table_set (r -> subprocess_env , "IP2PROXY_CITY" , record -> city );
102- apr_table_set (r -> subprocess_env , "IP2PROXY_ISP" , record -> isp );
98+ apr_table_set (r -> subprocess_env , "IP2PROXY_COUNTRY_SHORT" , record -> country_short );
99+ apr_table_set (r -> subprocess_env , "IP2PROXY_COUNTRY_LONG" , record -> country_long );
100+ apr_table_set (r -> subprocess_env , "IP2PROXY_REGION" , record -> region );
101+ apr_table_set (r -> subprocess_env , "IP2PROXY_CITY" , record -> city );
102+ apr_table_set (r -> subprocess_env , "IP2PROXY_ISP" , record -> isp );
103103 apr_table_set (r -> subprocess_env , "IP2PROXY_IS_PROXY" , record -> is_proxy );
104104 apr_table_set (r -> subprocess_env , "IP2PROXY_PROXY_TYPE" , record -> proxy_type );
105105 apr_table_set (r -> subprocess_env , "IP2PROXY_DOMAIN" , record -> domain );
@@ -109,96 +109,98 @@ static int ip2proxy_post_read_request(request_rec *r) {
109109 apr_table_set (r -> subprocess_env , "IP2PROXY_LAST_SEEN" , record -> last_seen );
110110 apr_table_set (r -> subprocess_env , "IP2PROXY_THREAT" , record -> threat );
111111 apr_table_set (r -> subprocess_env , "IP2PROXY_PROVIDER" , record -> provider );
112+ apr_table_set (r -> subprocess_env , "IP2PROXY_FRAUD_SCORE" , record -> fraud_score );
112113 }
113114 if (config -> setMode & NOTES_SET_MODE ) {
114- apr_table_set (r -> notes , "IP2PROXY_COUNTRY_SHORT" , record -> country_short );
115- apr_table_set (r -> notes , "IP2PROXY_COUNTRY_LONG" , record -> country_long );
116- apr_table_set (r -> notes , "IP2PROXY_REGION" , record -> region );
117- apr_table_set (r -> notes , "IP2PROXY_CITY" , record -> city );
118- apr_table_set (r -> notes , "IP2PROXY_ISP" , record -> isp );
119- apr_table_set (r -> notes , "IP2PROXY_IS_PROXY" , record -> is_proxy );
120- apr_table_set (r -> notes , "IP2PROXY_PROXY_TYPE" , record -> proxy_type );
115+ apr_table_set (r -> notes , "IP2PROXY_COUNTRY_SHORT" , record -> country_short );
116+ apr_table_set (r -> notes , "IP2PROXY_COUNTRY_LONG" , record -> country_long );
117+ apr_table_set (r -> notes , "IP2PROXY_REGION" , record -> region );
118+ apr_table_set (r -> notes , "IP2PROXY_CITY" , record -> city );
119+ apr_table_set (r -> notes , "IP2PROXY_ISP" , record -> isp );
120+ apr_table_set (r -> notes , "IP2PROXY_IS_PROXY" , record -> is_proxy );
121+ apr_table_set (r -> notes , "IP2PROXY_PROXY_TYPE" , record -> proxy_type );
121122 apr_table_set (r -> notes , "IP2PROXY_DOMAIN" , record -> domain );
122123 apr_table_set (r -> notes , "IP2PROXY_USAGE_TYPE" , record -> usage_type );
123124 apr_table_set (r -> notes , "IP2PROXY_ASN" , record -> asn );
124125 apr_table_set (r -> notes , "IP2PROXY_AS" , record -> as_ );
125126 apr_table_set (r -> notes , "IP2PROXY_LAST_SEEN" , record -> last_seen );
126127 apr_table_set (r -> notes , "IP2PROXY_THREAT" , record -> threat );
127128 apr_table_set (r -> notes , "IP2PROXY_PROVIDER" , record -> provider );
129+ apr_table_set (r -> notes , "IP2PROXY_FRAUD_SCORE" , record -> fraud_score );
128130 }
129-
130- IP2Proxy_free_record (record );
131+
132+ IP2Proxy_free_record (record );
131133 }
132-
134+
133135 return OK ;
134136}
135137
136138static const char * set_ip2proxy_enable (cmd_parms * cmd , void * dummy , int arg ) {
137139 ip2proxy_server_config * config = (ip2proxy_server_config * ) ap_get_module_config (cmd -> server -> module_config , & IP2Proxy_module );
138-
139- if (!config )
140+
141+ if (!config )
140142 return NULL ;
141-
143+
142144 config -> enabled = arg ;
143-
145+
144146 return NULL ;
145147}
146148
147149static const char * set_ip2proxy_dbfile (cmd_parms * cmd , void * dummy , const char * dbFile , int arg ) {
148150 ip2proxy_server_config * config = (ip2proxy_server_config * ) ap_get_module_config (cmd -> server -> module_config , & IP2Proxy_module );
149-
150- if (!config )
151+
152+ if (!config )
151153 return NULL ;
152-
154+
153155 config -> dbFile = apr_pstrdup (cmd -> pool , dbFile );
154156
155157 if (config -> enabled ) {
156158 config -> ip2proxyObj = IP2Proxy_open (config -> dbFile );
157-
159+
158160 if (!config -> ip2proxyObj )
159161 return "Error opening dbFile!" ;
160162
161163 IP2Proxy_set_lookup_mode (config -> ip2proxyObj , IP2PROXY_CACHE_MEMORY );
162164 }
163165
164- return NULL ;
166+ return NULL ;
165167}
166168
167169static const char * set_ip2proxy_set_mode (cmd_parms * cmd , void * dummy , const char * mode , int arg ) {
168170 ip2proxy_server_config * config = (ip2proxy_server_config * ) ap_get_module_config (cmd -> server -> module_config , & IP2Proxy_module );
169-
170- if (!config )
171+
172+ if (!config )
171173 return NULL ;
172-
173- if (strcmp (mode , "ALL" ) == 0 )
174+
175+ if (strcmp (mode , "ALL" ) == 0 )
174176 config -> setMode = ALL_SET_MODE ;
175177
176- else if (strcmp (mode , "ENV" ) == 0 )
178+ else if (strcmp (mode , "ENV" ) == 0 )
177179 config -> setMode = ENV_SET_MODE ;
178180
179181 else if (strcmp (mode , "NOTES" ) == 0 )
180- config -> setMode = NOTES_SET_MODE ;
182+ config -> setMode = NOTES_SET_MODE ;
181183
182184 else
183185 return "Invalid mode for IP2ProxySetMode" ;
184-
185- return NULL ;
186+
187+ return NULL ;
186188}
187189
188190static const char * set_ip2proxy_detect_proxy (cmd_parms * cmd , void * dummy , int arg ) {
189191 ip2proxy_server_config * config = (ip2proxy_server_config * ) ap_get_module_config (cmd -> server -> module_config , & IP2Proxy_module );
190-
191- if (!config )
192+
193+ if (!config )
192194 return NULL ;
193-
195+
194196 config -> detectReverseProxy = arg ;
195-
197+
196198 return NULL ;
197199}
198200
199201static void * ip2proxy_create_svr_conf (apr_pool_t * pool , server_rec * svr ) {
200202 ip2proxy_server_config * svr_cfg = apr_pcalloc (pool , sizeof (ip2proxy_server_config ));
201-
203+
202204 svr_cfg -> enabled = 0 ;
203205 svr_cfg -> dbFile = NULL ;
204206 svr_cfg -> setMode = ALL_SET_MODE ;
@@ -212,7 +214,7 @@ static const command_rec ip2proxy_cmds[] = {
212214 AP_INIT_TAKE1 ("IP2ProxyDBFile" , (const char * (* )()) set_ip2proxy_dbfile , NULL , OR_FILEINFO , "File path to DB file" ),
213215 AP_INIT_TAKE1 ("IP2ProxySetMode" , (const char * (* )()) set_ip2proxy_set_mode , NULL , OR_FILEINFO , "Set scope mode" ),
214216 AP_INIT_TAKE1 ("IP2ProxyDetectProxy" , (const char * (* )()) set_ip2proxy_detect_proxy , NULL , OR_FILEINFO , "Detect reverse proxy headers" ),
215- {NULL }
217+ {NULL }
216218};
217219
218220static void ip2proxy_register_hooks (apr_pool_t * p ) {
@@ -222,7 +224,7 @@ static void ip2proxy_register_hooks(apr_pool_t *p) {
222224
223225// API hooks
224226module AP_MODULE_DECLARE_DATA IP2Proxy_module = {
225- STANDARD20_MODULE_STUFF ,
227+ STANDARD20_MODULE_STUFF ,
226228 NULL ,
227229 NULL ,
228230 ip2proxy_create_svr_conf ,
0 commit comments