@@ -27,22 +27,22 @@ ngx_http_bot_verifier_module_handler(ngx_http_request_t *r)
27
27
return NGX_DECLINED ;
28
28
}
29
29
30
- ngx_int_t connection_status = check_connection (loc_conf -> redis .connection );
30
+ ngx_int_t connection_status = ngx_http_bot_verifier_module_check_connection (loc_conf -> redis .connection );
31
31
if (connection_status == NGX_ERROR ) {
32
32
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 , "No cache connection, creating new connection" );
33
33
34
34
if (loc_conf -> redis .connection != NULL ) {
35
35
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 , "Cache connection error: %s" , loc_conf -> redis .connection -> errstr );
36
36
}
37
37
38
- connection_status = reset_connection (loc_conf );
38
+ connection_status = ngx_http_bot_verifier_module_reset_connection (loc_conf );
39
39
40
40
if (connection_status == NGX_ERROR ) {
41
41
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 , "Unable to establish cache connection, bypassing" );
42
42
43
43
if (loc_conf -> redis .connection != NULL ) {
44
44
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 , "Cache connection error: %s" , loc_conf -> redis .connection -> errstr );
45
- cleanup_connection (loc_conf );
45
+ ngx_http_bot_verifier_module_cleanup_connection (loc_conf );
46
46
}
47
47
48
48
return NGX_DECLINED ;
@@ -58,7 +58,7 @@ ngx_http_bot_verifier_module_handler(ngx_http_request_t *r)
58
58
return NGX_DECLINED ;
59
59
}
60
60
61
- ngx_int_t verification_status = lookup_verification_status (loc_conf -> redis .connection , address );
61
+ ngx_int_t verification_status = ngx_http_bot_verifier_module_lookup_verification_status (loc_conf -> redis .connection , address );
62
62
if (verification_status == NGX_ERROR ) {
63
63
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 , "Unable to lookup verification status, bypassing" );
64
64
return NGX_DECLINED ;
@@ -85,10 +85,10 @@ ngx_http_bot_verifier_module_handler(ngx_http_request_t *r)
85
85
ret = ngx_http_bot_verifier_module_verify_bot (r , loc_conf , address );
86
86
if (ret == NGX_OK ) {
87
87
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 , "Verification successful, allowing request" );
88
- persist_verification_status (loc_conf , address , ret );
88
+ ngx_http_bot_verifier_module_persist_verification_status (loc_conf , address , ret );
89
89
} else if (ret == NGX_DECLINED ) {
90
90
ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 , "Verification failed, blocking request" );
91
- persist_verification_status (loc_conf , address , ret );
91
+ ngx_http_bot_verifier_module_persist_verification_status (loc_conf , address , ret );
92
92
return NGX_HTTP_FORBIDDEN ;
93
93
}
94
94
}
@@ -197,38 +197,38 @@ ngx_http_bot_verifier_module_create_loc_conf(ngx_conf_t *cf)
197
197
198
198
char * google_domains [2 ] = {"google.com" , "googlebot.com" };
199
199
len = sizeof (google_domains ) / sizeof (google_domains [0 ]);
200
- provider_t * google = make_provider ("Google" , google_domains , len );
200
+ ngx_http_bot_verifier_module_provider_t * google = ngx_http_bot_verifier_module_make_provider ("Google" , google_domains , len );
201
201
202
202
char * bing_domains [1 ] = {"search.msn.com" };
203
203
len = sizeof (bing_domains ) / sizeof (bing_domains [0 ]);
204
- provider_t * bing = make_provider ("Bing" , bing_domains , len );
204
+ ngx_http_bot_verifier_module_provider_t * bing = ngx_http_bot_verifier_module_make_provider ("Bing" , bing_domains , len );
205
205
206
206
char * yahoo_domains [1 ] = {"yahoo.com" };
207
207
len = sizeof (yahoo_domains ) / sizeof (yahoo_domains [0 ]);
208
- provider_t * yahoo = make_provider ("Yahoo" , yahoo_domains , len );
208
+ ngx_http_bot_verifier_module_provider_t * yahoo = ngx_http_bot_verifier_module_make_provider ("Yahoo" , yahoo_domains , len );
209
209
210
210
char * baidu_domains [1 ] = {"crawl.baidu.com" };
211
211
len = sizeof (baidu_domains ) / sizeof (baidu_domains [0 ]);
212
- provider_t * baidu = make_provider ("Baidu" , baidu_domains , len );
212
+ ngx_http_bot_verifier_module_provider_t * baidu = ngx_http_bot_verifier_module_make_provider ("Baidu" , baidu_domains , len );
213
213
214
214
char * yandex_domains [3 ] = {"yandex.com" , "yandex.net" , "yandex.ru" };
215
215
len = sizeof (yandex_domains ) / sizeof (yandex_domains [0 ]);
216
- provider_t * yandex = make_provider ("Yandex" , yandex_domains , len );
216
+ ngx_http_bot_verifier_module_provider_t * yandex = ngx_http_bot_verifier_module_make_provider ("Yandex" , yandex_domains , len );
217
217
218
218
conf -> provider_len = 5 ;
219
- conf -> providers = ngx_pcalloc (cf -> pool , sizeof (provider_t * * ) + conf -> provider_len * sizeof (provider_t * ));
219
+ conf -> providers = ngx_pcalloc (cf -> pool , sizeof (ngx_http_bot_verifier_module_provider_t * * ) + conf -> provider_len * sizeof (ngx_http_bot_verifier_module_provider_t * ));
220
220
conf -> providers [0 ] = google ;
221
221
conf -> providers [1 ] = yahoo ;
222
222
conf -> providers [2 ] = bing ;
223
223
conf -> providers [3 ] = baidu ;
224
224
conf -> providers [4 ] = yandex ;
225
225
226
226
ngx_str_t identifier_pattern = ngx_string ("google|bing|yahoo|baidu|yandex" );
227
- conf -> identifier_regex = make_regex (cf -> pool , & identifier_pattern );
227
+ conf -> identifier_regex = ngx_http_bot_verifier_module_make_regex (cf -> pool , & identifier_pattern );
228
228
229
229
ngx_str_t domain_pattern = ngx_string ("[^.]*\\.[^.]{2,3}(?:\\.[^.]{2,3})?$" );
230
230
// ngx_str_t domain_pattern = ngx_string("\\.(.*)");
231
- conf -> domain_regex = make_regex (cf -> pool , & domain_pattern );
231
+ conf -> domain_regex = ngx_http_bot_verifier_module_make_regex (cf -> pool , & domain_pattern );
232
232
233
233
return conf ;
234
234
}
0 commit comments