From 493e28dd83f72dc3535cda4158e4177e904369a6 Mon Sep 17 00:00:00 2001 From: stefanocasazza Date: Sat, 29 Jul 2017 18:44:48 +0200 Subject: [PATCH] sync --- Makefile.am | 5 +- Makefile.in | 11 +- ULib.spec.in | 23 +- configure | 12 +- configure.ac | 10 +- contrib/HCSP/Makefile.in | 1 + contrib/Makefile.in | 1 + contrib/RSIGN/Makefile.in | 1 + contrib/signer/Makefile.in | 1 + doc/Makefile.in | 1 + examples/IR/Makefile.in | 1 + examples/IR/posting.cpp | 4 +- examples/Makefile.in | 1 + examples/PEC_log/Makefile.in | 1 + examples/PEC_log/PEC_report_anomalie1.cpp | 2 +- examples/PEC_log/PEC_report_messaggi.cpp | 2 +- examples/WiAuth/Makefile.in | 1 + examples/XAdES/Makefile.in | 1 + examples/csp/Makefile.in | 1 + examples/doc_classifier/Makefile.in | 1 + examples/doc_parse/Makefile.in | 1 + examples/download_accelerator/Makefile.in | 1 + examples/form_completion/Makefile.in | 1 + examples/hello/Makefile.in | 1 + examples/http_header/Makefile.in | 1 + examples/lcsp/Makefile.in | 1 + examples/lrp_session/Makefile.in | 1 + examples/rsign/Makefile.in | 1 + examples/simple_client_server/Makefile.in | 1 + examples/test_manager/Makefile.in | 1 + examples/uclient/Makefile.in | 1 + examples/userver/Makefile.in | 1 + examples/userver/userver.cfg.default | 2 + examples/userver/userver.cpp | 2 + examples/workflow/Makefile.in | 1 + examples/xml2txt/Makefile.in | 1 + fuzz/Makefile.in | 1 + include/Makefile.in | 1 + include/ulib/Makefile.in | 1 + include/ulib/base/utility.h | 30 ++- include/ulib/curl/curl.h | 2 +- include/ulib/json/value.h | 44 +++- include/ulib/net/ipaddress.h | 89 ++++++-- include/ulib/net/server/plugin/mod_nocat.h | 1 + include/ulib/net/server/server.h | 8 +- include/ulib/utility/uhttp.h | 4 + m4/Makefile.in | 1 + src/ulib/Makefile.in | 1 + src/ulib/curl/curl.cpp | 20 +- src/ulib/net/ipaddress.cpp | 130 ++--------- src/ulib/net/server/plugin/Makefile.in | 1 + .../net/server/plugin/mod_geoip/Makefile.in | 1 + src/ulib/net/server/plugin/mod_nocat.cpp | 13 +- .../net/server/plugin/mod_shib/Makefile.in | 1 + .../net/server/plugin/page_speed/Makefile.in | 1 + src/ulib/net/server/plugin/php/Makefile.in | 1 + src/ulib/net/server/plugin/python/Makefile.in | 1 + src/ulib/net/server/plugin/ruby/Makefile.in | 1 + src/ulib/net/server/plugin/usp/Makefile.in | 1 + src/ulib/net/server/plugin/v8/Makefile.in | 1 + src/ulib/net/server/server.cpp | 83 ++++--- src/ulib/orm/driver/Makefile.in | 1 + src/ulib/utility/uhttp.cpp | 216 ++++++++++-------- tests/Makefile.in | 1 + tests/base/Makefile.in | 1 + tests/base/test_utility.c | 71 ++++-- tests/contrib/Makefile.in | 1 + tests/debug/Makefile.in | 1 + tests/examples/Makefile.am | 3 + tests/examples/Makefile.in | 180 +++++++++++++-- tests/examples/bench_http_parser.cpp | 87 +++++++ tests/examples/web_server.sh | 1 + tests/ulib/Makefile.in | 1 + tests/ulib/http2/Makefile.in | 1 + userver.service.in | 38 +++ 75 files changed, 797 insertions(+), 343 deletions(-) create mode 100644 tests/examples/bench_http_parser.cpp create mode 100644 userver.service.in diff --git a/Makefile.am b/Makefile.am index dd40ec230..966cac775 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,7 +3,10 @@ AUTOMAKE_OPTIONS = no-dependencies ## dist-shar dist-zip ACLOCAL_AMFLAGS = -I m4 -EXTRA_DIST = cdb configure.help TODO LICENSE* README* *.spec* \ +configfiles = userver.service + +EXTRA_DIST = $(configfiles:%=%.in) \ + cdb configure.help TODO LICENSE* README* *.spec* \ ULib.m4 rpm.sh rpmpkgreq.lst rpmpkgreq.lst.suse openwrt \ doc/Doxyfile doc/readme.txt shtool *.awk .travis.yml autogen.sh nativejson-benchmark \ fuzz/http1-corpus fuzz/http2-corpus fuzz/build_libFuzzer.sh fuzz/Makefile.in fuzz/Makefile.am fuzz/uclient_fuzzer.cpp fuzz/uclient.cfg diff --git a/Makefile.in b/Makefile.in index a6312de02..dec39a5ee 100644 --- a/Makefile.in +++ b/Makefile.in @@ -118,7 +118,7 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/ulib/internal/config.h -CONFIG_CLEAN_FILES = rpm.sh ULib.spec +CONFIG_CLEAN_FILES = rpm.sh ULib.spec userver.service CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) @@ -207,7 +207,7 @@ ETAGS = etags CTAGS = ctags CSCOPE = cscope am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/ULib.spec.in \ - $(srcdir)/rpm.sh.in \ + $(srcdir)/rpm.sh.in $(srcdir)/userver.service.in \ $(top_srcdir)/include/ulib/internal/config.h.in AUTHORS \ ChangeLog INSTALL NEWS README THANKS TODO compile config.guess \ config.sub install-sh ltmain.sh missing ylwrap @@ -371,6 +371,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ @@ -446,7 +447,9 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = no-dependencies ## dist-shar dist-zip ACLOCAL_AMFLAGS = -I m4 -EXTRA_DIST = cdb configure.help TODO LICENSE* README* *.spec* \ +configfiles = userver.service +EXTRA_DIST = $(configfiles:%=%.in) \ + cdb configure.help TODO LICENSE* README* *.spec* \ ULib.m4 rpm.sh rpmpkgreq.lst rpmpkgreq.lst.suse openwrt \ doc/Doxyfile doc/readme.txt shtool *.awk .travis.yml autogen.sh nativejson-benchmark \ fuzz/http1-corpus fuzz/http2-corpus fuzz/build_libFuzzer.sh fuzz/Makefile.in fuzz/Makefile.am fuzz/uclient_fuzzer.cpp fuzz/uclient.cfg @@ -512,6 +515,8 @@ rpm.sh: $(top_builddir)/config.status $(srcdir)/rpm.sh.in cd $(top_builddir) && $(SHELL) ./config.status $@ ULib.spec: $(top_builddir)/config.status $(srcdir)/ULib.spec.in cd $(top_builddir) && $(SHELL) ./config.status $@ +userver.service: $(top_builddir)/config.status $(srcdir)/userver.service.in + cd $(top_builddir) && $(SHELL) ./config.status $@ mostlyclean-libtool: -rm -f *.lo diff --git a/ULib.spec.in b/ULib.spec.in index 439a6703d..aaab7f0b0 100644 --- a/ULib.spec.in +++ b/ULib.spec.in @@ -36,9 +36,8 @@ make LDFLAGS="-s" %install rm -rf %{buildroot} %makeinstall -mkdir -p %{_sysconfdir}/ulib mkdir -p %{buildroot}/usr/share/aclocal -mkdir -p %{buildroot}/usr/libexec/ulib/usp +mkdir -p %{buildroot}/usr/libexec/usp %clean rm -rf %{buildroot} @@ -50,9 +49,9 @@ rm -rf %{buildroot} %{_bindir}/userver_* %{_libdir}/*.so.* %{_sysconfdir}/*.cfg* -%{_libexecdir}/ulib/mod_*.* -%{_libexecdir}/ulib/usp/*.* -%dir %{_libexecdir}/ulib/usp +%{_libexecdir}/mod_*.* +%{_libexecdir}/usp/*.* +%dir %{_libexecdir}/usp %files devel %defattr(-,root,root,-) @@ -74,13 +73,13 @@ rm -rf %{buildroot} %{_includedir}/ulib/flex/flexer_head.ll %{_datadir}/aclocal/*.m4 %{_libdir}/pkgconfig/*.pc -%{_libexecdir}/ulib/mod_*.a -%{_libexecdir}/ulib/mod_*.so -%{_libexecdir}/ulib/mod_*.la -%{_libexecdir}/ulib/usp/*.a -%{_libexecdir}/ulib/usp/*.so -%{_libexecdir}/ulib/usp/*.la -%dir %{_libexecdir}/ulib/usp +%{_libexecdir}/mod_*.a +%{_libexecdir}/mod_*.so +%{_libexecdir}/mod_*.la +%{_libexecdir}/usp/*.a +%{_libexecdir}/usp/*.so +%{_libexecdir}/usp/*.la +%dir %{_libexecdir}/usp %post -p /sbin/ldconfig diff --git a/configure b/configure index e267ae061..c84e6c0a8 100755 --- a/configure +++ b/configure @@ -639,6 +639,7 @@ am__EXEEXT_TRUE LTLIBOBJS ULIB_SYSCONFDIR ULIB_MODULEDIR +ULIB_PREFIXDIR RPM_CONFIGURE STD_GNU11 USP_LDFLAGS @@ -32833,7 +32834,11 @@ if test -n "$posix4_lib"; then ULIB_LIBS="$ULIB_LIBS $posix4_lib"; fi if test -n "$plib"; then - ULIB_LIBS="$ULIB_LIBS -Wl,--no-as-needed $plib"; + if test "$with_gnu_ld" = "yes" -a "$enable_new_ldflags" = "yes"; then + ULIB_LIBS="$ULIB_LIBS -Wl,--no-as-needed $plib"; + else + ULIB_LIBS="$ULIB_LIBS $plib"; + fi fi if test "$enable_coverage" = "yes"; then ULIB_LIBS="$ULIB_LIBS -lgcov" @@ -33219,6 +33224,8 @@ cat >>confdefs.h <<_ACEOF _ACEOF +ULIB_PREFIXDIR="$u_prefixdir" + ULIB_MODULEDIR="$u_libexecdir" ULIB_SYSCONFDIR="$u_sysconfdir" @@ -33350,7 +33357,7 @@ See include/ulib/internal/config.h for further configuration information # SECTION 16: `AC_CONFIG_FILES([FILE...]) -ac_config_files="$ac_config_files Makefile rpm.sh ULib.spec m4/Makefile doc/Makefile include/Makefile contrib/Makefile include/ulib/Makefile contrib/HCSP/Makefile contrib/RSIGN/Makefile contrib/signer/Makefile fuzz/Makefile src/ulib/Makefile src/ulib/ULib.rc src/ulib/ULib.pc src/ulib/orm/driver/Makefile src/ulib/net/server/plugin/Makefile src/ulib/net/server/plugin/v8/Makefile src/ulib/net/server/plugin/php/Makefile src/ulib/net/server/plugin/usp/Makefile src/ulib/net/server/plugin/ruby/Makefile src/ulib/net/server/plugin/mod_shib/Makefile src/ulib/net/server/plugin/mod_geoip/Makefile src/ulib/net/server/plugin/usp/usp_compile.sh src/ulib/net/server/plugin/page_speed/Makefile src/ulib/net/server/plugin/python/Makefile examples/Makefile examples/IR/Makefile examples/csp/Makefile examples/lcsp/Makefile examples/rsign/Makefile examples/hello/Makefile examples/WiAuth/Makefile examples/xml2txt/Makefile examples/uclient/Makefile examples/userver/Makefile examples/PEC_log/Makefile examples/workflow/Makefile examples/doc_parse/Makefile examples/lrp_session/Makefile examples/http_header/Makefile examples/test_manager/Makefile examples/doc_classifier/Makefile examples/form_completion/Makefile examples/simple_client_server/Makefile examples/download_accelerator/Makefile examples/XAdES/Makefile examples/XAdES/XAdES.spec examples/xml2txt/xml2txt.spec examples/IR/searchengine-bin.spec examples/lcsp/lcsp.spec examples/lcsp/lcsp_rpc.spec examples/csp/cspclient.spec examples/csp/cspclient_rpc.spec examples/rsign/rsignclient.spec examples/rsign/rsignclient_rpc.spec examples/userver/web_server.spec examples/userver/wagsmserver.spec examples/workflow/workflow.spec examples/PEC_log/PEC_log.spec examples/userver/tsaserver.spec examples/userver/cspserver.spec examples/userver/rsignserver.spec examples/doc_parse/doc_parse.spec tests/Makefile tests/base/Makefile tests/debug/Makefile tests/ulib/Makefile tests/ulib/http2/Makefile tests/examples/Makefile tests/contrib/Makefile" +ac_config_files="$ac_config_files Makefile rpm.sh ULib.spec userver.service m4/Makefile doc/Makefile include/Makefile contrib/Makefile include/ulib/Makefile contrib/HCSP/Makefile contrib/RSIGN/Makefile contrib/signer/Makefile fuzz/Makefile src/ulib/Makefile src/ulib/ULib.rc src/ulib/ULib.pc src/ulib/orm/driver/Makefile src/ulib/net/server/plugin/Makefile src/ulib/net/server/plugin/v8/Makefile src/ulib/net/server/plugin/php/Makefile src/ulib/net/server/plugin/usp/Makefile src/ulib/net/server/plugin/ruby/Makefile src/ulib/net/server/plugin/mod_shib/Makefile src/ulib/net/server/plugin/mod_geoip/Makefile src/ulib/net/server/plugin/usp/usp_compile.sh src/ulib/net/server/plugin/page_speed/Makefile src/ulib/net/server/plugin/python/Makefile examples/Makefile examples/IR/Makefile examples/csp/Makefile examples/lcsp/Makefile examples/rsign/Makefile examples/hello/Makefile examples/WiAuth/Makefile examples/xml2txt/Makefile examples/uclient/Makefile examples/userver/Makefile examples/PEC_log/Makefile examples/workflow/Makefile examples/doc_parse/Makefile examples/lrp_session/Makefile examples/http_header/Makefile examples/test_manager/Makefile examples/doc_classifier/Makefile examples/form_completion/Makefile examples/simple_client_server/Makefile examples/download_accelerator/Makefile examples/XAdES/Makefile examples/XAdES/XAdES.spec examples/xml2txt/xml2txt.spec examples/IR/searchengine-bin.spec examples/lcsp/lcsp.spec examples/lcsp/lcsp_rpc.spec examples/csp/cspclient.spec examples/csp/cspclient_rpc.spec examples/rsign/rsignclient.spec examples/rsign/rsignclient_rpc.spec examples/userver/web_server.spec examples/userver/wagsmserver.spec examples/workflow/workflow.spec examples/PEC_log/PEC_log.spec examples/userver/tsaserver.spec examples/userver/cspserver.spec examples/userver/rsignserver.spec examples/doc_parse/doc_parse.spec tests/Makefile tests/base/Makefile tests/debug/Makefile tests/ulib/Makefile tests/ulib/http2/Makefile tests/examples/Makefile tests/contrib/Makefile" # examples/parser/Makefile \ @@ -35200,6 +35207,7 @@ do "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "rpm.sh") CONFIG_FILES="$CONFIG_FILES rpm.sh" ;; "ULib.spec") CONFIG_FILES="$CONFIG_FILES ULib.spec" ;; + "userver.service") CONFIG_FILES="$CONFIG_FILES userver.service" ;; "m4/Makefile") CONFIG_FILES="$CONFIG_FILES m4/Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;; diff --git a/configure.ac b/configure.ac index 7a025f74d..b46f7cf24 100644 --- a/configure.ac +++ b/configure.ac @@ -2512,7 +2512,11 @@ if test -n "$posix4_lib"; then ULIB_LIBS="$ULIB_LIBS $posix4_lib"; fi if test -n "$plib"; then - ULIB_LIBS="$ULIB_LIBS -Wl,--no-as-needed $plib"; + if test "$with_gnu_ld" = "yes" -a "$enable_new_ldflags" = "yes"; then + ULIB_LIBS="$ULIB_LIBS -Wl,--no-as-needed $plib"; + else + ULIB_LIBS="$ULIB_LIBS $plib"; + fi fi if test "$enable_coverage" = "yes"; then ULIB_LIBS="$ULIB_LIBS -lgcov" @@ -2674,6 +2678,8 @@ AC_DEFINE_UNQUOTED(U_LIBEXECDIR, "$u_libexecdir", [install directory for plugins # Config dir - read-only single-machine data [PREFIX/etc] AC_DEFINE_UNQUOTED(U_SYSCONFDIR, "$u_sysconfdir", [install directory for configuration data]) +ULIB_PREFIXDIR="$u_prefixdir" +AC_SUBST(ULIB_PREFIXDIR) ULIB_MODULEDIR="$u_libexecdir" AC_SUBST(ULIB_MODULEDIR) ULIB_SYSCONFDIR="$u_sysconfdir" @@ -2745,7 +2751,7 @@ See include/ulib/internal/config.h for further configuration information # SECTION 16: `AC_CONFIG_FILES([FILE...]) AC_CONFIG_FILES([ - Makefile rpm.sh ULib.spec m4/Makefile doc/Makefile include/Makefile contrib/Makefile + Makefile rpm.sh ULib.spec userver.service m4/Makefile doc/Makefile include/Makefile contrib/Makefile include/ulib/Makefile contrib/HCSP/Makefile contrib/RSIGN/Makefile contrib/signer/Makefile fuzz/Makefile src/ulib/Makefile src/ulib/ULib.rc src/ulib/ULib.pc src/ulib/orm/driver/Makefile src/ulib/net/server/plugin/Makefile src/ulib/net/server/plugin/v8/Makefile src/ulib/net/server/plugin/php/Makefile src/ulib/net/server/plugin/usp/Makefile diff --git a/contrib/HCSP/Makefile.in b/contrib/HCSP/Makefile.in index a7aaaa69b..f53e70758 100644 --- a/contrib/HCSP/Makefile.in +++ b/contrib/HCSP/Makefile.in @@ -335,6 +335,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/contrib/Makefile.in b/contrib/Makefile.in index 75111c61a..869bfbf81 100644 --- a/contrib/Makefile.in +++ b/contrib/Makefile.in @@ -318,6 +318,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/contrib/RSIGN/Makefile.in b/contrib/RSIGN/Makefile.in index 88abaf86c..97e21c1e4 100644 --- a/contrib/RSIGN/Makefile.in +++ b/contrib/RSIGN/Makefile.in @@ -307,6 +307,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/contrib/signer/Makefile.in b/contrib/signer/Makefile.in index cad1b6d88..469636c76 100644 --- a/contrib/signer/Makefile.in +++ b/contrib/signer/Makefile.in @@ -306,6 +306,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/doc/Makefile.in b/doc/Makefile.in index ed779125f..30d88207c 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -256,6 +256,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/IR/Makefile.in b/examples/IR/Makefile.in index 99fd648cc..f2ff2916b 100644 --- a/examples/IR/Makefile.in +++ b/examples/IR/Makefile.in @@ -403,6 +403,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/IR/posting.cpp b/examples/IR/posting.cpp index 5b175bc5f..f9583549f 100644 --- a/examples/IR/posting.cpp +++ b/examples/IR/posting.cpp @@ -104,8 +104,8 @@ UPosting::UPosting(uint32_t dimension, bool parsing, bool index) dimension += dimension / 4; - U_NEW(UHashMap, tbl_name, UHashMap(u_nextPowerOfTwo64(dimension))); - U_NEW(UHashMap, tbl_words, UHashMap(u_nextPowerOfTwo64(approximate_num_words), ignore_case)); + U_NEW(UHashMap, tbl_name, UHashMap(u_nextPowerOfTwo(dimension))); + U_NEW(UHashMap, tbl_words, UHashMap(u_nextPowerOfTwo(approximate_num_words), ignore_case)); } if (parsing) diff --git a/examples/Makefile.in b/examples/Makefile.in index d5a461021..846cbfa9e 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -328,6 +328,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/PEC_log/Makefile.in b/examples/PEC_log/Makefile.in index 85219ca98..c7c77ddf9 100644 --- a/examples/PEC_log/Makefile.in +++ b/examples/PEC_log/Makefile.in @@ -404,6 +404,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/PEC_log/PEC_report_anomalie1.cpp b/examples/PEC_log/PEC_report_anomalie1.cpp index c7a341f5e..9c4fe92fd 100644 --- a/examples/PEC_log/PEC_report_anomalie1.cpp +++ b/examples/PEC_log/PEC_report_anomalie1.cpp @@ -323,7 +323,7 @@ class Application : public PEC_report_anomalie { // setting for anomalie - table = new UHashMap(u_nextPowerOfTwo64(max_size_table + MARGINE), true); // ignore case + table = new UHashMap(u_nextPowerOfTwo(max_size_table + MARGINE), true); // ignore case rdbname = new UString(100U); Messaggio::id_max_ttl = new UString; diff --git a/examples/PEC_log/PEC_report_messaggi.cpp b/examples/PEC_log/PEC_report_messaggi.cpp index cb72a602e..a810422ba 100644 --- a/examples/PEC_log/PEC_report_messaggi.cpp +++ b/examples/PEC_log/PEC_report_messaggi.cpp @@ -417,7 +417,7 @@ class Application : public PEC_report { // setting for messaggi - table = new UHashMap(u_nextPowerOfTwo64(16 * 1024), true); // ignore case + table = new UHashMap(u_nextPowerOfTwo(16 * 1024), true); // ignore case PEC_report::parse = Application::parseLineForMessaggi; PEC_report::change_file = Application::reportNumCaselle; diff --git a/examples/WiAuth/Makefile.in b/examples/WiAuth/Makefile.in index 33d54e2d4..5d064b2e5 100644 --- a/examples/WiAuth/Makefile.in +++ b/examples/WiAuth/Makefile.in @@ -387,6 +387,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/XAdES/Makefile.in b/examples/XAdES/Makefile.in index bd4d02962..907f39580 100644 --- a/examples/XAdES/Makefile.in +++ b/examples/XAdES/Makefile.in @@ -347,6 +347,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/csp/Makefile.in b/examples/csp/Makefile.in index 0c438d7c1..4947da360 100644 --- a/examples/csp/Makefile.in +++ b/examples/csp/Makefile.in @@ -320,6 +320,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/doc_classifier/Makefile.in b/examples/doc_classifier/Makefile.in index 75e8df1eb..21a097af3 100644 --- a/examples/doc_classifier/Makefile.in +++ b/examples/doc_classifier/Makefile.in @@ -327,6 +327,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/doc_parse/Makefile.in b/examples/doc_parse/Makefile.in index e54ed436c..7292f6244 100644 --- a/examples/doc_parse/Makefile.in +++ b/examples/doc_parse/Makefile.in @@ -308,6 +308,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/download_accelerator/Makefile.in b/examples/download_accelerator/Makefile.in index 75fc9d3e5..2c838762c 100644 --- a/examples/download_accelerator/Makefile.in +++ b/examples/download_accelerator/Makefile.in @@ -308,6 +308,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/form_completion/Makefile.in b/examples/form_completion/Makefile.in index 9b886e81e..090bea82f 100644 --- a/examples/form_completion/Makefile.in +++ b/examples/form_completion/Makefile.in @@ -308,6 +308,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/hello/Makefile.in b/examples/hello/Makefile.in index 79b065f5a..db72cb33d 100644 --- a/examples/hello/Makefile.in +++ b/examples/hello/Makefile.in @@ -304,6 +304,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/http_header/Makefile.in b/examples/http_header/Makefile.in index c83e29424..076c7acb0 100644 --- a/examples/http_header/Makefile.in +++ b/examples/http_header/Makefile.in @@ -306,6 +306,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/lcsp/Makefile.in b/examples/lcsp/Makefile.in index 1b30ff937..d5c18eae1 100644 --- a/examples/lcsp/Makefile.in +++ b/examples/lcsp/Makefile.in @@ -320,6 +320,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/lrp_session/Makefile.in b/examples/lrp_session/Makefile.in index 2d6a9b12e..b82316e2a 100644 --- a/examples/lrp_session/Makefile.in +++ b/examples/lrp_session/Makefile.in @@ -313,6 +313,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/rsign/Makefile.in b/examples/rsign/Makefile.in index 73fd56753..b8a34c764 100644 --- a/examples/rsign/Makefile.in +++ b/examples/rsign/Makefile.in @@ -321,6 +321,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/simple_client_server/Makefile.in b/examples/simple_client_server/Makefile.in index e96d582d9..f68d677a8 100644 --- a/examples/simple_client_server/Makefile.in +++ b/examples/simple_client_server/Makefile.in @@ -313,6 +313,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/test_manager/Makefile.in b/examples/test_manager/Makefile.in index 89ca0ffd7..456f65046 100644 --- a/examples/test_manager/Makefile.in +++ b/examples/test_manager/Makefile.in @@ -307,6 +307,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/uclient/Makefile.in b/examples/uclient/Makefile.in index ee91367ec..439d07ed2 100644 --- a/examples/uclient/Makefile.in +++ b/examples/uclient/Makefile.in @@ -339,6 +339,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/userver/Makefile.in b/examples/userver/Makefile.in index 882e29da0..5299378f7 100644 --- a/examples/userver/Makefile.in +++ b/examples/userver/Makefile.in @@ -362,6 +362,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/userver/userver.cfg.default b/examples/userver/userver.cfg.default index a43e0a93c..955b12e94 100644 --- a/examples/userver/userver.cfg.default +++ b/examples/userver/userver.cfg.default @@ -22,6 +22,7 @@ # CLIENT_THRESHOLD min number of clients to active polling # CLIENT_FOR_PARALLELIZATION min number of clients to active parallelization (dedicated process) # +# LOAD_BALANCE_CLUSTER list of comma separated IP address (IPADDR[/MASK]) to define the load balance cluster # LOAD_BALANCE_DEVICE_NETWORK network interface name of cluster of physical server # LOAD_BALANCE_LOADAVG_THRESHOLD system load threshold to proxies the request on other userver on the network cluster ([0-9].[0-9]) # @@ -84,6 +85,7 @@ # DOS_WHITE_LIST list of comma separated IP addresses of trusted clients can be whitelisted to insure they are never denied (IPADDR[/MASK]) # DOS_EMAIL_NOTIFY the email address to send a message whenever an IP address becomes blacklisted # DOS_SYSTEM_COMMAND the system command specified will be executed whenever an IP address becomes blacklisted. Use %v to denote the IP address of the blacklisted IP +# DOS_LOGFILE the file to write DOS event # ---------------------------------------------------------------------------------------------------------------------------------------- userver { diff --git a/examples/userver/userver.cpp b/examples/userver/userver.cpp index 9e1369be7..cf0d8fdd8 100644 --- a/examples/userver/userver.cpp +++ b/examples/userver/userver.cpp @@ -84,6 +84,7 @@ class Application : public UApplication { // CLIENT_THRESHOLD min number of clients to active polling // CLIENT_FOR_PARALLELIZATION minum number of clients to active parallelization // + // LOAD_BALANCE_CLUSTER list of comma separated IP address (IPADDR[/MASK]) to define the load balance cluster // LOAD_BALANCE_DEVICE_NETWORK network interface name of cluster of physical server // LOAD_BALANCE_LOADAVG_THRESHOLD system load threshold to proxies the request on other userver on the network cluster ([0-9].[0-9]) // @@ -130,6 +131,7 @@ class Application : public UApplication { // DOS_WHITE_LIST list of comma separated IP addresses of trusted clients can be whitelisted to insure they are never denied (IPADDR[/MASK]) // DOS_EMAIL_NOTIFY the email address to send a message whenever an IP address becomes blacklisted // DOS_SYSTEM_COMMAND the system command specified will be executed whenever an IP address becomes blacklisted. Use %v to denote the IP address of the blacklisted IP + // DOS_LOGFILE the file to write DOS event // --------------------------------------------------------------------------------------------------------------------------------------- # ifdef U_SSL_SOCKET diff --git a/examples/workflow/Makefile.in b/examples/workflow/Makefile.in index 1f076c2ba..e65b2fc85 100644 --- a/examples/workflow/Makefile.in +++ b/examples/workflow/Makefile.in @@ -328,6 +328,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/examples/xml2txt/Makefile.in b/examples/xml2txt/Makefile.in index dcdb674ef..6e9a75e2b 100644 --- a/examples/xml2txt/Makefile.in +++ b/examples/xml2txt/Makefile.in @@ -308,6 +308,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/fuzz/Makefile.in b/fuzz/Makefile.in index aad6772cf..e0b07a015 100644 --- a/fuzz/Makefile.in +++ b/fuzz/Makefile.in @@ -308,6 +308,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/include/Makefile.in b/include/Makefile.in index f7e5506b4..16850f2cb 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -347,6 +347,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/include/ulib/Makefile.in b/include/ulib/Makefile.in index 718b92faa..2e27371ca 100644 --- a/include/ulib/Makefile.in +++ b/include/ulib/Makefile.in @@ -256,6 +256,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/include/ulib/base/utility.h b/include/ulib/base/utility.h index f83703c9b..95d5f0d4b 100644 --- a/include/ulib/base/utility.h +++ b/include/ulib/base/utility.h @@ -145,13 +145,37 @@ static inline uint8_t u_loadavg(const char* buffer) return (((buffer[0]-'0') * 10) + (buffer[2]-'0') + (buffer[3] > '5')); // 0.19 => 2, 4.56 => 46, ... } -static inline uint64_t u_nextPowerOfTwo64(uint64_t n) +/** + * Return the smallest power of two value greater than n + * + * Input range: [2..2147483648] + * Output range: [2..2147483648] + */ + +static inline uint64_t u_nextPowerOfTwo(uint32_t n) { - U_INTERNAL_TRACE("u_nextPowerOfTwo64(%llu)", n) + U_INTERNAL_TRACE("u_nextPowerOfTwo(%u)", n) U_INTERNAL_ASSERT_MAJOR(n, 1) + U_INTERNAL_ASSERT(n <= ((UINT32_MAX/2)+1)) + +#if (defined(__GNUC__) || defined(__clang__)) && !defined(HAVE_OLD_IOSTREAM) + return 1U << (sizeof(uint32_t) * 8 - __builtin_clz(n-1)); +#else + /* @https://web.archive.org/web/20170704200003/https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 */ + + --n; + + n |= n >> 1; + n |= n >> 2; + n |= n >> 4; + n |= n >> 8; + n |= n >> 16; - return 1ULL << (sizeof(uint64_t) * 8 - __builtin_clzll(n-1)); + U_INTERNAL_PRINT("n+1 = %u", n+1) + + return n+1; +#endif } /* Random number generator */ diff --git a/include/ulib/curl/curl.h b/include/ulib/curl/curl.h index c4ab450a0..538148d3d 100644 --- a/include/ulib/curl/curl.h +++ b/include/ulib/curl/curl.h @@ -63,7 +63,7 @@ class U_EXPORT UCURL { * @param message the payload to send (JSON) */ - static bool sendHTTP2Push(const UString& token, const UString& message); + static bool sendHTTP2Push(const UString& token, const UString& message, UVector* pextraHeaders = U_NULLPTR); UString& getResponse() { return response; } diff --git a/include/ulib/json/value.h b/include/ulib/json/value.h index b9ff67267..56796934b 100644 --- a/include/ulib/json/value.h +++ b/include/ulib/json/value.h @@ -627,8 +627,8 @@ class U_EXPORT UValue { { U_TRACE_NO_PARAM(0, "UValue::initParser()") - o = {0ULL}; - pos = -1; + pos = -1; + o.ival = 0ULL; } static void nextParser(); @@ -1039,7 +1039,13 @@ template class U_EXPORT UJsonTypeHandler : public UJsonTypeHandler_Bas U_INTERNAL_ASSERT_MINOR(UValue::pos, U_JSON_PARSE_STACK_SIZE) - UValue::sd[UValue::pos] = {0, U_NULLPTR, true}; +# ifndef HAVE_OLD_IOSTREAM + UValue::sd[UValue::pos] = {0, U_NULLPTR, true}; +# else + UValue::sd[UValue::pos].keys = 0; + UValue::sd[UValue::pos].tails = U_NULLPTR; + UValue::sd[UValue::pos].tags = true; +# endif ((T*)pval)->toJSON(); @@ -1848,7 +1854,13 @@ template class U_EXPORT UJsonTypeHandler > : public UJsonT U_INTERNAL_ASSERT_MINOR(UValue::pos, U_JSON_PARSE_STACK_SIZE) +# ifndef HAVE_OLD_IOSTREAM UValue::sd[UValue::pos] = {0, U_NULLPTR, false}; +# else + UValue::sd[UValue::pos].keys = 0; + UValue::sd[UValue::pos].tails = U_NULLPTR; + UValue::sd[UValue::pos].tags = false; +# endif do { UJsonTypeHandler(*(T*)(*ptr)).toJSON(); } while (++ptr < end); @@ -1943,7 +1955,13 @@ template <> class U_EXPORT UJsonTypeHandler > : public UJsonTyp U_INTERNAL_ASSERT_MINOR(UValue::pos, U_JSON_PARSE_STACK_SIZE) +# ifndef HAVE_OLD_IOSTREAM UValue::sd[UValue::pos] = {0, U_NULLPTR, false}; +# else + UValue::sd[UValue::pos].keys = 0; + UValue::sd[UValue::pos].tails = U_NULLPTR; + UValue::sd[UValue::pos].tags = false; +# endif do { UValue::addString(U_STRING_TO_PARAM(*(const UStringRep*)(*ptr))); } while (++ptr < end); @@ -2003,7 +2021,9 @@ template class U_EXPORT UJsonTypeHandler > : public UJson { json.push_back('{'); +# ifndef HAVE_OLD_IOSTREAM do { json.toJSON(pmap->getKey(), UJsonTypeHandler(*(pmap->elem()))); } while (pmap->next()); +# endif json.setLastChar('}'); } @@ -2024,7 +2044,13 @@ template class U_EXPORT UJsonTypeHandler > : public UJson U_INTERNAL_ASSERT_MINOR(UValue::pos, U_JSON_PARSE_STACK_SIZE) +# ifndef HAVE_OLD_IOSTREAM UValue::sd[UValue::pos] = {0, U_NULLPTR, true}; +# else + UValue::sd[UValue::pos].keys = 0; + UValue::sd[UValue::pos].tails = U_NULLPTR; + UValue::sd[UValue::pos].tags = true; +# endif do { UValue::toJSON(pmap->getKey(), *(pmap->elem())); } while (pmap->next()); @@ -2114,7 +2140,13 @@ template <> class U_EXPORT UJsonTypeHandler > : public UJsonTy U_INTERNAL_ASSERT_MINOR(UValue::pos, U_JSON_PARSE_STACK_SIZE) +# ifndef HAVE_OLD_IOSTREAM UValue::sd[UValue::pos] = {0, U_NULLPTR, true}; +# else + UValue::sd[UValue::pos].keys = 0; + UValue::sd[UValue::pos].tails = U_NULLPTR; + UValue::sd[UValue::pos].tags = true; +# endif do { UValue::addString(pmap->getKey()); @@ -2216,7 +2248,13 @@ template class U_EXPORT UJsonTypeHandler > : public UJs U_INTERNAL_ASSERT_MINOR(UValue::pos, U_JSON_PARSE_STACK_SIZE) +# ifndef HAVE_OLD_IOSTREAM UValue::sd[UValue::pos] = {0, U_NULLPTR, false}; +# else + UValue::sd[UValue::pos].keys = 0; + UValue::sd[UValue::pos].tails = U_NULLPTR; + UValue::sd[UValue::pos].tags = false; +# endif for (uint32_t i = 0; i < n; ++i) UJsonTypeHandler(pvec->at(i)).toJSON(); diff --git a/include/ulib/net/ipaddress.h b/include/ulib/net/ipaddress.h index 2730a8319..9746772c9 100644 --- a/include/ulib/net/ipaddress.h +++ b/include/ulib/net/ipaddress.h @@ -14,7 +14,7 @@ #ifndef ULIB_IPADDRES_H #define ULIB_IPADDRES_H 1 -#include +#include #ifdef _MSWINDOWS_ # include @@ -50,14 +50,13 @@ class UHTTP; class USocket; class USocketExt; class USSLSocket; +class UIPAddress; class UNoCatPlugIn; class UClient_Base; class UServer_Base; class URDBClientImage; class UClientImage_Base; -template class UVector; - // Simple IP-based access-control system // Interpret a "HOST/BITS" IP mask specification. (Ex. 192.168.1.64/28) @@ -71,7 +70,7 @@ class U_EXPORT UIPAllow { U_MEMORY_ALLOCATOR U_MEMORY_DEALLOCATOR - UString spec, device, host; + UString device, host; UIPAllow() { @@ -105,15 +104,36 @@ class U_EXPORT UIPAllow { // Interpret a "HOST/BITS" IP mask specification. (Ex. 192.168.1.64/28) bool parseMask(const UString& spec); - static uint32_t parseMask(const UString& vspec, UVector& vipallow); + static uint32_t parseMask(const UString& vspec, UVector& vipallow, UVector* pvspec = U_NULLPTR); // Check whether a ip address client ought to be allowed (belong to the same network)... - bool isAllowed(const char* ip_client); - bool isAllowed(const UString& ip_client); + bool isAllowed(const char* ip_client) + { + U_TRACE(0, "UIPAllow::isAllowed(%S)", ip_client) + + U_INTERNAL_ASSERT(u_isIPv4Addr(ip_client, u__strlen(ip_client, __PRETTY_FUNCTION__))) + + struct in_addr ia; + + if (inet_aton(ip_client, &ia) && isAllowed(ia.s_addr)) U_RETURN(true); + + U_RETURN(false); + } + + bool isAllowed(const UString& ip_client) { return isAllowed(ip_client.c_str()); } bool isAllowed(in_addr_t client) __pure; - bool isAllowed(in_addr_t ifa_addr, in_addr_t ifa_netmask) __pure; + bool isAllowed(in_addr_t ifa_addr, in_addr_t ifa_netmask) + { + U_TRACE(0, "UIPAllow::isAllowed(%u,%u)", ifa_addr, ifa_netmask) + + U_INTERNAL_ASSERT_EQUALS(network, addr & mask) + + if ((ifa_addr & ifa_netmask) == network) U_RETURN(true); + + U_RETURN(false); + } // SERVICES @@ -121,8 +141,8 @@ class U_EXPORT UIPAllow { { U_TRACE_NO_PARAM(0, "UIPAllow::isEmpty()") - if (device.empty() || - host.empty()) + if ( host.empty() || + device.empty()) { U_RETURN(true); } @@ -132,9 +152,41 @@ class U_EXPORT UIPAllow { static bool getNetworkInterface(UVector& vipallow); - static uint32_t find(in_addr_t client, UVector& vipallow) __pure; - static uint32_t find(const char* ip_client, UVector& vipallow) __pure; - static uint32_t find(const UString& ip_client, UVector& vipallow) __pure; + static uint32_t find(in_addr_t client, UVector& vipallow) + { + U_TRACE(0, "UIPAllow::find(%u,%p)", client, &vipallow) + + for (uint32_t i = 0, vlen = vipallow.size(); i < vlen; ++i) + { + if (vipallow[i]->isAllowed(client)) U_RETURN(i); + } + + U_RETURN(U_NOT_FOUND); + } + + static uint32_t find(const char* ip_client, UVector& vipallow) + { + U_TRACE(0, "UIPAllow::find(%S,%p)", ip_client, &vipallow) + + for (uint32_t i = 0, vlen = vipallow.size(); i < vlen; ++i) + { + if (vipallow[i]->isAllowed(ip_client)) U_RETURN(i); + } + + U_RETURN(U_NOT_FOUND); + } + + static uint32_t find(const UString& ip_client, UVector& vipallow) + { + U_TRACE(0, "UIPAllow::find(%V,%p)", ip_client.rep, &vipallow) + + for (uint32_t i = 0, vlen = vipallow.size(); i < vlen; ++i) + { + if (vipallow[i]->isAllowed(ip_client)) U_RETURN(i); + } + + U_RETURN(U_NOT_FOUND); + } static bool isAllowed(in_addr_t client, UVector& vipallow) { return (find( client, vipallow) != U_NOT_FOUND); } static bool isAllowed(const char* ip_client, UVector& vipallow) { return (find(ip_client, vipallow) != U_NOT_FOUND); } @@ -353,7 +405,16 @@ class U_EXPORT UIPAddress { char pcStrAddress[U_INET_ADDRSTRLEN]; void resolveHostName(); - void resolveStrAddress(); + void resolveStrAddress() + { + U_TRACE_NO_PARAM(0, "UIPAddress::resolveStrAddress()") + + U_CHECK_MEMORY + + U_INTERNAL_ASSERT(U_ipaddress_StrAddressUnresolved(this)) + + if (resolveStrAddress(iAddressType, pcAddress.p, pcStrAddress)) U_ipaddress_StrAddressUnresolved(this) = false; + } static char* resolveStrAddress(int iAddressType, const void* addr, char* ip); diff --git a/include/ulib/net/server/plugin/mod_nocat.h b/include/ulib/net/server/plugin/mod_nocat.h index 468b18807..2cc84ca36 100644 --- a/include/ulib/net/server/plugin/mod_nocat.h +++ b/include/ulib/net/server/plugin/mod_nocat.h @@ -190,6 +190,7 @@ class U_EXPORT UNoCatPlugIn : public UServerPlugIn, UEventTime { static UVector* vLoginValidate; static UVector* vInternalDevice; static UVector* vLocalNetworkLabel; + static UVector* vLocalNetworkSpec; static UVector* vLocalNetworkMask; static void* pdata; diff --git a/include/ulib/net/server/server.h b/include/ulib/net/server/server.h index 463b70531..ed6e39c36 100644 --- a/include/ulib/net/server/server.h +++ b/include/ulib/net/server/server.h @@ -156,7 +156,8 @@ class U_EXPORT UServer_Base : public UEventFd { // CLIENT_THRESHOLD min number of clients to active polling // CLIENT_FOR_PARALLELIZATION min number of clients to active parallelization // - // LOAD_BALANCE_DEVICE_NETWORK network interface name of cluster of physical server + // LOAD_BALANCE_CLUSTER list of comma separated IP address (IPADDR[/MASK]) to define the load balance cluster + // LOAD_BALANCE_DEVICE_NETWORK network interface name of the cluster of physical server // LOAD_BALANCE_LOADAVG_THRESHOLD system load threshold to proxies the request on other userver on the network cluster ([0-9].[0-9]) // // PID_FILE write pid on file indicated @@ -203,6 +204,7 @@ class U_EXPORT UServer_Base : public UEventFd { // DOS_WHITE_LIST list of comma separated IP addresses of trusted clients can be whitelisted to insure they are never denied (IPADDR[/MASK]) // DOS_EMAIL_NOTIFY the email address to send a message whenever an IP address becomes blacklisted // DOS_SYSTEM_COMMAND the system command specified will be executed whenever an IP address becomes blacklisted. Use %v to denote the IP address of the blacklisted IP + // DOS_LOGFILE the file to write DOS event // -------------------------------------------------------------------------------------------------------------------------------------- static void run(); // loop waiting for connection @@ -409,6 +411,7 @@ class U_EXPORT UServer_Base : public UEventFd { #ifdef USE_LOAD_BALANCE static UString* ifname; static uint8_t loadavg_threshold; + static UVector* vallow_cluster; #endif static void setLockUser1() @@ -674,12 +677,10 @@ class U_EXPORT UServer_Base : public UEventFd { #endif #ifdef U_ACL_SUPPORT - static UString* allow_IP; static UVector* vallow_IP; #endif #ifdef U_RFC1918_SUPPORT - static UString* allow_IP_prv; static bool enable_rfc1918_filter; static UVector* vallow_IP_prv; #endif @@ -720,7 +721,6 @@ class U_EXPORT UServer_Base : public UEventFd { static UFile* dos_LOG; static bool bwhitelist; - static UString* whitelist_IP; static uevasive* evasive_rec; static UString* systemCommand; static UString* dosEmailAddress; diff --git a/include/ulib/utility/uhttp.h b/include/ulib/utility/uhttp.h index d95a61f9d..593b4063f 100644 --- a/include/ulib/utility/uhttp.h +++ b/include/ulib/utility/uhttp.h @@ -277,6 +277,10 @@ class U_EXPORT UHTTP { static bool manageRequestOnRemoteServer(); #endif +#if !defined(U_LOG_DISABLE) || defined(USE_LIBZ) + static void parserExecute(const char* ptr, uint32_t len); +#endif + static void setHostname(const char* ptr, uint32_t len); static void setHostname(const UString& name) { setHostname(U_STRING_TO_PARAM(name)); } diff --git a/m4/Makefile.in b/m4/Makefile.in index 5976c3f9e..97064865c 100644 --- a/m4/Makefile.in +++ b/m4/Makefile.in @@ -273,6 +273,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/src/ulib/Makefile.in b/src/ulib/Makefile.in index 2fe093024..014f0b78e 100644 --- a/src/ulib/Makefile.in +++ b/src/ulib/Makefile.in @@ -629,6 +629,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/src/ulib/curl/curl.cpp b/src/ulib/curl/curl.cpp index ac0084801..c541b47b3 100644 --- a/src/ulib/curl/curl.cpp +++ b/src/ulib/curl/curl.cpp @@ -305,29 +305,31 @@ const char* UCURL::apple_cert = "/certificates/samplepush/development.pem"; // t const char* UCURL::http2_server = "https://api.development.push.apple.com"; // the Apple server url - "https://api.push.apple.com" const char* UCURL::app_bundle_id; // the app bundle id -bool UCURL::sendHTTP2Push(const UString& token, const UString& message) +bool UCURL::sendHTTP2Push(const UString& token, const UString& message, UVector* pextraHeaders) { - U_TRACE(0, "UCURL::sendHTTP2Push(%V,%V)", token.rep, message.rep) + U_TRACE(0, "UCURL::sendHTTP2Push(%V,%V,%p)", token.rep, message.rep, pextraHeaders) + UCURL curl; char url[1024], buf[1024]; - (void) u__snprintf(url, sizeof(url), U_CONSTANT_TO_PARAM("%s/3/device/%v"), http2_server, token.rep); // url (endpoint) - (void) u__snprintf(buf, sizeof(buf), U_CONSTANT_TO_PARAM("apns-topic: %s"), app_bundle_id); - - UCURL curl; - curl.setHTTP2(); curl.setHeader(); - curl.setURL(url); curl.setPort(443); curl.setInsecure(); - curl.addHeader(buf); curl.setMaxTime(30); curl.setPostMode(message); curl.setUserAgent("ULib"); curl.setCertificate(apple_cert); + (void) u__snprintf(url, sizeof(url), U_CONSTANT_TO_PARAM("%s/3/device/%v"), http2_server, token.rep); // url (endpoint) + (void) u__snprintf(buf, sizeof(buf), U_CONSTANT_TO_PARAM("apns-topic: %s"), app_bundle_id); + + curl.setURL(url); + curl.addHeader(buf); + + if (pextraHeaders) curl.addHeader(*pextraHeaders); // Ex: [ "apns-collapse-id: cCI1QJ1mdNvbTyr1q7PvUV3I8OeB4Uygl", "apns-expiration: 0" ] + if (curl.performWait()) U_RETURN(true); U_RETURN(false); diff --git a/src/ulib/net/ipaddress.cpp b/src/ulib/net/ipaddress.cpp index d825a8ddc..135356440 100644 --- a/src/ulib/net/ipaddress.cpp +++ b/src/ulib/net/ipaddress.cpp @@ -12,7 +12,6 @@ // ============================================================================ #include -#include #ifdef HAVE_IFADDRS_H # include @@ -408,17 +407,6 @@ char* UIPAddress::resolveStrAddress(int iAddressType, const void* src, char* ip) return result; } -void UIPAddress::resolveStrAddress() -{ - U_TRACE_NO_PARAM(0, "UIPAddress::resolveStrAddress()") - - U_CHECK_MEMORY - - U_INTERNAL_ASSERT(U_ipaddress_StrAddressUnresolved(this)) - - if (resolveStrAddress(iAddressType, pcAddress.p, pcStrAddress)) U_ipaddress_StrAddressUnresolved(this) = false; -} - /****************************************************************************/ /* void resolveHostName() */ /* */ @@ -648,42 +636,41 @@ UString UIPAddress::toString(uint8_t* addr) // Simple IP-based access-control system // Interpret a "HOST/BITS" IP mask specification. (Ex. 192.168.1.64/28) -bool UIPAllow::parseMask(const UString& _spec) +bool UIPAllow::parseMask(const UString& spec) { - U_TRACE(1, "UIPAllow::parseMask(%V)", _spec.rep) + U_TRACE(1, "UIPAllow::parseMask(%V)", spec.rep) // get bit before slash struct in_addr ia; char addr_str[U_INET_ADDRSTRLEN]; - uint32_t start, addr_len = _spec.find('/'); + uint32_t start, addr_len = spec.find('/'); // extract and parse addr part - if (_spec.c_char(0) == '!') + if (spec.c_char(0) == '!') { bnot = true; start = 1; - spec = _spec.substr(1).copy(); } else { bnot = false; start = 0; - spec = _spec.copy(); } if (addr_len == U_NOT_FOUND) { mask = 0xffffffff; - _spec.copy(addr_str, addr_len, start); + spec.copy(addr_str, addr_len, start); } else { - mask = network = 0; + mask = + network = 0; - _spec.copy(addr_str, addr_len - start, start); + spec.copy(addr_str, addr_len-start, start); } U_INTERNAL_DUMP("u_isIPv4Addr(%S) = %b", addr_str, u_isIPv4Addr(addr_str, u__strlen(addr_str, __PRETTY_FUNCTION__))) @@ -709,7 +696,8 @@ bool UIPAllow::parseMask(const UString& _spec) // /24 256 255.255.255.0 0xffffff00 // /30 4 255.255.255.252 0xfffffffc // ------------------------------------ - int mask_bits = u_atoi(_spec.c_pointer(addr_len + 1)); + + int mask_bits = u_atoi(spec.c_pointer(addr_len+1)); U_INTERNAL_DUMP("mask_bits = %d", mask_bits) @@ -756,20 +744,28 @@ bool UIPAllow::parseMask(const UString& _spec) U_RETURN(true); } -uint32_t UIPAllow::parseMask(const UString& vspec, UVector& vipallow) +uint32_t UIPAllow::parseMask(const UString& vspec, UVector& vipallow, UVector* pvspec) { - U_TRACE(0, "UIPAllow::parseMask(%V,%p)", vspec.rep, &vipallow) + U_TRACE(0, "UIPAllow::parseMask(%V,%p,%p)", vspec.rep, &vipallow, pvspec) + UString spec; UIPAllow* elem; UVector vec(vspec, ", \t"); uint32_t result, n = vipallow.size(); for (uint32_t i = 0, vlen = vec.size(); i < vlen; ++i) { + spec = vec[i]; + U_NEW(UIPAllow, elem, UIPAllow); - if (elem->parseMask(vec[i])) vipallow.push_back(elem); - else delete elem; + if (elem->parseMask(spec) == false) delete elem; + else + { + vipallow.push_back(elem); + + if (pvspec) pvspec->push_back(spec.c_char(0) == '!' ? spec.substr(1).copy() : spec.copy()); + } } result = (vipallow.size() - n); @@ -781,96 +777,18 @@ __pure bool UIPAllow::isAllowed(in_addr_t client) { U_TRACE(0, "UIPAllow::isAllowed(%u)", client) - U_DUMP("addr = %V mask = %V network = %V", UIPAddress::toString(addr).rep, UIPAddress::toString(mask).rep, UIPAddress::toString(network).rep) + U_DUMP("addr = %V mask = %V network = %V", UIPAddress::toString(addr).rep, UIPAddress::toString(mask).rep, UIPAddress::toString(network).rep) + U_DUMP("client = %V mask = %V network = %V", UIPAddress::toString(client).rep, UIPAddress::toString(mask).rep, UIPAddress::toString(client & mask).rep) U_INTERNAL_ASSERT_EQUALS(network, addr & mask) bool result = ((client & mask) == network); - U_DUMP("client = %V mask = %V network = %V", UIPAddress::toString(client).rep, UIPAddress::toString(mask).rep, UIPAddress::toString(client & mask).rep) - if (bnot) U_RETURN(!result); U_RETURN(result); } -__pure bool UIPAllow::isAllowed(in_addr_t ifa_addr, in_addr_t ifa_netmask) -{ - U_TRACE(0, "UIPAllow::isAllowed(%u,%u)", ifa_addr, ifa_netmask) - - U_DUMP("addr = %V mask = %V network = %V", UIPAddress::toString(addr).rep, UIPAddress::toString(mask).rep, UIPAddress::toString(network).rep) - - U_INTERNAL_ASSERT_EQUALS(network, addr & mask) - - bool result = ((ifa_addr & ifa_netmask) == network); - - U_DUMP("ifa_addr = %V ifa_netmask = %V network = %V", UIPAddress::toString(ifa_addr).rep, UIPAddress::toString(ifa_netmask).rep, UIPAddress::toString(ifa_addr & ifa_netmask).rep) - - U_RETURN(result); -} - -bool UIPAllow::isAllowed(const char* ip_client) -{ - U_TRACE(0, "UIPAllow::isAllowed(%S)", ip_client) - - U_INTERNAL_ASSERT(u_isIPv4Addr(ip_client, u__strlen(ip_client, __PRETTY_FUNCTION__))) - - struct in_addr ia; - - bool result = (inet_aton(ip_client, &ia) && isAllowed(ia.s_addr)); - - U_RETURN(result); -} - -bool UIPAllow::isAllowed(const UString& ip_client) -{ - U_TRACE(0, "UIPAllow::isAllowed(%V)", ip_client.rep) - - U_INTERNAL_ASSERT(u_isIPv4Addr(U_STRING_TO_PARAM(ip_client))) - - struct in_addr ia; - - bool result = (inet_aton(ip_client.c_str(), &ia) && isAllowed(ia.s_addr)); - - U_RETURN(result); -} - -__pure uint32_t UIPAllow::find(in_addr_t client, UVector& vipallow) -{ - U_TRACE(0, "UIPAllow::find(%u,%p)", client, &vipallow) - - for (uint32_t i = 0, vlen = vipallow.size(); i < vlen; ++i) - { - if (vipallow[i]->isAllowed(client)) U_RETURN(i); - } - - U_RETURN(U_NOT_FOUND); -} - -__pure uint32_t UIPAllow::find(const char* ip_client, UVector& vipallow) -{ - U_TRACE(0, "UIPAllow::find(%S,%p)", ip_client, &vipallow) - - for (uint32_t i = 0, vlen = vipallow.size(); i < vlen; ++i) - { - if (vipallow[i]->isAllowed(ip_client)) U_RETURN(i); - } - - U_RETURN(U_NOT_FOUND); -} - -__pure uint32_t UIPAllow::find(const UString& ip_client, UVector& vipallow) -{ - U_TRACE(0, "UIPAllow::find(%V,%p)", ip_client.rep, &vipallow) - - for (uint32_t i = 0, vlen = vipallow.size(); i < vlen; ++i) - { - if (vipallow[i]->isAllowed(ip_client)) U_RETURN(i); - } - - U_RETURN(U_NOT_FOUND); -} - bool UIPAddress::setBroadcastAddress(uusockaddr& addr, const UString& ifname) { U_TRACE(0, "UIPAddress::setBroadcastAddress(%p,%V)", &addr, ifname.rep) diff --git a/src/ulib/net/server/plugin/Makefile.in b/src/ulib/net/server/plugin/Makefile.in index 88fbf5305..13a615294 100644 --- a/src/ulib/net/server/plugin/Makefile.in +++ b/src/ulib/net/server/plugin/Makefile.in @@ -556,6 +556,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/src/ulib/net/server/plugin/mod_geoip/Makefile.in b/src/ulib/net/server/plugin/mod_geoip/Makefile.in index 41b4a5dde..e89915c46 100644 --- a/src/ulib/net/server/plugin/mod_geoip/Makefile.in +++ b/src/ulib/net/server/plugin/mod_geoip/Makefile.in @@ -334,6 +334,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/src/ulib/net/server/plugin/mod_nocat.cpp b/src/ulib/net/server/plugin/mod_nocat.cpp index d3b5aad2e..9f58f503b 100644 --- a/src/ulib/net/server/plugin/mod_nocat.cpp +++ b/src/ulib/net/server/plugin/mod_nocat.cpp @@ -87,6 +87,7 @@ UVector* UNoCatPlugIn::vroaming_data; UVector* UNoCatPlugIn::vLoginValidate; UVector* UNoCatPlugIn::vInternalDevice; UVector* UNoCatPlugIn::vLocalNetworkLabel; +UVector* UNoCatPlugIn::vLocalNetworkSpec; UVector* UNoCatPlugIn::vLocalNetworkMask; UVector** UNoCatPlugIn::vaddr; UHttpClient* UNoCatPlugIn::client; @@ -205,6 +206,7 @@ UNoCatPlugIn::UNoCatPlugIn() U_NEW(UVector, vLoginValidate, UVector); U_NEW(UVector, vInternalDevice, UVector(64U)); U_NEW(UVector, vLocalNetworkLabel, UVector(64U)); + U_NEW(UVector, vLocalNetworkSpec, UVector(64U)); U_NEW(UVector, vLocalNetworkMask, UVector); U_NEW(UHttpClient, client, UHttpClient(U_NULLPTR)); @@ -243,6 +245,7 @@ UNoCatPlugIn::~UNoCatPlugIn() delete vroaming_data; delete vLoginValidate; delete vInternalDevice; + delete vLocalNetworkSpec; delete vLocalNetworkMask; delete vLocalNetworkLabel; @@ -415,7 +418,7 @@ void UNoCatPlugIn::setStatusContent(const UString& ap_label) if (index < vLocalNetworkMask->size()) { - UString x = (*vLocalNetworkMask)[index]->spec; + UString x = (*vLocalNetworkSpec)[index]; label_buffer.snprintf(U_CONSTANT_TO_PARAM("Label (Local Network Mask)%v (%v)\n"), ap_label.rep, x.rep); } @@ -453,9 +456,9 @@ void UNoCatPlugIn::getTraffic() for (uint32_t i = 0, n = vLocalNetworkMask->size(); i < n; ++i) { - U_INTERNAL_ASSERT((*vLocalNetworkMask)[i]->spec.isNullTerminated()) + U_INTERNAL_ASSERT((*vLocalNetworkSpec)[i].isNullTerminated()) - const char* table = (*vLocalNetworkMask)[i]->spec.data(); + const char* table = (*vLocalNetworkSpec)[i].data(); if (ipt->readEntries(table, true)) { @@ -2074,7 +2077,7 @@ int UNoCatPlugIn::handlerConfig(UFileConfig& cfg) U_SRV_LOG("Autodetected LocalNetwork %S", localnet->data()); } - (void) UIPAllow::parseMask(*localnet, *vLocalNetworkMask); + (void) UIPAllow::parseMask(*localnet, *vLocalNetworkMask, vLocalNetworkSpec); (void) vLocalNetworkLabel->split(U_STRING_TO_PARAM(lnetlbl)); @@ -2233,7 +2236,7 @@ int UNoCatPlugIn::handlerInit() U_INTERNAL_DUMP("num_peers_preallocate = %u", num_peers_preallocate) - U_NEW(UHashMap, peers, UHashMap(u_nextPowerOfTwo64(num_peers_preallocate))); + U_NEW(UHashMap, peers, UHashMap(u_nextPowerOfTwo(num_peers_preallocate))); U_NEW(UString, status_content, UString(U_CAPACITY)); U_NEW(UVector, openlist, UVector); diff --git a/src/ulib/net/server/plugin/mod_shib/Makefile.in b/src/ulib/net/server/plugin/mod_shib/Makefile.in index 7b2043098..0838fd6fb 100644 --- a/src/ulib/net/server/plugin/mod_shib/Makefile.in +++ b/src/ulib/net/server/plugin/mod_shib/Makefile.in @@ -334,6 +334,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/src/ulib/net/server/plugin/page_speed/Makefile.in b/src/ulib/net/server/plugin/page_speed/Makefile.in index 433ea0806..e3cf256da 100644 --- a/src/ulib/net/server/plugin/page_speed/Makefile.in +++ b/src/ulib/net/server/plugin/page_speed/Makefile.in @@ -335,6 +335,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/src/ulib/net/server/plugin/php/Makefile.in b/src/ulib/net/server/plugin/php/Makefile.in index 04bbca1e0..bf03855ff 100644 --- a/src/ulib/net/server/plugin/php/Makefile.in +++ b/src/ulib/net/server/plugin/php/Makefile.in @@ -334,6 +334,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/src/ulib/net/server/plugin/python/Makefile.in b/src/ulib/net/server/plugin/python/Makefile.in index 00a5b2889..8248b70a3 100644 --- a/src/ulib/net/server/plugin/python/Makefile.in +++ b/src/ulib/net/server/plugin/python/Makefile.in @@ -335,6 +335,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/src/ulib/net/server/plugin/ruby/Makefile.in b/src/ulib/net/server/plugin/ruby/Makefile.in index 43475b0ef..8eadd84cc 100644 --- a/src/ulib/net/server/plugin/ruby/Makefile.in +++ b/src/ulib/net/server/plugin/ruby/Makefile.in @@ -334,6 +334,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/src/ulib/net/server/plugin/usp/Makefile.in b/src/ulib/net/server/plugin/usp/Makefile.in index de10e0d69..40b3ce64f 100644 --- a/src/ulib/net/server/plugin/usp/Makefile.in +++ b/src/ulib/net/server/plugin/usp/Makefile.in @@ -310,6 +310,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/src/ulib/net/server/plugin/v8/Makefile.in b/src/ulib/net/server/plugin/v8/Makefile.in index 191127aa1..b95e3ce53 100644 --- a/src/ulib/net/server/plugin/v8/Makefile.in +++ b/src/ulib/net/server/plugin/v8/Makefile.in @@ -334,6 +334,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/src/ulib/net/server/server.cpp b/src/ulib/net/server/server.cpp index 53df993e8..c3ea44bfe 100644 --- a/src/ulib/net/server/server.cpp +++ b/src/ulib/net/server/server.cpp @@ -159,16 +159,15 @@ UVector* UServer_Base::vlog; UString* UServer_Base::msg_welcome; #endif #ifdef USE_LOAD_BALANCE -UString* UServer_Base::ifname; -unsigned char UServer_Base::loadavg_threshold = 45; // => 4.5 +UString* UServer_Base::ifname; +unsigned char UServer_Base::loadavg_threshold = 45; // => 4.5 +UVector* UServer_Base::vallow_cluster; #endif #ifdef U_ACL_SUPPORT -UString* UServer_Base::allow_IP; UVector* UServer_Base::vallow_IP; #endif #ifdef U_RFC1918_SUPPORT bool UServer_Base::enable_rfc1918_filter; -UString* UServer_Base::allow_IP_prv; UVector* UServer_Base::vallow_IP_prv; #endif @@ -816,7 +815,6 @@ uint32_t UServer_Base::site_interval; uint32_t UServer_Base::page_interval; uint32_t UServer_Base::blocking_period; UString* UServer_Base::dosEmailAddress; -UString* UServer_Base::whitelist_IP; UString* UServer_Base::systemCommand; UVector* UServer_Base::vwhitelist_IP; UServer_Base::uevasive* UServer_Base::evasive_rec; @@ -861,7 +859,7 @@ bool UServer_Base::checkHold(in_addr_t client, const char* client_address, uint3 bool result = false; - if ((bwhitelist = (whitelist_IP && UIPAllow::isAllowed(client, *vwhitelist_IP))) == false) // Check whitelist + if ((bwhitelist = (vwhitelist_IP && UIPAllow::isAllowed(client, *vwhitelist_IP))) == false) // Check whitelist { U_gettimeofday // NB: optimization if it is enough a time resolution of one second... @@ -1147,11 +1145,12 @@ class UTimeThread : public UThread { # ifdef USE_LOAD_BALANCE if (fd_sock > 0) { - uint8_t my_loadavg = u_get_loadavg(); + U_SRV_MY_LOAD = u_get_loadavg(); + U_SRV_MIN_LOAD_REMOTE = 255; - U_INTERNAL_DUMP("U_SRV_MY_LOAD = %u", my_loadavg) + U_INTERNAL_DUMP("U_SRV_MY_LOAD = %u", U_SRV_MY_LOAD) - int iBytesTransferred = U_SYSCALL(sendto, "%d,%p,%u,%u,%p,%d", fd_sock, &my_loadavg, sizeof(char), MSG_DONTROUTE, (sockaddr*)&(addr.psaGeneric), sizeof(addr)); + int iBytesTransferred = U_SYSCALL(sendto, "%d,%p,%u,%u,%p,%d", fd_sock, &U_SRV_MY_LOAD, sizeof(char), MSG_DONTROUTE, (sockaddr*)&(addr.psaGeneric), sizeof(addr)); if (iBytesTransferred == sizeof(char)) { @@ -1169,8 +1168,8 @@ class UTimeThread : public UThread { if (iBytesTransferred == 1) { - if (saddr.psaIP4Addr.sin_addr.s_addr == laddr && - ntohs(saddr.psaIP4Addr.sin_port) == UServer_Base::port) + if ((saddr.psaIP4Addr.sin_addr.s_addr == laddr && ntohs(saddr.psaIP4Addr.sin_port) == UServer_Base::port) || + (UServer_Base::vallow_cluster && UIPAllow::isAllowed(saddr.psaIP4Addr.sin_addr.s_addr, *UServer_Base::vallow_cluster) == false)) { continue; } @@ -1184,7 +1183,6 @@ class UTimeThread : public UThread { } } - U_SRV_MY_LOAD = my_loadavg; U_SRV_MIN_LOAD_REMOTE = min_loadavg_remote; u_put_unalignedp32(&U_SRV_MIN_LOAD_REMOTE_IP, min_loadavg_remote_ip); @@ -1442,7 +1440,8 @@ UServer_Base::~UServer_Base() if (crashEmailAddress) delete crashEmailAddress; #ifdef USE_LOAD_BALANCE - if (ifname) delete ifname; + if (ifname) delete ifname; + if (vallow_cluster) delete vallow_cluster; #endif #ifdef U_THROTTLING_SUPPORT @@ -1462,12 +1461,7 @@ UServer_Base::~UServer_Base() delete db_evasive; } - if (vwhitelist_IP) - { - delete whitelist_IP; - delete vwhitelist_IP; - } - + if (vwhitelist_IP) delete vwhitelist_IP; if (dosEmailAddress) delete dosEmailAddress; #endif @@ -1476,19 +1470,11 @@ UServer_Base::~UServer_Base() #endif #ifdef U_ACL_SUPPORT - if (vallow_IP) - { - delete allow_IP; - delete vallow_IP; - } + if (vallow_IP) delete vallow_IP; #endif #ifdef U_RFC1918_SUPPORT - if (vallow_IP_prv) - { - delete allow_IP_prv; - delete vallow_IP_prv; - } + if (vallow_IP_prv) delete vallow_IP_prv; #endif #ifdef U_LINUX @@ -1690,6 +1676,7 @@ void UServer_Base::loadConfigParam() // CLIENT_THRESHOLD min number of clients to active polling // CLIENT_FOR_PARALLELIZATION min number of clients to active parallelization // + // LOAD_BALANCE_CLUSTER list of comma separated IP address (IPADDR[/MASK]) to define the load balance cluster // LOAD_BALANCE_DEVICE_NETWORK network interface name of cluster of physical server // LOAD_BALANCE_LOADAVG_THRESHOLD system load threshold to proxies the request on other userver on the network cluster ([0-9].[0-9]) // @@ -1889,12 +1876,11 @@ void UServer_Base::loadConfigParam() if (x) { - U_INTERNAL_ASSERT_EQUALS(allow_IP, U_NULLPTR) + U_INTERNAL_ASSERT_EQUALS(vallow_IP, U_NULLPTR) U_NEW(UVector, vallow_IP, UVector); - if (UIPAllow::parseMask(x, *vallow_IP)) U_NEW(UString, allow_IP, UString(x)); - else + if (UIPAllow::parseMask(x, *vallow_IP) == 0) { delete vallow_IP; vallow_IP = U_NULLPTR; @@ -1907,12 +1893,11 @@ void UServer_Base::loadConfigParam() if (x) { - U_INTERNAL_ASSERT_EQUALS(allow_IP_prv, U_NULLPTR) + U_INTERNAL_ASSERT_EQUALS(vallow_IP_prv, U_NULLPTR) U_NEW(UVector, vallow_IP_prv, UVector); - if (UIPAllow::parseMask(x, *vallow_IP_prv)) U_NEW(UString, allow_IP_prv, UString(x)); - else + if (UIPAllow::parseMask(x, *vallow_IP_prv) == 0) { delete vallow_IP_prv; vallow_IP_prv = U_NULLPTR; @@ -2033,6 +2018,21 @@ void UServer_Base::loadConfigParam() if (x) loadavg_threshold = u_loadavg(x.data()); // 0.19 => 2, 4.56 => 46, ... U_INTERNAL_DUMP("loadavg_threshold = %u", loadavg_threshold) + + x = cfg->at(U_CONSTANT_TO_PARAM("LOAD_BALANCE_CLUSTER")); + + if (x) + { + U_INTERNAL_ASSERT_EQUALS(vallow_cluster, U_NULLPTR) + + U_NEW(UVector, vallow_cluster, UVector); + + if (UIPAllow::parseMask(x, *vallow_cluster) == 0) + { + delete vallow_cluster; + vallow_cluster = U_NULLPTR; + } + } #endif #ifdef U_EVASIVE_SUPPORT @@ -2082,12 +2082,11 @@ void UServer_Base::loadConfigParam() if (x) { - U_INTERNAL_ASSERT_EQUALS(whitelist_IP, U_NULLPTR) + U_INTERNAL_ASSERT_EQUALS(vwhitelist_IP, U_NULLPTR) U_NEW(UVector, vwhitelist_IP, UVector); - if (UIPAllow::parseMask(x, *vwhitelist_IP)) U_NEW(UString, whitelist_IP, UString(x)); - else + if (UIPAllow::parseMask(x, *vwhitelist_IP) == 0) { delete vwhitelist_IP; vwhitelist_IP = U_NULLPTR; @@ -3416,8 +3415,7 @@ int UServer_Base::handlerRead() #endif #ifdef U_ACL_SUPPORT - if (vallow_IP && - UIPAllow::isAllowed(CSOCKET->remoteIPAddress().getInAddr(), *vallow_IP) == false) + if (vallow_IP && UIPAllow::isAllowed(CSOCKET->remoteIPAddress().getInAddr(), *vallow_IP) == false) { CSOCKET->abortive_close(); @@ -3449,7 +3447,7 @@ int UServer_Base::handlerRead() if (public_address && enable_rfc1918_filter && CSOCKET->remoteIPAddress().isPrivate() && - (vallow_IP_prv == U_NULLPTR || + (vallow_IP_prv == U_NULLPTR || UIPAllow::isAllowed(CSOCKET->remoteIPAddress().getInAddr(), *vallow_IP_prv) == false)) { CSOCKET->abortive_close(); @@ -4305,9 +4303,6 @@ const char* UServer_Base::dump(bool reset) const << "dh_file (UString " << (void*)dh_file << ")\n" << "ca_file (UString " << (void*)ca_file << ")\n" << "ca_path (UString " << (void*)ca_path << ")\n" -# ifdef U_ACL_SUPPORT - << "allow_IP (UString " << (void*)allow_IP << ")\n" -# endif << "key_file (UString " << (void*)key_file << ")\n" << "password (UString " << (void*)password << ")\n" << "cert_file (UString " << (void*)cert_file << ")\n" diff --git a/src/ulib/orm/driver/Makefile.in b/src/ulib/orm/driver/Makefile.in index e30b9fa2f..584973bbc 100644 --- a/src/ulib/orm/driver/Makefile.in +++ b/src/ulib/orm/driver/Makefile.in @@ -369,6 +369,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/src/ulib/utility/uhttp.cpp b/src/ulib/utility/uhttp.cpp index 57fa452fe..83214d957 100644 --- a/src/ulib/utility/uhttp.cpp +++ b/src/ulib/utility/uhttp.cpp @@ -1177,7 +1177,7 @@ void UHTTP::init() sz = n + (15 * (n / 100)) + 32; - if (sz > cache_file->capacity()) cache_file->reserve(u_nextPowerOfTwo64(sz)); + if (sz > cache_file->capacity()) cache_file->reserve(u_nextPowerOfTwo(sz)); U_INTERNAL_ASSERT_POINTER(pathname) @@ -1199,7 +1199,6 @@ void UHTTP::init() } } -#if !defined(U_SERVER_CAPTIVE_PORTAL) && defined(U_STDCPP_ENABLE) if (cache_file_store && content_cache.empty()) { @@ -1211,47 +1210,13 @@ void UHTTP::init() if (UFile::writeTo(*cache_file_store, buffer, sz)) U_SRV_LOG("Saved (%u bytes) cache file store: %V", sz, cache_file_store->rep); } -#endif U_ASSERT(cache_file_check_memory()) - // manage gzip bomb... - - file_gzip_bomb = cache_file->at(U_CONSTANT_TO_PARAM("../__BomB__.gz")); - - if (file_gzip_bomb) - { - U_INTERNAL_ASSERT_POINTER(file_gzip_bomb->array) - - U_SRV_LOG("File gzip bomb: ../__BomB__.gz loaded"); - } - - // manage authorization data... - - file_data = cache_file->at(U_CONSTANT_TO_PARAM("../.htpasswd")); - - if (file_data) - { - U_INTERNAL_ASSERT_POINTER(file_data->array) - - U_NEW(UString, htpasswd, UString(file_data->array->operator[](0))); - - U_SRV_LOG("File data users permission: ../.htpasswd loaded"); - } - - file_data = cache_file->at(U_CONSTANT_TO_PARAM("../.htdigest")); - - if (file_data) - { - U_INTERNAL_ASSERT_POINTER(file_data->array) - - U_NEW(UString, htdigest, UString(file_data->array->operator[](0))); - - U_SRV_LOG("File data users permission: ../.htdigest loaded"); - } - UServices::generateKey(UServices::key, U_NULLPTR); // for ULib facility request TODO session cookies... + U_INTERNAL_DUMP("htdigest = %p htpasswd = %p", htdigest, htpasswd) + if (htdigest || htpasswd) { @@ -2009,7 +1974,6 @@ U_NO_EXPORT bool UHTTP::readHeaderRequest() ptr += U_http_info.startHeader; - U_ASSERT_EQUALS(UServer_Base::bssl, UServer_Base::csocket->isSSLActive()) U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp16(ptr), U_MULTICHAR_CONSTANT16('\r','\n')) if (u_get_unalignedp32(ptr) == U_MULTICHAR_CONSTANT32('\r','\n','\r','\n')) U_RETURN(true); @@ -3209,6 +3173,36 @@ next: U_INTERNAL_DUMP("char (after cr/newline) = %C U_http_version = %C U_Client } } +#if !defined(U_LOG_DISABLE) || defined(USE_LIBZ) +void UHTTP::parserExecute(const char* ptr, uint32_t len) +{ + U_TRACE(0, "UHTTP::parserExecute(%.*S,%u)", len, ptr, len) + + UClientImage_Base::request->assign(ptr, len); + + U_HTTP_INFO_RESET(0); + + if (readHeaderRequest()) + { + U_INTERNAL_ASSERT_DIFFERS(U_http_method_type, 0) + + if (U_http_info.endHeader) + { + checkRequestForHeader(); + + U_INTERNAL_DUMP("U_http_version = %C U_http_method_type = %u", U_http_version, U_http_method_type) + } + + U_INTERNAL_DUMP("U_HTTP_HOST(%u) = %.*S", U_http_host_len, U_HTTP_HOST_TO_TRACE) + + UClientImage_Base::size_request = (U_http_info.endHeader ? U_http_info.endHeader + : U_http_info.startHeader + U_CONSTANT_SIZE(U_CRLF2)); + + U_INTERNAL_DUMP("UClientImage_Base::size_request = %u U_http_info.clength = %u", UClientImage_Base::size_request, U_http_info.clength) + } +} +#endif + // manage dynamic page request (CGI - C/ULib Servlet Page - RUBY - PHP - PYTHON) bool UHTTP::checkIfSourceHasChangedAndCompileUSP() @@ -3971,6 +3965,7 @@ int UHTTP::handlerREAD() U_INTERNAL_DUMP("UClientImage_Base::size_request = %u UClientImage_Base::bsendGzipBomp = %b", UClientImage_Base::size_request, UClientImage_Base::bsendGzipBomp) +#if !defined(U_LOG_DISABLE) || defined(USE_LIBZ) if (UClientImage_Base::bsendGzipBomp) { UClientImage_Base::bsendGzipBomp = false; @@ -3998,6 +3993,7 @@ int UHTTP::handlerREAD() U_RETURN(U_PLUGIN_HANDLER_FINISHED); } +#endif U_ClientImage_state = manageRequest(); @@ -4171,7 +4167,6 @@ set_uri: U_http_info.uri = alias->data(); if (UClientImage_Base::isRequestNotFound()) { -# ifndef U_SERVER_CAPTIVE_PORTAL U_INTERNAL_DUMP("U_http_is_nocache_file = %b", U_http_is_nocache_file) if (U_http_is_nocache_file) goto manage; @@ -4222,12 +4217,11 @@ set_uri: U_http_info.uri = alias->data(); if (checkPathName(file->path_relativ_len)) goto manage; } -# endif } // NB: apply rewrite rule if requested and if status is 'file forbidden or not exist'... -#if !defined(U_SERVER_CAPTIVE_PORTAL) && defined(U_ALIAS) && defined(USE_LIBPCRE) +#if defined(U_ALIAS) && defined(USE_LIBPCRE) if (vRewriteRule && U_ClientImage_request <= UClientImage_Base::FORBIDDEN) { @@ -4245,9 +4239,7 @@ set_uri: U_http_info.uri = alias->data(); // 5) the file is not present in FILE CACHE or in DOCUMENT_ROOT and it is already processed // ---------------------------------------------------------------------------------------- -#ifndef U_SERVER_CAPTIVE_PORTAL manage: -#endif U_INTERNAL_DUMP("file_data = %p U_ClientImage_request = %B U_http_info.flag = %.8S", file_data, U_ClientImage_request, U_http_info.flag) #if defined(DEBUG) && !defined(U_STATIC_ONLY) @@ -6301,14 +6293,12 @@ void UHTTP::setStatusDescription() UClientImage_Base::iov_vec[0].iov_len = U_CONSTANT_SIZE("HTTP/1.1 505 HTTP Version Not Supported\r\n"); } break; -# ifdef U_SERVER_CAPTIVE_PORTAL case HTTP_NETWORK_AUTHENTICATION_REQUIRED: { UClientImage_Base::iov_vec[0].iov_base = (caddr_t) "HTTP/1.1 511 Network authentication required\r\n"; UClientImage_Base::iov_vec[0].iov_len = U_CONSTANT_SIZE("HTTP/1.1 511 Network authentication required\r\n"); } break; -# endif default: { @@ -7000,9 +6990,11 @@ U_NO_EXPORT bool UHTTP::processAuthorization() pos = (ptr + sz) - psuffix; } - buffer.snprintf(U_CONSTANT_TO_PARAM("..%.*s.ht%s"), sz-pos, ptr, digest_authentication ? "digest" : "passwd"); + buffer.snprintf(U_CONSTANT_TO_PARAM("..%.*s.ht%6s"), sz-pos, ptr, digest_authentication ? "digest" : "passwd"); ptr_file_data = cache_file->at(U_STRING_TO_PARAM(buffer)); + + U_INTERNAL_DUMP("ptr_file_data = %p htpasswd = %p", ptr_file_data, htpasswd) if (ptr_file_data) fpasswd = ptr_file_data->array->operator[](0); else @@ -8144,6 +8136,8 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name) uint32_t suffix_len; const char* suffix_ptr; + uint32_t file_len = file->getPathRelativLen(); + const char* file_ptr = file->getPathRelativ(); uint32_t file_name_len = file_name.size(); const char* file_name_ptr = file_name.data(); @@ -8152,11 +8146,11 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name) U_INTERNAL_ASSERT_POINTER(pathname) U_INTERNAL_ASSERT_POINTER(cache_file) - U_INTERNAL_DUMP("pathname = %V file = %.*S rpathname = %V", pathname->rep, U_FILE_TO_TRACE(*file), rpathname->rep) + U_INTERNAL_DUMP("pathname = %V file = %.*S rpathname = %V", pathname->rep, file_len, file_ptr, rpathname->rep) - if (pathname->equal(U_FILE_TO_PARAM(*file)) == false) // NB: can happen with inotify... + if (pathname->equal(file_ptr, file_len) == false) // NB: can happen with inotify... { - U_DEBUG("UHTTP::manageDataForCache(%V) pathname(%u) = %.*S file(%u) = %.*S", file_name.rep, pathname->size(), pathname->rep, file->getPathRelativLen(), U_FILE_TO_TRACE(*file)) + U_DEBUG("UHTTP::manageDataForCache(%V) pathname(%u) = %.*S file(%u) = %.*S", file_name.rep, pathname->size(), pathname->rep, file->getPathRelativLen(), file_len, file_ptr) } #endif @@ -8263,13 +8257,15 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name) { UString content = file->getContent(true, false, true); - if (content) putDataInCache(getHeaderMimeType(content.data(), 0, setMimeIndex(suffix_ptr), U_TIME_FOR_EXPIRE), content); + if (content.empty()) goto error; + + putDataInCache(getHeaderMimeType(content.data(), 0, setMimeIndex(suffix_ptr), U_TIME_FOR_EXPIRE), content); } goto end; } - if (u_dosmatch(U_FILE_TO_PARAM(*file), U_CONSTANT_TO_PARAM("*cgi-bin/*"), 0)) + if (u_dosmatch(file_ptr, file_len, U_CONSTANT_TO_PARAM("*cgi-bin/*"), 0)) { // NB: when a pathfile ends by "cgi-bin/*.[sh|php|pl|py|rb|*]" it is assumed to be a cgi script... @@ -8338,22 +8334,65 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name) // manage authorization data... - if (suffix_len == 8 && - (u_get_unalignedp64(suffix_ptr) == U_MULTICHAR_CONSTANT64('h','t','p','a','s','s','w','d') || - u_get_unalignedp64(suffix_ptr) == U_MULTICHAR_CONSTANT64('h','t','d','i','g','e','s','t'))) + if (suffix_len == 8) { - U_NEW(UVector, file_data->array, UVector(1U)); + if (u_get_unalignedp64(suffix_ptr) == U_MULTICHAR_CONSTANT64('h','t','p','a','s','s','w','d')) + { + UString content = file->getContent(true, false, true); + + if (u_get_unalignedp32(file_ptr) == U_MULTICHAR_CONSTANT32('.','.','/','.')) + { + U_INTERNAL_ASSERT_EQUALS(file_len, 12) + U_INTERNAL_ASSERT_EQUALS(htpasswd, U_NULLPTR) - file_data->array->push_back(file->getContent(true, false, true)); + U_NEW(UString, htpasswd, UString(content)); - U_SRV_LOG("File cached: %V - %u bytes", pathname->rep, file_data->size); + U_SRV_LOG("File data users permission: ../.htpasswd loaded - %u bytes", file_data->size); - goto end; + goto error; + } + + U_NEW(UVector, file_data->array, UVector(1U)); + + file_data->array->push_back(content); + + U_SRV_LOG("File data users permission: %V loaded - %u bytes", pathname->rep, file_data->size); + + goto end; + } + + if (u_get_unalignedp64(suffix_ptr) == U_MULTICHAR_CONSTANT64('h','t','d','i','g','e','s','t')) + { + UString content = file->getContent(true, false, true); + + if (u_get_unalignedp32(file_ptr) == U_MULTICHAR_CONSTANT32('.','.','/','.')) + { + U_INTERNAL_ASSERT_EQUALS(file_len, 12) + U_INTERNAL_ASSERT_EQUALS(htdigest, U_NULLPTR) + + U_NEW(UString, htdigest, UString(content)); + + U_SRV_LOG("File data users permission: ../.htdigest loaded - %u bytes", file_data->size); + + goto error; + } + + U_NEW(UVector, file_data->array, UVector(1U)); + + file_data->array->push_back(content); + + U_SRV_LOG("File data users permission: %V loaded - %u bytes", pathname->rep, file_data->size); + + goto end; + } + + goto chk; } // manage gzip bomb... if (suffix_len == 2 && + file_gzip_bomb == U_NULLPTR && u_get_unalignedp16( suffix_ptr) == U_MULTICHAR_CONSTANT16('g','z') && u_get_unalignedp64(file_name_ptr) == U_MULTICHAR_CONSTANT64('_','_','B','o','m','B','_','_')) { @@ -8369,9 +8408,11 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name) { UString header(U_CAPACITY); - U_NEW(UVector, file_data->array, UVector(2U)); + file_gzip_bomb = file_data; - file_data->array->push_back(content); + U_NEW(UVector, file_gzip_bomb->array, UVector(2U)); + + file_gzip_bomb->array->push_back(content); header.snprintf(U_CONSTANT_TO_PARAM("Content-Encoding: gzip\r\n" "Content-Type: application/octet-stream\r\n" @@ -8379,9 +8420,9 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name) (void) header.shrink(); - file_data->array->push_back(header); + file_gzip_bomb->array->push_back(header); - U_SRV_LOG("File cached: %V - %u bytes", pathname->rep, file_data->size); + U_SRV_LOG("File gzip bomb: ../__BomB__.gz loaded - %u bytes", file_gzip_bomb->size); } } @@ -8410,7 +8451,7 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& file_name) uint32_t sz; struct stat st; # ifndef U_LOG_DISABLE - const char* link; + uint32_t link_sz; # endif UServletPage* usp_page; @@ -8479,14 +8520,14 @@ check: if (usp_src) goto end; file_data->mime_index = U_usp; # ifdef U_LOG_DISABLE - cache_file->callForAllEntry(checkIfUSPLink); + cache_file->callForAllEntry(checkIfUSPLink); # else - link = (cache_file->callForAllEntry(checkIfUSPLink), file_data->link) ? " (link)" : ""; + if (cache_file->callForAllEntry(checkIfUSPLink), file_data->link) link_sz = U_CONSTANT_SIZE(" (link)"); # endif (void) pathname->replace(buffer+2, len-1); - U_SRV_LOG("USP found: %S%s, USP service registered (URI): %V", buffer, link, pathname->rep); + U_SRV_LOG("USP found: %.*S%.*s, USP service registered (URI): %V", sz, buffer, link_sz, " (link)", pathname->rep); if (bcallInitForAllUSP) { @@ -8523,14 +8564,14 @@ check: if (usp_src) goto end; (void) pathname->replace(buffer, len - U_CONSTANT_SIZE(".c")); - U_SRV_LOG("CSP found: %S, CSP service registered (URI): %V", buffer, pathname->rep); + U_SRV_LOG("CSP found: %.*S, CSP service registered (URI): %V", len, buffer, pathname->rep); } # endif goto end; } - ctype = u_get_mimetype(suffix_ptr, &file_data->mime_index); +chk: ctype = u_get_mimetype(suffix_ptr, &file_data->mime_index); U_INTERNAL_DUMP("u_is_cacheable(%d) = %b ctype = %S", file_data->mime_index, u_is_cacheable(file_data->mime_index), ctype) @@ -8777,12 +8818,14 @@ U_NO_EXPORT void UHTTP::checkPathName() file->setPath(*pathname); - U_INTERNAL_DUMP("file = %.*S", U_FILE_TO_TRACE(*file)) + len = file->getPathRelativLen(); + ptr = file->getPathRelativ(); + + U_INTERNAL_DUMP("file = %.*S", len, ptr) -#ifndef U_SERVER_CAPTIVE_PORTAL if (nocache_file_mask) { - UString basename = UStringExt::basename(U_FILE_TO_PARAM(*file)); + UString basename = UStringExt::basename(ptr, len); if (basename && UServices::dosMatchWithOR(basename, U_STRING_TO_PARAM(*nocache_file_mask), 0)) @@ -8792,9 +8835,8 @@ U_NO_EXPORT void UHTTP::checkPathName() U_INTERNAL_DUMP("U_http_is_nocache_file = %b U_http_is_request_nostat = %b", U_http_is_nocache_file, U_http_is_request_nostat) } } -#endif - checkFileInCacheOld(U_FILE_TO_PARAM(*file)); + checkFileInCacheOld(ptr, len); if (file_data == U_NULLPTR) { @@ -8807,10 +8849,17 @@ U_NO_EXPORT void UHTTP::checkPathName() return; } - // we don't wont to process this kind of request (usually aliased)... + // check for zombies... + + if (u_get_unalignedp64(ptr) == U_MULTICHAR_CONSTANT64('c','h','e','c','k','Z','o','m') && + u_get_unalignedp32(ptr+8) == U_MULTICHAR_CONSTANT32('b','i','e','s')) + { + UServer_Base::removeZombies(); + + goto nocontent; + } - len = file->getPathRelativLen(); - ptr = file->getPathRelativ(); + // we don't wont to process this kind of request (usually aliased)... if (len >= U_PATH_MAX || u_isFileName(ptr, len) == false || @@ -8826,17 +8875,6 @@ U_NO_EXPORT void UHTTP::checkPathName() return; } - if (U_STREQ(ptr, len, "checkZombies")) // check for zombies... - { - UServer_Base::removeZombies(); - - goto nocontent; - } - -# ifdef U_SERVER_CAPTIVE_PORTAL - return; -# endif - # ifdef USE_RUBY if (ruby_on_rails) { @@ -8930,7 +8968,7 @@ U_NO_EXPORT void UHTTP::checkPathName() } } - (void) pathname->replace(U_FILE_TO_PARAM(*file)); + (void) pathname->replace(ptr, len); U_INTERNAL_DUMP("U_http_is_nocache_file = %b", U_http_is_nocache_file) diff --git a/tests/Makefile.in b/tests/Makefile.in index 41fe82825..db947f807 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -318,6 +318,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/tests/base/Makefile.in b/tests/base/Makefile.in index e4eaa55d9..6260f6d4d 100644 --- a/tests/base/Makefile.in +++ b/tests/base/Makefile.in @@ -590,6 +590,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/tests/base/test_utility.c b/tests/base/test_utility.c index b7f743614..0e7f426d7 100644 --- a/tests/base/test_utility.c +++ b/tests/base/test_utility.c @@ -280,7 +280,7 @@ int main(int argc, char* argv[]) char buf8[9]; const char* ptr; char* sargv[128]; - uint32_t path_len; + uint32_t x, path_len; const char* path_rel; char path[PATH_MAX + 1]; @@ -303,12 +303,41 @@ int main(int argc, char* argv[]) U_INTERNAL_TRACE("main(%d,%p)", argc, argv) - U_INTERNAL_ASSERT_EQUALS( u_nextPowerOfTwo64(2), 2 ) - U_INTERNAL_ASSERT_EQUALS( u_nextPowerOfTwo64(3), 4 ) - U_INTERNAL_ASSERT_EQUALS( u_nextPowerOfTwo64(4), 4 ) - U_INTERNAL_ASSERT_EQUALS( u_nextPowerOfTwo64(5), 8 ) - U_INTERNAL_ASSERT_EQUALS( u_nextPowerOfTwo64(123), 128 ) - U_INTERNAL_ASSERT_EQUALS( u_nextPowerOfTwo64(222), 256 ) + x = u_nextPowerOfTwo(2); + + U_INTERNAL_PRINT("x = %u", x) + + U_INTERNAL_ASSERT_EQUALS( x, 2 ) + + x = u_nextPowerOfTwo(3); + + U_INTERNAL_PRINT("x = %u", x) + + U_INTERNAL_ASSERT_EQUALS( x, 4 ) + + x = u_nextPowerOfTwo(4); + + U_INTERNAL_PRINT("x = %u", x) + + U_INTERNAL_ASSERT_EQUALS( x, 4 ) + + x = u_nextPowerOfTwo(5); + + U_INTERNAL_PRINT("x = %u", x) + + U_INTERNAL_ASSERT_EQUALS( x, 8 ) + + x = u_nextPowerOfTwo(123); + + U_INTERNAL_PRINT("x = %u", x) + + U_INTERNAL_ASSERT_EQUALS( x, 128 ) + + x = u_nextPowerOfTwo(222); + + U_INTERNAL_PRINT("x = %u", x) + + U_INTERNAL_ASSERT_EQUALS( x, 256 ) (void) strcpy(path, "../../pippo"); @@ -501,19 +530,19 @@ int main(int argc, char* argv[]) qsort(vec, 13, sizeof(const char*), compare_str); -// U_INTERNAL_ASSERT( strcmp(vec[0], "libpng-1.0.3.tar.gz") == 0 ) -// U_INTERNAL_ASSERT( strcmp(vec[1], "libpng-1.0.5.tar.gz") == 0 ) -// U_INTERNAL_ASSERT( strcmp(vec[2], "libpng-1.0.6-patch-a.txt.gz") == 0 ) -// U_INTERNAL_ASSERT( strcmp(vec[3], "libpng-1.0.6-patch-b.txt.gz") == 0 ) -// U_INTERNAL_ASSERT( strcmp(vec[4], "libpng-1.0.6-patch-c.txt.gz") == 0 ) -// U_INTERNAL_ASSERT( strcmp(vec[5], "libpng-1.0.6.tar.gz") == 0 ) -// U_INTERNAL_ASSERT( strcmp(vec[6], "libpng-1.0.7.tar.gz") == 0 ) -// U_INTERNAL_ASSERT( strcmp(vec[7], "libpng-1.0.8.tar.gz") == 0 ) -// U_INTERNAL_ASSERT( strcmp(vec[8], "libpng-1.0.9.tar.gz") == 0 ) -// U_INTERNAL_ASSERT( strcmp(vec[9], "libpng-1.0.10.tar.gz") == 0 ) -// U_INTERNAL_ASSERT( strcmp(vec[10], "libpng-1.0.11.tar.gz") == 0 ) -// U_INTERNAL_ASSERT( strcmp(vec[11], "libpng-1.0.12.tar.gz") == 0 ) -// U_INTERNAL_ASSERT( strcmp(vec[12], "libpng-1.2.0.tar.gz") == 0 ) + // U_INTERNAL_ASSERT( strcmp(vec[0], "libpng-1.0.3.tar.gz") == 0 ) + // U_INTERNAL_ASSERT( strcmp(vec[1], "libpng-1.0.5.tar.gz") == 0 ) + // U_INTERNAL_ASSERT( strcmp(vec[2], "libpng-1.0.6-patch-a.txt.gz") == 0 ) + // U_INTERNAL_ASSERT( strcmp(vec[3], "libpng-1.0.6-patch-b.txt.gz") == 0 ) + // U_INTERNAL_ASSERT( strcmp(vec[4], "libpng-1.0.6-patch-c.txt.gz") == 0 ) + // U_INTERNAL_ASSERT( strcmp(vec[5], "libpng-1.0.6.tar.gz") == 0 ) + // U_INTERNAL_ASSERT( strcmp(vec[6], "libpng-1.0.7.tar.gz") == 0 ) + // U_INTERNAL_ASSERT( strcmp(vec[7], "libpng-1.0.8.tar.gz") == 0 ) + // U_INTERNAL_ASSERT( strcmp(vec[8], "libpng-1.0.9.tar.gz") == 0 ) + // U_INTERNAL_ASSERT( strcmp(vec[9], "libpng-1.0.10.tar.gz") == 0 ) + // U_INTERNAL_ASSERT( strcmp(vec[10], "libpng-1.0.11.tar.gz") == 0 ) + // U_INTERNAL_ASSERT( strcmp(vec[11], "libpng-1.0.12.tar.gz") == 0 ) + // U_INTERNAL_ASSERT( strcmp(vec[12], "libpng-1.2.0.tar.gz") == 0 ) for (i = 0; i < 13; ++i) puts(vec[i]); @@ -551,4 +580,4 @@ int main(int argc, char* argv[]) U_VAR_UNUSED(buffer) return 0; -} + } diff --git a/tests/contrib/Makefile.in b/tests/contrib/Makefile.in index ed2450e67..f942f5a70 100644 --- a/tests/contrib/Makefile.in +++ b/tests/contrib/Makefile.in @@ -460,6 +460,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/tests/debug/Makefile.in b/tests/debug/Makefile.in index ccd91fc64..069f67907 100644 --- a/tests/debug/Makefile.in +++ b/tests/debug/Makefile.in @@ -530,6 +530,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/tests/examples/Makefile.am b/tests/examples/Makefile.am index 47d105d78..b6bd84b69 100644 --- a/tests/examples/Makefile.am +++ b/tests/examples/Makefile.am @@ -9,6 +9,9 @@ EXTRA_DIST = inp ok CA CSP LCSP TSA RSIGN XAdES nocat wi-auth WAGSM RA IR/WEB IR ## DEFS = -DU_TEST @DEFS@ +PRG = bench_http_parser +bench_http_parser_SOURCES = bench_http_parser.cpp + TESTS = client_server.test test_manager.test IR.test web_server.test web_server_multiclient.test web_socket.test ## workflow.test if SSL diff --git a/tests/examples/Makefile.in b/tests/examples/Makefile.in index bbcb95a39..cecd6cace 100644 --- a/tests/examples/Makefile.in +++ b/tests/examples/Makefile.in @@ -96,7 +96,7 @@ target_triplet = @target@ @LIBZ_TRUE@@SSL_TRUE@am__append_6 = PEC_report_rejected.test PEC_report_messaggi.test PEC_report_virus.test PEC_report_anomalie.test PEC_check_namefile.test @LIBZ_TRUE@@SSL_TRUE@@ZIP_TRUE@am__append_7 = doc_parse.test doc_classifier.test @EXPAT_TRUE@am__append_8 = xml2txt.test -check_PROGRAMS = +check_PROGRAMS = $(am__EXEEXT_1) subdir = tests/examples ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_check_package.m4 \ @@ -123,6 +123,16 @@ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/ulib/internal/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = +am__EXEEXT_1 = bench_http_parser$(EXEEXT) +am_bench_http_parser_OBJECTS = bench_http_parser.$(OBJEXT) +bench_http_parser_OBJECTS = $(am_bench_http_parser_OBJECTS) +bench_http_parser_LDADD = $(LDADD) +bench_http_parser_DEPENDENCIES = \ + $(top_builddir)/src/ulib/lib@ULIB@.la +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -135,14 +145,53 @@ AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = -SOURCES = -DIST_SOURCES = +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +SOURCES = $(bench_http_parser_SOURCES) +DIST_SOURCES = $(bench_http_parser_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no @@ -347,7 +396,8 @@ TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) -am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/test-driver +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ + $(top_srcdir)/test-driver DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ @@ -467,6 +517,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ @@ -545,6 +596,8 @@ DEFAULT_INCLUDES = -I. -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_srcdir)/e EXTRA_DIST = inp ok CA CSP LCSP TSA RSIGN XAdES nocat wi-auth WAGSM RA IR/WEB IR/benchmark IR/doc_dir *.cfg .htpasswd .htdigest python \ *.properties *.test *.sh error_msg workflow doc_parse robots.txt alias.txt throttling.txt css js benchmark websocket docroot php.sh +PRG = bench_http_parser +bench_http_parser_SOURCES = bench_http_parser.cpp TESTS = client_server.test test_manager.test IR.test web_server.test \ web_server_multiclient.test web_socket.test $(am__append_1) \ $(am__append_2) $(am__append_3) $(am__append_4) \ @@ -554,7 +607,7 @@ LDADD = @ULIBS@ $(HTTP_LIB) $(top_builddir)/src/ulib/lib@ULIB@.la @ULIB_LIBS@ all: all-am .SUFFIXES: -.SUFFIXES: .log .test .test$(EXEEXT) .trs +.SUFFIXES: .cpp .lo .log .o .obj .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -594,17 +647,99 @@ clean-checkPROGRAMS: echo " rm -f" $$list; \ rm -f $$list +bench_http_parser$(EXEEXT): $(bench_http_parser_OBJECTS) $(bench_http_parser_DEPENDENCIES) $(EXTRA_bench_http_parser_DEPENDENCIES) + @rm -f bench_http_parser$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(bench_http_parser_OBJECTS) $(bench_http_parser_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bench_http_parser.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< + mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs -tags TAGS: -ctags CTAGS: +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique -cscope cscopelist: +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags # Recover from deleted '.trs' file; this should ensure that # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create @@ -845,8 +980,10 @@ clean-am: clean-checkPROGRAMS clean-generic clean-libtool clean-local \ mostlyclean-am distclean: distclean-am + -rm -rf ./$(DEPDIR) -rm -f Makefile -distclean-am: clean-am distclean-generic +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags dvi: dvi-am @@ -889,12 +1026,14 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am -mostlyclean-am: mostlyclean-generic mostlyclean-libtool +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf: pdf-am @@ -908,18 +1047,19 @@ uninstall-am: .MAKE: check-am install-am install-strip -.PHONY: all all-am check check-TESTS check-am clean \ +.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ clean-checkPROGRAMS clean-generic clean-libtool clean-local \ - cscopelist-am ctags-am distclean distclean-generic \ - distclean-libtool distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ + cscopelist-am ctags ctags-am distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - recheck tags-am uninstall uninstall-am + recheck tags tags-am uninstall uninstall-am .PRECIOUS: Makefile diff --git a/tests/examples/bench_http_parser.cpp b/tests/examples/bench_http_parser.cpp new file mode 100644 index 000000000..636d46827 --- /dev/null +++ b/tests/examples/bench_http_parser.cpp @@ -0,0 +1,87 @@ +// bench_http_parser.cpp + +/** + * Took 3.990086 seconds to run + * 1253105.750000 req/sec + * + * https://api.travis-ci.org/nodejs/http-parser.svg?branch=master + * + * Took 5.386795 seconds to run + * 928195.687500 req/sec + */ + +#include + +static const char data[] = + "POST /joyent/http-parser HTTP/1.1\r\n" + "Host: github.com\r\n" + "DNT: 1\r\n" + "Accept-Encoding: gzip, deflate, sdch\r\n" + "Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4\r\n" + "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) " + "AppleWebKit/537.36 (KHTML, like Gecko) " + "Chrome/39.0.2171.65 Safari/537.36\r\n" + "Accept: text/html,application/xhtml+xml,application/xml;q=0.9," + "image/webp,*/*;q=0.8\r\n" + "Referer: https://github.com/joyent/http-parser\r\n" + "Connection: keep-alive\r\n" + "Transfer-Encoding: chunked\r\n" + "Cache-Control: max-age=0\r\n\r\nb\r\nhello world\r\n0\r\n\r\n"; + +static int bench(int iter_count, int silent) +{ + U_TRACE(5, "bench(%d,%d)", iter_count, silent) + + int i; + float rps; + struct timeval start, end; + + u_init_ulib_hostname(); + + UClientImage_Base::init(); + + UString::str_allocate(STR_ALLOCATE_HTTP); + + if (!silent) (void) gettimeofday(&start, U_NULLPTR); + + for (i = 0; i < iter_count; i++) + { + UHTTP::parserExecute(data, sizeof(data)-1); + } + + if (!silent) + { + (void) gettimeofday(&end, U_NULLPTR); + + fprintf(stdout, "Benchmark result:\n"); + + rps = (float) (end.tv_sec - start.tv_sec) + (end.tv_usec - start.tv_usec) * 1e-6f; + + fprintf(stdout, "Took %f seconds to run\n", rps); + + rps = (float) iter_count / rps; + + fprintf(stdout, "%f req/sec\n", rps); + + fflush(stdout); + } + + return 0; +} + +int main(int argc, char** argv) +{ + U_ULIB_INIT(argv); + + U_TRACE(5,"main(%d)",argc) + + if (argc == 2 && + strcmp(argv[1], "infinite") == 0) + { + for (;;) bench(5000000, 1); + + return 0; + } + + return bench(5000000, 0); +} diff --git a/tests/examples/web_server.sh b/tests/examples/web_server.sh index 7a737d53c..3a97d639d 100755 --- a/tests/examples/web_server.sh +++ b/tests/examples/web_server.sh @@ -63,6 +63,7 @@ userver { #LOG_FILE_SZ 20k LOG_MSG_SIZE -1 PID_FILE /var/run/userver_tcp.pid +#LOAD_BALANCE_CLUSTER 10.30.0.1,10.30.0.2 #LOAD_BALANCE_DEVICE_NETWORK enp0s20u1 #LOAD_BALANCE_LOADAVG_THRESHOLD 4.0 #PREFORK_CHILD 0 diff --git a/tests/ulib/Makefile.in b/tests/ulib/Makefile.in index 6845a4d35..4493e88c4 100644 --- a/tests/ulib/Makefile.in +++ b/tests/ulib/Makefile.in @@ -1020,6 +1020,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/tests/ulib/http2/Makefile.in b/tests/ulib/http2/Makefile.in index bf72a502a..746d5c11b 100644 --- a/tests/ulib/http2/Makefile.in +++ b/tests/ulib/http2/Makefile.in @@ -514,6 +514,7 @@ ULIB = @ULIB@ ULIBS = @ULIBS@ ULIB_LIBS = @ULIB_LIBS@ ULIB_MODULEDIR = @ULIB_MODULEDIR@ +ULIB_PREFIXDIR = @ULIB_PREFIXDIR@ ULIB_SYSCONFDIR = @ULIB_SYSCONFDIR@ ULIB_VERSION = @ULIB_VERSION@ USP_FLAGS = @USP_FLAGS@ diff --git a/userver.service.in b/userver.service.in new file mode 100644 index 000000000..a42f2eab4 --- /dev/null +++ b/userver.service.in @@ -0,0 +1,38 @@ +[Unit] +Description=ULib server +Documentation=http://stefanocasazza.github.io/ULib/ +After=network-online.target +Wants=network-online.target systemd-networkd-wait-online.service + +[Service] +Restart=on-failure +StartLimitInterval=86400 +StartLimitBurst=5 + +; User and group the process will run as. +User=www-data +Group=www-data + +ExecStart=@ULIB_PREFIXDIR@/bin/userver_tcp -c @ULIB_SYSCONFDIR@/userver.cfg + +; Limit the number of file descriptors; see `man systemd.exec` for more limit settings. +LimitNOFILE=1048576 + +; Use private /tmp and /var/tmp, which are discarded after userver stops. +PrivateTmp=true +; Use a minimal /dev +PrivateDevices=true +; Hide /home, /root, and /run/user. Nobody will steal your SSH-keys. +ProtectHome=true +; Make /usr, /boot, /etc and possibly some more folders read-only. +ProtectSystem=full + +; The following additional security directives only work with systemd v229 or later. +; They further retrict privileges that can be gained by userver. Uncomment if you like. +; Note that you may have to add capabilities required by any plugins in use. +;CapabilityBoundingSet=CAP_NET_BIND_SERVICE +;AmbientCapabilities=CAP_NET_BIND_SERVICE +;NoNewPrivileges=true + +[Install] +WantedBy=multi-user.target