資源簡介
nginx防盜鏈插件
代碼片段和文件信息
/*
?*?nginx?(c)?Igor?Sysoev
?*?this?module?(C)?Mykola?Grechukh?
?*/
#include?
#include?
#include?
#if?(NGX_HAVE_OPENSSL_MD5_H)
#include?
#else
#include?
#endif
#if?(NGX_OPENSSL_MD5)
#define??MD5Init????MD5_Init
#define??MD5Update??MD5_Update
#define??MD5Final???MD5_Final
#endif
#if?(NGX_HAVE_OPENSSL_SHA1_H)
#include?
#else
#include?
#endif
#define?NGX_ACCESSKEY_MD5?1
#define?NGX_ACCESSKEY_SHA1?2
typedef?struct?{
????ngx_flag_t????enable;
????ngx_str_t?????arg;
????ngx_uint_t????hashmethod;
????ngx_str_t?????signature;
????ngx_array_t??*signature_lengths;
????ngx_array_t??*signature_values;
}?ngx_http_accesskey_loc_conf_t;
static?ngx_int_t?ngx_http_accesskey_handler(ngx_http_request_t?*r);
static?char?*ngx_http_accesskey_signature(ngx_conf_t?*cf?void?*post?void?*data);
static?char?*ngx_http_accesskey_hashmethod(ngx_conf_t?*cf?ngx_command_t?*cmd?void?*conf);
static?void?*ngx_http_accesskey_create_loc_conf(ngx_conf_t?*cf);
static?char?*ngx_http_accesskey_merge_loc_conf(ngx_conf_t?*cf
????void?*parent?void?*child);
static?ngx_int_t?ngx_http_accesskey_init(ngx_conf_t?*cf);
static?ngx_conf_post_handler_pt??ngx_http_accesskey_signature_p?=
????ngx_http_accesskey_signature;
static?ngx_command_t??ngx_http_accesskey_commands[]?=?{
????{?ngx_string(“accesskey“)
??????NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG
??????ngx_conf_set_flag_slot
??????NGX_HTTP_LOC_CONF_OFFSET
??????offsetof(ngx_http_accesskey_loc_conf_t?enable)
??????NULL?}
????{?ngx_string(“accesskey_hashmethod“)
??????NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1
??????ngx_http_accesskey_hashmethod
??????NGX_HTTP_LOC_CONF_OFFSET
??????0
??????NULL?}
????{?ngx_string(“accesskey_signature“)
??????NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1
??????ngx_conf_set_str_slot
??????NGX_HTTP_LOC_CONF_OFFSET
??????offsetof(ngx_http_accesskey_loc_conf_t?signature)
??????&ngx_http_accesskey_signature_p?}
????{?ngx_string(“accesskey_arg“)
??????NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1
??????ngx_conf_set_str_slot
??????NGX_HTTP_LOC_CONF_OFFSET
??????offsetof(ngx_http_accesskey_loc_conf_t?arg)
??????NULL?}
??????ngx_null_command
};
static?ngx_http_module_t??ngx_http_accesskey_module_ctx?=?{
????NULL??????????????????????????????????/*?preconfiguration?*/
????ngx_http_accesskey_init??????????????????/*?postconfiguration?*/
????NULL??????????????????????????????????/*?create?main?configuration?*/
????NULL??????????????????????????????????/*?init?main?configuration?*/
????NULL??????????????????????????????????/*?create?server?configuration?*/
????NULL??????????????????????????????????/*?merge?server?configuration?*/
????ngx_http_accesskey_create_loc_conf???????/*?create?location?configuration?*/
????ngx_http_accesskey_merge_loc_conf?????????/*?merge?locati
評論
共有 條評論