static char *
ngx_http_ssl_enable_async(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    ngx_http_ssl_srv_conf_t *sscf = conf;
    char                    *rv;
    ngx_flag_t              *pssl, *pssl_async;

    rv = ngx_conf_set_flag_slot(cf, cmd, conf);

    if (rv != NGX_CONF_OK) {
        return rv;
    }

    /* If ssl_async on is configured, then ssl on is configured by default
     * This will align 'ssl_async on;' and 'listen port ssl' diretives
     * */
    pssl = (ngx_flag_t *) ((char *)conf + offsetof(ngx_http_ssl_srv_conf_t, enable));
    pssl_async = (ngx_flag_t *) ((char *)conf + cmd->offset);

    if(*pssl_async && *pssl != 1) {
        *pssl = *pssl_async;
    }

    sscf->file = cf->conf_file->file.name.data;
    sscf->line = cf->conf_file->line;

    return NGX_CONF_OK;
}
static char *
ngx_http_groonga_conf_set_groonga_slot(ngx_conf_t *cf, ngx_command_t *cmd,
                                       void *conf)
{
  char *status;
  ngx_http_core_loc_conf_t *location_conf;
  ngx_http_groonga_loc_conf_t *groonga_location_conf = conf;

  status = ngx_conf_set_flag_slot(cf, cmd, conf);
  if (status != NGX_CONF_OK) {
    return status;
  }

  location_conf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
  if (groonga_location_conf->enabled) {
    location_conf->handler = ngx_http_groonga_handler;
    groonga_location_conf->name =
      ngx_str_null_terminate(cf->pool, &(location_conf->name));
    groonga_location_conf->config_file =
      ngx_str_null_terminate(cf->pool, &(cf->conf_file->file.name));
    groonga_location_conf->config_line = cf->conf_file->line;
  } else {
    location_conf->handler = NULL;
  }

  return NGX_CONF_OK;
}
static char *ngx_http_notetask_counter(ngx_conf_t *cf, ngx_command_t *cmd,
        void *conf)
{
        ngx_http_notetask_loc_conf_t* local_conf;
        local_conf = conf;
        char* rv = NULL;
        rv = ngx_conf_set_flag_slot(cf, cmd, conf);
        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "notetask_counter:%d", local_conf->notetask_counter);
        return rv;
}
static char *
ngx_http_xss_get(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    ngx_http_xss_main_conf_t       *xmcf;

    xmcf = ngx_http_conf_get_module_main_conf(cf,
                                              ngx_http_xss_filter_module);

    xmcf->requires_filter = 1;

    return ngx_conf_set_flag_slot(cf, cmd, conf);
}
/*
 * 在解析hello_counter命令时执行的解析函数: 将hello_counter(含义:一个bool值)转换为
 * 0或者1,0代表不启用访问计数,1代表启用访问计数
 * */
static char *ngx_http_hello_counter(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
	/* ngx_conf_set_flag_slot:把“on”和“off”转成1和0,并保存到配置文件结构体中 */
	ngx_conf_set_flag_slot(cf, cmd, conf);

    // 打印参数值
	ngx_http_hello_loc_conf_t* local_conf;
	local_conf = conf;
    ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "hello_counter:%d", local_conf->hello_counter);

    return NGX_CONF_OK;
}
static char *
ngx_http_rds_xml(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    ngx_http_rds_xml_main_conf_t     *rmcf;

    rmcf = ngx_http_conf_get_module_main_conf(cf,
                                              ngx_http_rds_xml_filter_module);

    dd("set filter used to 1");

    rmcf->requires_filters = 1;

    return ngx_conf_set_flag_slot(cf, cmd, conf);
}
// Parse the jsonp directive
static char * ngx_http_jsonp_directive_jsonp(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    // Actually, we just get the index of the variable for the config object
    // then let the built-in flag processing function do the rest
    ngx_http_jsonp_conf_t * jsonp_cf = conf;
    jsonp_cf->variable_index = ngx_http_get_variable_index(cf, &ngx_http_jsonp_callback_variable_name);

    if (jsonp_cf->variable_index == NGX_ERROR)
    {
        return NGX_CONF_ERROR;
    }

    return ngx_conf_set_flag_slot(cf, cmd, conf);
}
static char *
ngx_http_eval_subrequest_in_memory(ngx_conf_t *cf,
                                   ngx_command_t *cmd, void *conf)
{
    char                        *res;

    dd("eval subrequest in memory");

    res = ngx_conf_set_flag_slot(cf, cmd, conf);
    if (res != NGX_CONF_OK) {
        return res;
    }

    return NGX_CONF_OK;
}
    static char *
