From 62662b69ca26051d157668a00cfb836ce4e6c962 Mon Sep 17 00:00:00 2001 From: yzprofile Date: Fri, 23 Nov 2012 22:16:34 +0800 Subject: [PATCH] added themis cmd type and reuqest type --- core/ngx_http_themis_module.c | 13 +++++++++++-- core/ngx_themis.h | 6 +++++- core/ngx_themis_channel.c | 2 +- core/ngx_themis_channel.h | 6 +++++- .../access_mate/ngx_themis_access_mate_module.c | 16 ++++++++++++++++ 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/core/ngx_http_themis_module.c b/core/ngx_http_themis_module.c index c3fc5ba..8450956 100644 --- a/core/ngx_http_themis_module.c +++ b/core/ngx_http_themis_module.c @@ -347,7 +347,7 @@ ngx_http_themis_init_process(ngx_cycle_t *cycle) if (ngx_add_channel_event(cycle, ngx_themis_socketpairs[ngx_process_slot][1], NGX_READ_EVENT, - ngx_themis_channel_read_handler) == NGX_ERROR) + ngx_themis_channel_handler) == NGX_ERROR) { return NGX_ERROR; } @@ -375,6 +375,12 @@ ngx_themis_conf_set_config(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) ngx_http_themis_main_conf_t *tmcf; value = cf->args->elts; + if (ngx_strncasecmp(value[1].data, (u_char *) "themis", value[1].len) + == 0) + { + return "\"themis\" is not allowed be a parameter"; + } + tlcf->name = value[1]; tlcf->enable = 1; http_ctx = cf->ctx; @@ -542,7 +548,10 @@ ngx_http_themis_interface(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) static ngx_int_t ngx_http_themis_interface_handler(ngx_http_request_t *r) { - /* uri: app/module/command */ + /* + uri: app/module/command + themis/... + */ return NGX_DONE; } diff --git a/core/ngx_themis.h b/core/ngx_themis.h index 65fc8e1..32b6467 100644 --- a/core/ngx_themis.h +++ b/core/ngx_themis.h @@ -8,9 +8,13 @@ #include -#define NGX_THEMIS_MODULE 0x53494d54 /* TMIS */ +#define NGX_THEMIS_MODULE 0x53494d54 /* TMIS */ + #define NGX_THEMIS_CONF NGX_ANY_CONF +#define NGX_THEMIS_COMMAND 0 +#define NGX_THEMIS_REQUEST 1 + typedef void *(*ngx_themis_create_config_pt)(ngx_conf_t *cf); typedef ngx_int_t (*ngx_themis_update_config)(ngx_cycle_t *cycle, void *config); diff --git a/core/ngx_themis_channel.c b/core/ngx_themis_channel.c index 2fe82d5..af82f2e 100644 --- a/core/ngx_themis_channel.c +++ b/core/ngx_themis_channel.c @@ -4,7 +4,7 @@ ngx_socket_t ngx_themis_socketpairs[NGX_MAX_PROCESSES][2]; void -ngx_themis_channel_read_handler(ngx_event_t *ev) +ngx_themis_channel_handler(ngx_event_t *ev) { } diff --git a/core/ngx_themis_channel.h b/core/ngx_themis_channel.h index 1ae3c1b..18718da 100644 --- a/core/ngx_themis_channel.h +++ b/core/ngx_themis_channel.h @@ -1,6 +1,10 @@ #ifndef _NGX_THEMIS_CHANNEL_H_INCLUDE_ #define _NGX_THEMIS_CHANNEL_H_INCLUDE_ -void ngx_themis_channel_read_handler(ngx_event_t *ev); + +#define THEMIS_CHANNEL_TYPE_CONF 0 + + +void ngx_themis_channel_handler(ngx_event_t *ev); #endif diff --git a/modules/access_mate/ngx_themis_access_mate_module.c b/modules/access_mate/ngx_themis_access_mate_module.c index d03e06f..303c1d5 100644 --- a/modules/access_mate/ngx_themis_access_mate_module.c +++ b/modules/access_mate/ngx_themis_access_mate_module.c @@ -14,6 +14,8 @@ static ngx_int_t ngx_themis_access_mate_apply_config(ngx_http_request_t *r, void *config); static char *ngx_themis_access_add(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); +static char *ngx_themis_access_status(ngx_conf_t *cf, ngx_command_t *cmd, + void *conf); typedef struct { @@ -50,7 +52,14 @@ static ngx_command_t ngx_themis_access_commands[] = { { ngx_string("add"), NGX_THEMIS_CONF|NGX_CONF_TAKE2, ngx_themis_access_add, + NGX_THEMIS_COMMAND, 0, + NULL }, + + { ngx_string("status"), + NGX_THEMIS_CONF|NGX_CONF_TAKE2, + ngx_themis_access_status, + NGX_THEMIS_REQUEST, 0, NULL }, @@ -99,6 +108,13 @@ ngx_themis_access_add(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) } +static char * +ngx_themis_access_status(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +{ + return NGX_CONF_OK; +} + + static ngx_int_t ngx_themis_access_mate_update_config(ngx_cycle_t *cycle, void *config)