Skip to content

Commit

Permalink
Stream: realip module.
Browse files Browse the repository at this point in the history
  • Loading branch information
xeioex committed Sep 1, 2016
1 parent a613df5 commit fe2774a
Show file tree
Hide file tree
Showing 5 changed files with 365 additions and 0 deletions.
10 changes: 10 additions & 0 deletions auto/modules
Expand Up @@ -1007,6 +1007,16 @@ if [ $STREAM != NO ]; then
. auto/module
fi

if [ $STREAM_REALIP = YES ]; then
ngx_module_name=ngx_stream_realip_module
ngx_module_deps=
ngx_module_srcs=src/stream/ngx_stream_realip_module.c
ngx_module_libs=
ngx_module_link=$STREAM_REALIP

. auto/module
fi

if [ $STREAM_LIMIT_CONN = YES ]; then
ngx_module_name=ngx_stream_limit_conn_module
ngx_module_deps=
Expand Down
3 changes: 3 additions & 0 deletions auto/options
Expand Up @@ -115,6 +115,7 @@ MAIL_SMTP=YES

STREAM=NO
STREAM_SSL=NO
STREAM_REALIP=NO
STREAM_LIMIT_CONN=YES
STREAM_ACCESS=YES
STREAM_GEO=YES
Expand Down Expand Up @@ -296,6 +297,7 @@ use the \"--with-mail_ssl_module\" option instead"
--with-stream) STREAM=YES ;;
--with-stream=dynamic) STREAM=DYNAMIC ;;
--with-stream_ssl_module) STREAM_SSL=YES ;;
--with-stream_realip_module) STREAM_REALIP=YES ;;
--with-stream_geoip_module) STREAM_GEOIP=YES ;;
--with-stream_geoip_module=dynamic)
STREAM_GEOIP=DYNAMIC ;;
Expand Down Expand Up @@ -503,6 +505,7 @@ cat << END
--with-stream enable TCP/UDP proxy module
--with-stream=dynamic enable dynamic TCP/UDP proxy module
--with-stream_ssl_module enable ngx_stream_ssl_module
--with-stream_realip_module enable ngx_stream_realip_module
--with-stream_geoip_module enable ngx_stream_geoip_module
--with-stream_geoip_module=dynamic enable dynamic ngx_stream_geoip_module
--without-stream_limit_conn_module disable ngx_stream_limit_conn_module
Expand Down
1 change: 1 addition & 0 deletions src/stream/ngx_stream.h
Expand Up @@ -122,6 +122,7 @@ typedef struct {
ngx_array_t servers; /* ngx_stream_core_srv_conf_t */
ngx_array_t listen; /* ngx_stream_listen_t */

ngx_stream_access_pt realip_handler;
ngx_stream_access_pt limit_conn_handler;
ngx_stream_access_pt access_handler;
ngx_stream_access_pt access_log_handler;
Expand Down
9 changes: 9 additions & 0 deletions src/stream/ngx_stream_handler.c
Expand Up @@ -296,6 +296,15 @@ ngx_stream_init_session_handler(ngx_event_t *rev)

cmcf = ngx_stream_get_module_main_conf(s, ngx_stream_core_module);

if (cmcf->realip_handler) {
rc = cmcf->realip_handler(s);

if (rc == NGX_ERROR) {
ngx_stream_finalize_session(s, NGX_STREAM_INTERNAL_SERVER_ERROR);
return;
}
}

if (cmcf->limit_conn_handler) {
rc = cmcf->limit_conn_handler(s);

Expand Down

0 comments on commit fe2774a

Please sign in to comment.