ngx_http_modsecurity_enable(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    ngx_http_modsecurity_loc_conf_t *mscf = conf;
    char                            *rc;

    rc = ngx_conf_set_flag_slot(cf, cmd, conf);
    if (rc != NGX_CONF_OK) {
        return rc;
    }
    if (mscf->enable) {
        mscf->file = &cf->conf_file->file.name;
        mscf->line = cf->conf_file->line;
    }
    return NGX_CONF_OK;
}
Exemple #10
0
static char *
ngx_http_ssl_enable(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    ngx_http_ssl_srv_conf_t *sscf = conf;

    char  *rv;

    rv = ngx_conf_set_flag_slot(cf, cmd, conf);

    if (rv != NGX_CONF_OK) {
        return rv;
    }

    sscf->file = cf->conf_file->file.name.data;
    sscf->line = cf->conf_file->line;

    return NGX_CONF_OK;
}
static char *ngx_http_hello_counter(ngx_conf_t *cf, ngx_command_t *cmd,
        void *conf)
{
        ngx_http_hello_loc_conf_t* local_conf;
        ngx_http_core_loc_conf_t *clcf;

        clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);

        local_conf = conf;

        char* rv = NULL;

        rv = ngx_conf_set_flag_slot(cf, cmd, conf);


        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "hello_counter:%d", local_conf->hello_counter);
        return rv;
}
char *
ngx_http_lua_code_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    char             *p = conf;
    ngx_flag_t       *fp;
    char             *ret;

    ret = ngx_conf_set_flag_slot(cf, cmd, conf);
    if (ret != NGX_CONF_OK) {
        return ret;
    }

    fp = (ngx_flag_t *) (p + cmd->offset);

    if (! *fp) {
        ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
                "lua_code_cache is off; this will hurt performance");
    }

    return NGX_CONF_OK;
}
/*
 * 在解析show_param命令时执行的解析函数: 将show_param(含义:一个bool值)转换为
 * 0或者1,0代表不启用访问计数,1代表启用访问计数
 * */
static char *ngx_http_show_param(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
	ngx_http_show_param_loc_conf_t* local_conf;

	local_conf = conf;

	char* rv = NULL;

	/* ngx_conf_set_flag_slot:把“on”和“off”转成1和0,并保存到配置文件结构体中 */
	rv = ngx_conf_set_flag_slot(cf, cmd, conf);

	ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "ngx_http_show_param: show_param:%d", local_conf->enable);

    // 按需挂载处理函数handler
    ngx_http_core_loc_conf_t *clcf;
    clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
    clcf->handler = ngx_http_show_param_handler;

    ngx_conf_log_error(NGX_LOG_EMERG, cf , 0, "show_param: handler hooked\n");

    return rv;
}
static char *
ngx_mail_ssl_enable(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    ngx_mail_ssl_conf_t  *scf = conf;

    char  *rv;

    rv = ngx_conf_set_flag_slot(cf, cmd, conf);

    if (rv != NGX_CONF_OK) {
        return rv;
    }

    if (scf->enable && (ngx_int_t) scf->starttls > NGX_MAIL_STARTTLS_OFF) {
        ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
                           "\"starttls\" directive conflicts with \"ssl on\"");
        return NGX_CONF_ERROR;
    }

    scf->file = cf->conf_file->file.name.data;
    scf->line = cf->conf_file->line;

    return NGX_CONF_OK;
}
Exemple #15
0
static char *
ngx_http_limit_req(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    ngx_http_limit_req_conf_t  *lrcf = conf;

    char                          *rv;
    ngx_int_t                      burst;
    ngx_str_t                     *value, s;
    ngx_uint_t                     i;
    ngx_http_limit_req_t          *limit_req;

    if (lrcf->rules == NULL) {
        lrcf->rules = ngx_array_create(cf->pool, 5,
                                       sizeof(ngx_http_limit_req_t));
        if (lrcf->rules == NULL) {
            return NGX_CONF_ERROR;
        }
    }

    limit_req = ngx_array_push(lrcf->rules);
    if (limit_req == NULL) {
        return NGX_CONF_ERROR;
    }

    ngx_memzero(limit_req, sizeof(ngx_http_limit_req_t));

    value = cf->args->elts;

    if (cf->args->nelts == 2) {
        rv = ngx_conf_set_flag_slot(cf, cmd, lrcf);
        return rv;
    }

    burst = 0;

    for (i = 1; i < cf->args->nelts; i++) {

        if (ngx_strncmp(value[i].data, "zone=", 5) == 0) {

            s.len = value[i].len - 5;
            s.data = value[i].data + 5;

            limit_req->shm_zone = ngx_shared_memory_add(cf, &s, 0,
                                                   &ngx_http_limit_req_module);
            if (limit_req->shm_zone == NULL) {
                return NGX_CONF_ERROR;
            }

            continue;
        }

        if (ngx_strncmp(value[i].data, "burst=", 6) == 0) {

            burst = ngx_atoi(value[i].data + 6, value[i].len - 6);
            if (burst <= 0) {
                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                                   "invalid burst rate \"%V\"", &value[i]);
                return NGX_CONF_ERROR;
            }

            continue;
        }

        if (ngx_strncmp(value[i].data, "forbid_action=", 14) == 0) {

            s.len = value[i].len - 14;
            s.data = value[i].data + 14;

            if (s.len < 2 || (s.data[0] != '@' && s.data[0] != '/')) {
                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                                   "invalid forbid_action \"%V\"", &value[i]);
                return NGX_CONF_ERROR;
            }

            limit_req->forbid_action = s;

            continue;
        }

        if (ngx_strncmp(value[i].data, "nodelay", 7) == 0) {
            limit_req->nodelay = 1;
            continue;
        }

        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                           "invalid parameter \"%V\"", &value[i]);
        return NGX_CONF_ERROR;
    }

    if (limit_req->shm_zone == NULL) {
        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                           "\"%V\" must have \"zone\" parameter",
                           &cmd->name);
        return NGX_CONF_ERROR;
    }

    if (limit_req->shm_zone->data == NULL) {
        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                           "unknown limit_req_zone \"%V\"",
                           &limit_req->shm_zone->shm.name);
        return NGX_CONF_ERROR;
    }

    limit_req->burst = burst * 1000;
    if (lrcf->enable == NGX_CONF_UNSET) {
        lrcf->enable = 1;
    }

    return NGX_CONF_OK;
}