本文使用nginx-stable-1.12代码。 路径:
src/http/modules/ngxhttpuseridfiltermodule.c
流程图
头文件
-
// nginx配置类
-
#include <ngx_config.h>
-
// nginx核心类
-
#include <ngx_core.h>
-
// nginx http模块类
-
#include <ngx_http.h>
define常量
-
// off关闭功能
-
#define NGX_HTTP_USERID_OFF 0
-
// 开启log
-
#define NGX_HTTP_USERID_LOG 1
-
// v1版本cookie
-
#define NGX_HTTP_USERID_V1 2
-
// 开启功能
-
#define NGX_HTTP_USERID_ON 3
-
/* 31 Dec 2037 23:55:55 GMT */ // unix最大时间戳
-
#define NGX_HTTP_USERID_MAX_EXPIRES 2145916555
结构
指令
-
typedef struct {
-
ngx_uint_t enable;
-
ngx_int_t service;
-
ngx_str_t name;
-
ngx_str_t domain;
-
ngx_str_t path;
-
ngx_str_t p3p;
-
time_t expires;
-
u_char mark;
-
} ngx_http_userid_conf_t;
变量
-
typedef struct {
-
uint32_t uid_got[4];
-
uint32_t uid_set[4];
-
ngx_str_t cookie;
-
ngx_uint_t reset;
-
} ngx_http_userid_ctx_t;
函数
-
// 获取uid
-
static ngx_http_userid_ctx_t *ngx_http_userid_get_uid(ngx_http_request_t *r,
-
ngx_http_userid_conf_t *conf);
-
-
// 变量
-
static ngx_int_t ngx_http_userid_variable(ngx_http_request_t *r,