[源码阅读]ngx_http_userid_module模块源码分析

本文使用nginx-stable-1.12代码。 路径:

src/http/modules/ngxhttpuseridfiltermodule.c

流程图

头文件

 
  1. // nginx配置类

  2. #include <ngx_config.h>

  3. // nginx核心类

  4. #include <ngx_core.h>

  5. // nginx http模块类

  6. #include <ngx_http.h>


define常量

 
  1. // off关闭功能

  2. #define NGX_HTTP_USERID_OFF   0

  3. // 开启log

  4. #define NGX_HTTP_USERID_LOG   1

  5. // v1版本cookie

  6. #define NGX_HTTP_USERID_V1    2

  7. // 开启功能

  8. #define NGX_HTTP_USERID_ON    3

  9. /* 31 Dec 2037 23:55:55 GMT */ // unix最大时间戳

  10. #define NGX_HTTP_USERID_MAX_EXPIRES  2145916555


结构

指令

 
  1. typedef struct {

  2.    ngx_uint_t  enable;

  3.    ngx_int_t   service;

  4.    ngx_str_t   name;

  5.    ngx_str_t   domain;

  6.    ngx_str_t   path;

  7.    ngx_str_t   p3p;

  8.    time_t      expires;

  9.    u_char      mark;

  10. } ngx_http_userid_conf_t;


变量

 
  1. typedef struct {

  2.    uint32_t    uid_got[4];

  3.    uint32_t    uid_set[4];

  4.    ngx_str_t   cookie;

  5.    ngx_uint_t  reset;

  6. } ngx_http_userid_ctx_t;


函数

 
  1. // 获取uid

  2. static ngx_http_userid_ctx_t *ngx_http_userid_get_uid(ngx_http_request_t *r,

  3.    ngx_http_userid_conf_t *conf);

  4.  

  5. // 变量

  6. static ngx_int_t ngx_http_userid_variable(ngx_http_request_t *r,

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值