Skip to content

Commit 0199af2

Browse files
committed
Removed access_type to minimize configuration and improve performance.
1 parent 6ea8944 commit 0199af2

File tree

2 files changed

+1
-46
lines changed

2 files changed

+1
-46
lines changed

README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ Context : main
7474
Description : Load IP2Proxy Nginx module if it was compiled as dynamic.
7575
```
7676

77-
```
78-
Syntax : ip2proxy_access_type file_io|shared_memory|cache_memory
79-
Default : cache_memory
80-
Context : http
81-
Description : Set the method used for lookup.
82-
```
83-
8477
```
8578
Syntax : ip2proxy_database path
8679
Default : none
@@ -110,7 +103,6 @@ Description : Set a list of proxies to translate x-forwarded-for headers for.
110103
http {
111104
...
112105
113-
ip2proxy_access_type cache_memory;
114106
ip2proxy_database /usr/share/ip2location/PX3.BIN;
115107
ip2proxy_proxy_recursive on;
116108
ip2proxy_proxy 192.168.1.0/24;

ngx_http_ip2proxy.c

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
typedef struct {
1515
IP2Proxy *handler;
16-
ngx_int_t access_type;
1716
ngx_array_t *proxies;
1817
ngx_flag_t proxy_recursive;
1918
} ngx_http_ip2proxy_conf_t;
@@ -29,7 +28,6 @@ static IP2ProxyRecord *ngx_http_ip2proxy_get_records(ngx_http_request_t *r);
2928
static void *ngx_http_ip2proxy_create_conf(ngx_conf_t *cf);
3029
static char *ngx_http_ip2proxy_init_conf(ngx_conf_t *cf, void *conf);
3130
static char *ngx_http_ip2proxy_database(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
32-
static char *ngx_http_ip2proxy_access_type(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
3331
static char *ngx_http_ip2proxy_proxy(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
3432
static ngx_int_t ngx_http_ip2proxy_cidr_value(ngx_conf_t *cf, ngx_str_t *net, ngx_cidr_t *cidr);
3533
static void ngx_http_ip2proxy_cleanup(void *data);
@@ -43,14 +41,6 @@ static ngx_command_t ngx_http_ip2proxy_commands[] = {
4341
0,
4442
NULL
4543
},
46-
{
47-
ngx_string("ip2proxy_access_type"),
48-
NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE12,
49-
ngx_http_ip2proxy_access_type,
50-
NGX_HTTP_MAIN_CONF_OFFSET,
51-
0,
52-
NULL
53-
},
5444
{
5545
ngx_string("ip2proxy_proxy"),
5646
NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
@@ -353,29 +343,7 @@ ngx_http_ip2proxy_database(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
353343
return NGX_CONF_ERROR;
354344
}
355345

356-
IP2Proxy_open_mem(gcf->handler, gcf->access_type);
357-
358-
return NGX_CONF_OK;
359-
}
360-
361-
static char *
362-
ngx_http_ip2proxy_access_type(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
363-
{
364-
ngx_http_ip2proxy_conf_t *gcf = conf;
365-
ngx_str_t *value;
366-
367-
value = cf->args->elts;
368-
369-
if (ngx_strcasecmp((u_char *)"file_io", value[1].data) == 0) {
370-
gcf->access_type = IP2PROXY_FILE_IO;
371-
} else if (ngx_strcasecmp((u_char *)"cache_memory", value[1].data) == 0) {
372-
gcf->access_type = IP2PROXY_CACHE_MEMORY;
373-
} else if (ngx_strcasecmp((u_char *)"shared_memory", value[1].data) == 0) {
374-
gcf->access_type = IP2PROXY_SHARED_MEMORY;
375-
} else {
376-
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "Unkown access type \"%V\".", &value[1]);
377-
return NGX_CONF_ERROR;
378-
}
346+
IP2Proxy_open_mem(gcf->handler, IP2PROXY_CACHE_MEMORY);
379347

380348
return NGX_CONF_OK;
381349
}
@@ -445,11 +413,6 @@ ngx_http_ip2proxy_cleanup(void *data)
445413

446414
if (gcf->handler) {
447415
IP2Proxy_close(gcf->handler);
448-
449-
if (gcf->access_type == IP2PROXY_SHARED_MEMORY) {
450-
IP2Proxy_DB_del_shm();
451-
}
452-
453416
gcf->handler = NULL;
454417
}
455418
}

0 commit comments

Comments
 (0)