Skip to content

Commit

Permalink
add ngx_http_user_agent_module and a data structure named ngx_trie
Browse files Browse the repository at this point in the history
git-svn-id: http://code.taobao.org/svn/tengine/trunk@43 8a6cbc4f-5610-49f6-9325-3f9afe71ff98
  • Loading branch information
xiongjunmin committed Mar 30, 2012
1 parent fe9e29f commit 94b2e76
Show file tree
Hide file tree
Showing 10 changed files with 1,294 additions and 0 deletions.
11 changes: 11 additions & 0 deletions auto/install
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ install: $NGX_OBJS${ngx_dirsep}nginx${ngx_binext} \
END


if [ $HTTP_USER_AGENT = YES ]; then
cat << END >> $NGX_MAKEFILE

test -f '\$(DESTDIR)$NGX_CONF_PREFIX/browsers' \
|| cp conf/browsers '\$(DESTDIR)$NGX_CONF_PREFIX'
cp conf/browsers '\$(DESTDIR)$NGX_CONF_PREFIX/browsers'
END

fi


if test -n "$NGX_ERROR_LOG_PATH"; then
cat << END >> $NGX_MAKEFILE

Expand Down
5 changes: 5 additions & 0 deletions auto/modules
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@ if [ $HTTP_BROWSER = YES ]; then
HTTP_SRCS="$HTTP_SRCS $HTTP_BROWSER_SRCS"
fi

if [ $HTTP_USER_AGENT = YES ]; then
HTTP_MODULES="$HTTP_MODULES $HTTP_USER_AGENT_MODULE"
HTTP_SRCS="$HTTP_SRCS $HTTP_USER_AGENT_SRCS"
fi

if [ $HTTP_SECURE_LINK = YES ]; then
USE_MD5=YES
HTTP_MODULES="$HTTP_MODULES $HTTP_SECURE_LINK_MODULE"
Expand Down
3 changes: 3 additions & 0 deletions auto/options
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ HTTP_MP4=NO
HTTP_GZIP_STATIC=NO
HTTP_UPSTREAM_IP_HASH=YES
HTTP_FOOTER=YES
HTTP_USER_AGENT=YES

# STUB
HTTP_STUB_STATUS=NO
Expand Down Expand Up @@ -243,6 +244,7 @@ do
--without-http_limit_req_module) HTTP_LIMIT_REQ=NO ;;
--without-http_empty_gif_module) HTTP_EMPTY_GIF=NO ;;
--without-http_browser_module) HTTP_BROWSER=NO ;;
--without-http_user_agent_module) HTTP_USER_AGENT=NO ;;
--without-http_upstream_ip_hash_module) HTTP_UPSTREAM_IP_HASH=NO ;;

--with-http_perl_module) HTTP_PERL=YES ;;
Expand Down Expand Up @@ -387,6 +389,7 @@ cat << END
--without-http_browser_module disable ngx_http_browser_module
--without-http_upstream_ip_hash_module
disable ngx_http_upstream_ip_hash_module
--without-http_user_agent_module disable ngx_http_user_agent_module

--with-http_perl_module enable ngx_http_perl_module
--with-perl_modules_path=PATH set Perl modules path
Expand Down
6 changes: 6 additions & 0 deletions auto/sources
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ CORE_DEPS="src/core/nginx.h \
src/core/ngx_md5.h \
src/core/ngx_sha1.h \
src/core/ngx_rbtree.h \
src/core/ngx_trie.h \
src/core/ngx_radix_tree.h \
src/core/ngx_slab.h \
src/core/ngx_times.h \
Expand Down Expand Up @@ -56,6 +57,7 @@ CORE_SRCS="src/core/nginx.c \
src/core/ngx_murmurhash.c \
src/core/ngx_md5.c \
src/core/ngx_rbtree.c \
src/core/ngx_trie.c
src/core/ngx_radix_tree.c \
src/core/ngx_slab.c \
src/core/ngx_times.c \
Expand Down Expand Up @@ -468,6 +470,10 @@ HTTP_BROWSER_MODULE=ngx_http_browser_module
HTTP_BROWSER_SRCS=src/http/modules/ngx_http_browser_module.c


