Permalink
Browse files

Make hash functions compatible with ngx_http_set_hash

  • Loading branch information...
1 parent e7c6c16 commit 514503081761f3c25189b0f781f96f75e795decf Marcus Clyne committed Oct 13, 2010
Showing with 15 additions and 4 deletions.
  1. +7 −1 config
  2. +4 −3 src/ngx_http_set_hash.c
  3. +4 −0 src/ngx_http_set_misc_module.c
View
@@ -2,4 +2,10 @@ ngx_addon_name=ngx_http_set_misc_module
HTTP_AUX_FILTER_MODULES="$HTTP_AUX_FILTER_MODULES ngx_http_set_misc_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/src/ngx_http_set_base32.c $ngx_addon_dir/src/ngx_http_set_default_value.c $ngx_addon_dir/src/ngx_http_set_hashed_upstream.c $ngx_addon_dir/src/ngx_http_set_quote_sql.c $ngx_addon_dir/src/ngx_http_set_quote_json.c $ngx_addon_dir/src/ngx_http_set_unescape_uri.c $ngx_addon_dir/src/ngx_http_set_misc_module.c $ngx_addon_dir/src/ngx_http_set_escape_uri.c $ngx_addon_dir/src/ngx_http_set_hash.c $ngx_addon_dir/src/ngx_http_set_local_today.c"
NGX_ADDON_DEPS="$NGX_ADDON_DEPS $ngx_addon_dir/src/ddebug.h $ngx_addon_dir/src/ngx_http_set_default_value.h $ngx_addon_dir/src/ngx_http_set_hashed_upstream.h $ngx_addon_dir/src/ngx_http_set_quote_sql.h $ngx_addon_dir/src/ngx_http_set_quote_json.h $ngx_addon_dir/src/ngx_http_set_unescape_uri.h $ngx_addon_dir/src/ngx_http_set_escape_uri.h $ngx_addon_dir/src/ngx_http_set_hash.h $ngx_addon_dir/src/ngx_http_set_local_today.h"
-CFLAGS="$CFLAGS -DNGX_HAVE_OPENSSL_MD5_H -DNGX_HAVE_OPENSSL_SHA1_H -DNDK_SET_VAR -DNDK_HASH -DNDK_SHA1 -DNDK_UPSTREAM_LIST -DNDK_MD5"
+
+have=NDK_HASH . auto/have
+have=NDK_UPSTREAM_LIST . auto/have
+
+USE_OPENSSL=YES
+USE_MD5=YES
+USE_SHA1=YES
@@ -4,7 +4,7 @@
#include <ndk.h>
#include "ngx_http_set_hash.h"
-
+#ifndef NGX_HTTP_SET_HASH
ngx_int_t
ngx_http_set_misc_set_sha1(ngx_http_request_t *r,
ngx_str_t *res, ngx_http_variable_value_t *v)
@@ -16,7 +16,7 @@ ngx_http_set_misc_set_sha1(ngx_http_request_t *r,
return NGX_ERROR;
}
- ndk_sha1_lower_hash((char *) p, (char *) v->data, v->len);
+ ndk_sha1_hash((char *) p, (char *) v->data, v->len);
res->data = p;
res->len = SHA_DIGEST_LENGTH * 2;
@@ -34,10 +34,11 @@ ngx_http_set_misc_set_md5(ngx_http_request_t *r,
return NGX_ERROR;
}
- ndk_md5_lower_hash((char *) p, (char *) v->data, v->len);
+ ndk_md5_hash((char *) p, (char *) v->data, v->len);
res->data = p;
res->len = MD5_DIGEST_LENGTH * 2;
return NGX_OK;
}
+#endif
@@ -14,6 +14,7 @@
#define NGX_UNESCAPE_URI_COMPONENT 0
+#ifndef NGX_HTTP_SET_HASH
static ndk_set_var_t ngx_http_set_misc_set_md5_filter = {
NDK_SET_VAR_VALUE,
ngx_http_set_misc_set_md5,
@@ -27,6 +28,7 @@ static ndk_set_var_t ngx_http_set_misc_set_sha1_filter = {
1,
NULL
};
+#endif
static ndk_set_var_t ngx_http_set_misc_unescape_uri_filter = {
NDK_SET_VAR_VALUE,
@@ -85,6 +87,7 @@ static ndk_set_var_t ngx_http_set_misc_local_today_filter = {
};
static ngx_command_t ngx_http_set_misc_commands[] = {
+#ifndef NGX_HTTP_SET_HASH
{ ngx_string ("set_md5"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_SIF_CONF
|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE12,
@@ -102,6 +105,7 @@ static ngx_command_t ngx_http_set_misc_commands[] = {
0,
&ngx_http_set_misc_set_sha1_filter
},
+#endif
{
ngx_string ("set_unescape_uri"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_SIF_CONF

0 comments on commit 5145030

Please sign in to comment.