HTTP_USER_AGENT_MODULE=ngx_http_user_agent_module
HTTP_USER_AGENT_SRCS=src/http/modules/ngx_http_user_agent_module.c


HTTP_SECURE_LINK_MODULE=ngx_http_secure_link_module
HTTP_SECURE_LINK_SRCS=src/http/modules/ngx_http_secure_link_module.c

Expand Down
100 changes: 100 additions & 0 deletions conf/browsers
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# syntax:
#
# user_agent $variable_name {
# default value;
# nongreedy name;
#
# name [([+|-]version) | (version1~version2)] value;
# }

user_agent $browser {

# default
default unknown;

# nongreedy
nongreedy Chrome;
nongreedy Safari;
nongreedy Firefox;

# name version value

# match version greater than 18.0[18.0,+OO]
Chrome 18.0+ chrome18;
# match version in[16.0,16.9999]
Chrome 17.0~17.9999 chrome17;
Chrome 16.0~16.9999 chrome16;
Chrome 15.0~15.9999 chrome15;
Chrome 14.0~14.9999 chrome14;
Chrome 13.0~13.9999 chrome13;
Chrome 12.0~12.9999 chrome12;
Chrome 11.0~11.9999 chrome11;
Chrome 10.0~10.9999 chrome10;
Chrome 0~0.9999 chrome_low;

# match version 4.0 exactly
ChromePlus 4.0 chromeplus4;
ChromePlus 0~3.9999 chromeplus;

Firebird 3.0~3.9999 firebird3;
Firebird 0.7~0.7.9999 firebird07;
Firebird 0.6~0.6.9999 firebird06;

Firefox 9.0~9.9999 firefox9;
Firefox 7.0~7.9999 firefox7;
Firefox 8.0~8.9999 firefox8;
Firefox 6.0~6.9999 firefox6;
Firefox 5.0~5.9999 firefox5;
Firefox 4.0~4.9999 firefox4;
Firefox 0~3.9999 firefox_low;

MSIE 10.0~10.9999 msie10;
MSIE 9.0~9.9999 msie9;
MSIE 8.0~8.9999 msie8;
MSIE 7.0~7.9999 msie7;
MSIE 6.0~6.9999 msie6;
# match version less than 5.9999[-OO,5.9999]
MSIE 5.9999- msie_low;

Maxthon 3.0~3.9999 maxthon3;
Maxthon 2.9999- maxthon_low;

Safari safari5;

# match all versions
Opera opera;

# mobile browsers
BlackBerry blackberry;

Blazer blazer;

'Maemo Browser' maemobrowser;

'Opera Mini' operamini;
'Opera Mobile' operamobile;

Skyfire skyfire;

UCWEB UCWEB;
}

user_agent $os {
default unknown;

iPad ipad;
iPhone iphone;
Symbian symbian;
MeeGo meego;
'Windows Phone' windowsphone;
Android android;
BlackBerry blackberry;
MIUI miui;
'Windows NT' 5.1 windowsxp;
'Windows NT' 6.1 windows7;
'Windows NT' 6.0 windowsvista;
linux linux;
unix unix;
FreeBSD freebsd;
Macintosh macos;
}
1 change: 1 addition & 0 deletions src/core/ngx_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ typedef void (*ngx_connection_handler_pt)(ngx_connection_t *c);
#if (NGX_PCRE)
#include <ngx_regex.h>
#endif
#include <ngx_trie.h>
#include <ngx_radix_tree.h>
#include <ngx_times.h>
#include <ngx_shmtx.h>
Expand Down
Loading

0 comments on commit 94b2e76

Please sign in to comment.