Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

sync

  • Loading branch information...
commit 8ae102fc4617e5a8e3caebb7fcd2cae565722912 1 parent ecdcd84
@stefanocasazza authored
Showing with 2,219 additions and 4,606 deletions.
  1. +1 −2  Makefile.am
  2. +1 −2  Makefile.in
  3. +20 −0 configure
  4. +17 −7 examples/WiAuth/wi_auth.cpp
  5. +17 −7 examples/WiAuth/wi_auth.usp
  6. +2 −3 examples/userver/userver.cfg.default
  7. +12 −3 include/ulib/container/vector.h
  8. +1 −0  include/ulib/event/event_time.h
  9. +3 −0  include/ulib/internal/config.h.in
  10. +1 −8 include/ulib/net/server/plugin/mod_http.h
  11. +51 −48 include/ulib/net/server/server.h
  12. +4 −4 include/ulib/net/server/server_rdb.h
  13. +7 −6 include/ulib/notifier.h
  14. +1 −1  include/ulib/ssl/net/ssl_session.h
  15. +3 −8 include/ulib/timer.h
  16. +21 −8 include/ulib/utility/uhttp.h
  17. +11 −0 m4/ac_compilation_options.m4
  18. +12 −16 openwrt/package/nodog/Makefile
  19. +5 −0 openwrt/package/userver/Config.in
  20. +76 −0 openwrt/package/userver/Makefile
  21. +25 −0 src/ulib/container/vector.cpp
  22. +24 −0 src/ulib/event/event_time.cpp
  23. +10 −5 src/ulib/file_config.cpp
  24. +6 −2 src/ulib/mime/header.cpp
  25. +1 −1  src/ulib/net/client/client.cpp
  26. +0 −1  src/ulib/net/server/client_image.cpp
  27. +7 −0 src/ulib/net/server/plugin/mod_fcgi.cpp
  28. +34 −21 src/ulib/net/server/plugin/mod_http.cpp
  29. +27 −15 src/ulib/net/server/plugin/mod_nocat.cpp
  30. +2 −2 src/ulib/net/server/plugin/mod_proxy.cpp
  31. +1 −1  src/ulib/net/server/plugin/mod_proxy_service.cpp
  32. +7 −0 src/ulib/net/server/plugin/mod_scgi.cpp
  33. +7 −0 src/ulib/net/server/plugin/mod_soap.cpp
  34. +7 −0 src/ulib/net/server/plugin/mod_tsa.cpp
  35. +519 −423 src/ulib/net/server/server.cpp
  36. +2 −0  src/ulib/net/server/server_rdb.cpp
  37. +9 −11 src/ulib/net/socket.cpp
  38. +38 −36 src/ulib/notifier.cpp
  39. +3 −7 src/ulib/ssl/net/ssl_session.cpp
  40. +16 −5 src/ulib/string.cpp
  41. +19 −6 src/ulib/timer.cpp
  42. +5 −2 src/ulib/utility/interrupt.cpp
  43. +834 −748 src/ulib/utility/uhttp.cpp
  44. +2 −2 tests/.function
  45. +0 −115 tests/examples/FIRENZE_ssl.cfg
  46. +0 −124 tests/examples/FIRENZE_tcp.cfg
  47. +0 −105 tests/examples/IR_WEB.cfg
  48. +0 −135 tests/examples/RA.cfg
  49. +1 −116 tests/examples/SIENA_ssl.cfg
  50. +0 −125 tests/examples/SIENA_tcp.cfg
  51. +1 −1  tests/examples/TSA/CA/tsaserial
  52. BIN  tests/examples/TSA/TSA/.rnd
  53. +0 −8 tests/examples/WAGSM_server.cfg
  54. +3 −143 tests/examples/WI-AUTH.cfg
  55. +0 −35 tests/examples/attack_server.cfg
  56. +0 −100 tests/examples/benchmark/benchmarking.cfg
  57. +0 −100 tests/examples/benchmark/benchmarking_ssl.cfg
  58. +0 −12 tests/examples/cspserver.cfg
  59. +0 −8 tests/examples/cspserver_rpc.cfg
  60. +3 −0  tests/examples/inp/server.cf
  61. +0 −12 tests/examples/lcspserver.cfg
  62. +0 −8 tests/examples/lcspserver_rpc.cfg
  63. +2 −36 tests/examples/mod_http.cfg
  64. +7 −52 tests/examples/mod_proxy.cfg
  65. +1 −1  tests/examples/mod_proxy_err_msg.cfg
  66. +1 −71 tests/examples/nocat.cfg
  67. +84 −57 tests/examples/nocat/etc/init.d/nodog
  68. +30 −29 tests/examples/ok/client_server.ok
  69. +0 −12 tests/examples/rsignserver.cfg
  70. +0 −8 tests/examples/rsignserver_rpc.cfg
  71. +17 −114 tests/examples/tsa_http.cfg
  72. +0 −12 tests/examples/tsa_https.cfg
  73. +0 −8 tests/examples/tsa_rpc.cfg
  74. +0 −12 tests/examples/tsa_ssoap.cfg
  75. +0 −72 tests/examples/userver.cfg
  76. +0 −109 tests/examples/usp.cfg
  77. +0 −37 tests/examples/web_doc_parse.cfg
  78. +11 −75 tests/examples/web_server-1.cfg
  79. +2 −127 tests/examples/web_server.cfg
  80. +3 −2 tests/examples/web_server.test
  81. +10 −78 tests/examples/web_server0.cfg
  82. +9 −73 tests/examples/web_server1.cfg
  83. +10 −74 tests/examples/web_server2.cfg
  84. +10 −74 tests/examples/web_serverN.cfg
  85. +9 −72 tests/examples/web_serverV.cfg
  86. +0 −4 tests/examples/web_server_echo.cfg
  87. +0 −98 tests/examples/web_server_multiclient.cfg
  88. +1 −68 tests/examples/web_server_ruby.cfg
  89. +2 −4 tests/examples/web_server_ssl.sh
  90. +2 −2 tests/examples/web_server_ssl.test
  91. +9 −71 tests/examples/web_server_ssl0.cfg
  92. +8 −68 tests/examples/web_server_ssl1.cfg
  93. +8 −68 tests/examples/web_server_ssl2.cfg
  94. +8 −67 tests/examples/web_server_sslN.cfg
  95. +1 −68 tests/examples/web_server_yii.cfg
  96. +1 −103 tests/examples/web_socket.cfg
  97. +0 −8 tests/examples/web_socket_proxy.cfg
  98. +0 −109 tests/examples/web_socket_sh.cfg
  99. +0 −72 tests/examples/web_stream.cfg
  100. +2 −2 tests/examples/wi-auth/www/ap/10.8.0.17/nodog.conf.local
  101. +3 −3 tests/examples/wi-auth/www/ap/10.8.0.54/nodog.conf.local
  102. +1 −1  tests/examples/wi-auth/www/ap/10.8.0.65/nodog.conf.local
  103. +1 −1  tests/examples/wi-auth/www/ap/10.8.0.68/nodog.conf.local
  104. +2 −2 tests/examples/wi-auth/www/ap/10.8.0.85/nodog.conf.local
  105. +5 −3 tests/examples/wi-auth/www/ap/10.8.1.2/nodog.conf.local
  106. +16 −11 tests/examples/wi-auth/www/ap/nodog.conf.template
  107. BIN  tests/ulib/inp/test.db
  108. +1 −1  tests/ulib/rdb_client_server.test
  109. +1 −1  tests/ulib/server.test
  110. +2 −1  tests/ulib/ssl_client_server.test
  111. +3 −4 tests/ulib/test_notifier.cpp
  112. +18 −2 tests/ulib/test_rdb_server.cpp
  113. +14 −0 tests/ulib/test_ssl_server.cpp
  114. +9 −0 tests/ulib/test_string.cpp
  115. +14 −0 tests/ulib/test_unixsocket_server.cpp
  116. +2 −1  tests/ulib/unixsocket.test
View
3  Makefile.am
@@ -41,8 +41,7 @@ dist-hook:
$(distdir)/tests/examples/WAGSM/log \
$(distdir)/tests/examples/CApath/*.*0 \
$(distdir)/tests/examples/TSA/log \
- $(distdir)/tests/examples/TSA/DB/log \
- $(distdir)/tests/examples/TSA/DB/.rnd \
+ $(distdir)/tests/examples/TSA/TSA/.rnd \
$(distdir)/tests/examples/TSA/response/* \
$(distdir)/tests/examples/www.sito1.com \
$(distdir)/tests/examples/CSP/DB_CA/CA* \
View
3  Makefile.in
@@ -937,8 +937,7 @@ dist-hook:
$(distdir)/tests/examples/WAGSM/log \
$(distdir)/tests/examples/CApath/*.*0 \
$(distdir)/tests/examples/TSA/log \
- $(distdir)/tests/examples/TSA/DB/log \
- $(distdir)/tests/examples/TSA/DB/.rnd \
+ $(distdir)/tests/examples/TSA/TSA/.rnd \
$(distdir)/tests/examples/TSA/response/* \
$(distdir)/tests/examples/www.sito1.com \
$(distdir)/tests/examples/CSP/DB_CA/CA* \
View
20 configure
@@ -944,6 +944,7 @@ enable_HIS
enable_HCRS
enable_HUPS
enable_CRPWS
+enable_thread_approach
enable_pch
enable_coverage
enable_gcc_optimized
@@ -1629,6 +1630,7 @@ Optional Features:
--enable-HCRS enable HTTP Cache Request Support [default=yes]
--enable-HUPS enable HTTP Upload Progress Support [default=no]
--enable-CRPWS enable Client Response Partial Write Support [default=no]
+ --enable-thread-approach enable server thread approach support [default=no]
--enable-pch enables precompiled header support (currently only gcc >= 3.4) [default=no]
--enable-coverage enable coverage [default=no]
--enable-gcc-optimized compile with GCC optimizations flags enabled (-finline,-fstrict-aliasing,...) [default=yes]
@@ -20933,6 +20935,24 @@ $as_echo "#define U_CLIENT_RESPONSE_PARTIAL_WRITE_SUPPORT 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_CRPWS" >&5
$as_echo "$enable_CRPWS" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if you want to enable server thread approach support" >&5
+$as_echo_n "checking if you want to enable server thread approach support... " >&6; }
+ # Check whether --enable-thread-approach was given.
+if test "${enable_thread_approach+set}" = set; then :
+ enableval=$enable_thread_approach;
+fi
+
+ if test -z "$enable_thread_approach" ; then
+ enable_thread_approach="no"
+ fi
+ if test "$enable_thread_approach" = "yes"; then
+
+$as_echo "#define U_SERVER_THREAD_APPROACH_SUPPORT 1" >>confdefs.h
+
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_thread_approach" >&5
+$as_echo "$enable_thread_approach" >&6; }
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if you want to enable use of precompiled headers" >&5
$as_echo_n "checking if you want to enable use of precompiled headers... " >&6; }
# Check whether --enable-pch was given.
View
24 examples/WiAuth/wi_auth.cpp
@@ -241,17 +241,27 @@
The latitude and longitude attributes are geographic coordinates specified in decimal degrees.
- The altitude attribute denotes the height of the position, specified in meters above the [WGS84] ellipsoid. If the implementation cannot provide altitude information, the value of this attribute must be null.
+ The altitude attribute denotes the height of the position, specified in meters above the [WGS84] ellipsoid.
+ If the implementation cannot provide altitude information, the value of this attribute must be null.
- The accuracy attribute denotes the accuracy level of the latitude and longitude coordinates. It is specified in meters and must be supported by all implementations. The value of the accuracy attribute must be a non-negative real number.
+ The accuracy attribute denotes the accuracy level of the latitude and longitude coordinates. It is specified
+ in meters and must be supported by all implementations. The value of the accuracy attribute must be a non-negative
+ real number.
- The altitudeAccuracy attribute is specified in meters. If the implementation cannot provide altitude information, the value of this attribute must be null. Otherwise, the value of the altitudeAccuracy attribute must be a non-negative real number.
+ The altitudeAccuracy attribute is specified in meters. If the implementation cannot provide altitude information,
+ the value of this attribute must be null. Otherwise, the value of the altitudeAccuracy attribute must be a non-negative
+ real number.
The accuracy and altitudeAccuracy values returned by an implementation should correspond to a 95% confidence level.
- The heading attribute denotes the direction of travel of the hosting device and is specified in degrees, where 0° ≤ heading < 360°, counting clockwise relative to the true north. If the implementation cannot provide heading information, the value of this attribute must be null. If the hosting device is stationary (i.e. the value of the speed attribute is 0), then the value of the heading attribute must be NaN.
+ The heading attribute denotes the direction of travel of the hosting device and is specified in degrees, where 0° ≤ heading < 360°,
+ counting clockwise relative to the true north. If the implementation cannot provide heading information, the value of this attribute
+ must be null. If the hosting device is stationary (i.e. the value of the speed attribute is 0), then the value of the heading attribute
+ must be NaN.
- The speed attribute denotes the magnitude of the horizontal component of the hosting device's current velocity and is specified in meters per second. If the implementation cannot provide speed information, the value of this attribute must be null. Otherwise, the value of the speed attribute must be a non-negative real number.
+ The speed attribute denotes the magnitude of the horizontal component of the hosting device's current velocity and is specified in meters
+ per second. If the implementation cannot provide speed information, the value of this attribute must be null. Otherwise, the value of the
+ speed attribute must be a non-negative real number.
};
*/
@@ -1247,8 +1257,8 @@
U_INTERNAL_ASSERT_POINTER(U_LOCK_USER1)
U_INTERNAL_ASSERT_POINTER(U_LOCK_USER2)
- UString pathdb_ap = U_STRING_FROM_CONSTANT(U_LIBEXECDIR "/WiAuthAccessPoint.cdb"),
- pathdb_user = U_STRING_FROM_CONSTANT(U_LIBEXECDIR "/WiAuthUser.cdb");
+ UString pathdb_ap = U_STRING_FROM_CONSTANT("../db/WiAuthAccessPoint.cdb"),
+ pathdb_user = U_STRING_FROM_CONSTANT("../db/WiAuthUser.cdb");
db_ap = U_NEW(URDB(pathdb_ap, false));
db_user = U_NEW(URDB(pathdb_user, false));
View
24 examples/WiAuth/wi_auth.usp
@@ -238,17 +238,27 @@ interface Coordinates {
The latitude and longitude attributes are geographic coordinates specified in decimal degrees.
-The altitude attribute denotes the height of the position, specified in meters above the [WGS84] ellipsoid. If the implementation cannot provide altitude information, the value of this attribute must be null.
+The altitude attribute denotes the height of the position, specified in meters above the [WGS84] ellipsoid.
+If the implementation cannot provide altitude information, the value of this attribute must be null.
-The accuracy attribute denotes the accuracy level of the latitude and longitude coordinates. It is specified in meters and must be supported by all implementations. The value of the accuracy attribute must be a non-negative real number.
+The accuracy attribute denotes the accuracy level of the latitude and longitude coordinates. It is specified
+in meters and must be supported by all implementations. The value of the accuracy attribute must be a non-negative
+real number.
-The altitudeAccuracy attribute is specified in meters. If the implementation cannot provide altitude information, the value of this attribute must be null. Otherwise, the value of the altitudeAccuracy attribute must be a non-negative real number.
+The altitudeAccuracy attribute is specified in meters. If the implementation cannot provide altitude information,
+the value of this attribute must be null. Otherwise, the value of the altitudeAccuracy attribute must be a non-negative
+real number.
The accuracy and altitudeAccuracy values returned by an implementation should correspond to a 95% confidence level.
-The heading attribute denotes the direction of travel of the hosting device and is specified in degrees, where 0° ≤ heading < 360°, counting clockwise relative to the true north. If the implementation cannot provide heading information, the value of this attribute must be null. If the hosting device is stationary (i.e. the value of the speed attribute is 0), then the value of the heading attribute must be NaN.
+The heading attribute denotes the direction of travel of the hosting device and is specified in degrees, where 0° ≤ heading < 360°,
+counting clockwise relative to the true north. If the implementation cannot provide heading information, the value of this attribute
+must be null. If the hosting device is stationary (i.e. the value of the speed attribute is 0), then the value of the heading attribute
+must be NaN.
-The speed attribute denotes the magnitude of the horizontal component of the hosting device's current velocity and is specified in meters per second. If the implementation cannot provide speed information, the value of this attribute must be null. Otherwise, the value of the speed attribute must be a non-negative real number.
+The speed attribute denotes the magnitude of the horizontal component of the hosting device's current velocity and is specified in meters
+per second. If the implementation cannot provide speed information, the value of this attribute must be null. Otherwise, the value of the
+speed attribute must be a non-negative real number.
};
*/
@@ -1244,8 +1254,8 @@ static void usp_init()
U_INTERNAL_ASSERT_POINTER(U_LOCK_USER1)
U_INTERNAL_ASSERT_POINTER(U_LOCK_USER2)
- UString pathdb_ap = U_STRING_FROM_CONSTANT(U_LIBEXECDIR "/WiAuthAccessPoint.cdb"),
- pathdb_user = U_STRING_FROM_CONSTANT(U_LIBEXECDIR "/WiAuthUser.cdb");
+ UString pathdb_ap = U_STRING_FROM_CONSTANT("../db/WiAuthAccessPoint.cdb"),
+ pathdb_user = U_STRING_FROM_CONSTANT("../db/WiAuthUser.cdb");
db_ap = U_NEW(URDB(pathdb_ap, false));
db_user = U_NEW(URDB(pathdb_user, false));
View
5 examples/userver/userver.cfg.default
@@ -67,14 +67,14 @@ userver {
# SOCKET_NAME tmp/socket
# IP_ADDRESS 10.30.1.131
# ALLOWED_IP 127.0.0.1,10.30.0.0/16
-#
+
# ENABLE_RFC1918_FILTER yes
# ALLOWED_IP_PRIVATE 127.0.0.1,10.30.0.0/16
LISTEN_BACKLOG 1024
SET_REALTIME_PRIORITY yes
- PID_FILE /var/run/userver.pid
+# PID_FILE /var/run/userver.pid
# WELCOME_MSG "220 david.unirel.intranet ULib WEB server (Version 1.1.0) ready.\n"
# RUN_AS_USER apache
DOCUMENT_ROOT /var/www/localhost/htdocs
@@ -83,7 +83,6 @@ userver {
# LOG_FILE_SZ 1M
# LOG_MSG_SIZE -1
- PLUGIN mod_http
# PLUGIN "mod_tsa mod_http"
# PLUGIN "mod_rpc mod_http"
# PLUGIN "mod_soap mod_http"
View
15 include/ulib/container/vector.h
@@ -30,6 +30,7 @@ template <class T> class UVector;
template <> class U_EXPORT UVector<void*> {
public:
+
// Check for memory error
U_MEMORY_TEST
@@ -881,8 +882,11 @@ template <> class U_EXPORT UVector<UString> : public UVector<UStringRep*> {
// STACK OPERATIONS
- void push( UStringRep* rep) { UVector<UStringRep*>::push(rep); }
- void push_back(UStringRep* rep) { UVector<UStringRep*>::push(rep); }
+ void push( UStringRep* rep) { UVector<UStringRep*>::push(rep); }
+ void push_back(UStringRep* rep) { UVector<UStringRep*>::push(rep); }
+
+ void push( const char* str, uint32_t len) { push(UStringRep::create(str, len, 0)); }
+ void push_back(const char* str, uint32_t len) { push(UStringRep::create(str, len, 0)); }
void push( const UString& str);
void push_back(const UString& str) { push(str); } // add to end
@@ -1097,6 +1101,11 @@ template <> class U_EXPORT UVector<UString> : public UVector<UStringRep*> {
uint32_t intersection(UVector<UString>& set1, UVector<UString>& set2);
+ // OPERATOR
+
+ bool operator==(const UVector<UString>& v) const __pure;
+ bool operator!=(const UVector<UString>& v) const { return ! operator==(v); }
+
// STREAMS
uint32_t readline( istream& is);
@@ -1115,7 +1124,7 @@ template <> class U_EXPORT UVector<UString> : public UVector<UStringRep*> {
static void mksort(UStringRep** a, int n, int depth);
bool _isEqual(UVector<UString>& vec, bool ignore_case);
-// uint32_t findWithDataOffset(const char* s, uint32_t n, uint32_t offset = 0) __pure;
+ // uint32_t findWithDataOffset(const char* s, uint32_t n, uint32_t offset = 0) __pure;
UVector<UString>(const UVector<UString>&) : UVector<UStringRep*>() {}
UVector<UString>& operator=(const UVector<UString>&) { return *this; }
View
1  include/ulib/event/event_time.h
@@ -59,6 +59,7 @@ class U_EXPORT UEventTime : public UTimeVal {
void setCurrentTime();
bool isOld() const __pure;
+ bool isExpired() const __pure;
void setTimerVal(struct timeval* it_value);
time_t expire() { return (ctime.tv_sec + tv_sec); }
View
3  include/ulib/internal/config.h.in
@@ -958,6 +958,9 @@ typedef unsigned long long uint64;
/* install directory */
#undef U_PREFIXDIR
+/* enable server thread approach support */
+#undef U_SERVER_THREAD_APPROACH_SUPPORT
+
/* STATIC_HANDLER_ECHO */
#undef U_STATIC_HANDLER_ECHO
View
9 include/ulib/net/server/plugin/mod_http.h
@@ -69,14 +69,7 @@ class U_EXPORT UHttpPlugIn : public UServerPlugIn, UEventFd {
// define method VIRTUAL of class UEventFd
virtual int handlerRead();
- virtual void handlerDelete()
- {
- U_TRACE(0, "UHttpPlugIn::handlerDelete()")
-
- U_INTERNAL_DUMP("UEventFd::fd = %d", UEventFd::fd)
-
- UEventFd::fd = 0;
- }
+ virtual void handlerDelete();
// DEBUG
View
99 include/ulib/net/server/server.h
@@ -185,39 +185,39 @@ class U_EXPORT UServer_Base : public UEventFd {
// bound to the port number, etc...
static void run();
- void init();
- void loadConfigParam(UFileConfig& file);
+ static void init();
+ static void loadConfigParam(UFileConfig& file);
// tipologia server...
static bool bssl, bipc;
- static int getPort() { return port; }
- static int getCgiTimeout() { return cgi_timeout; }
- static int getReqTimeout() { return (timeoutMS / 1000); }
- static bool isIPv6() { return UClientImage_Base::bIPv6; }
- static UString getHost() { return *host; }
+ static int getPort() { return port; }
+ static int getCgiTimeout() { return cgi_timeout; }
+ static int getReqTimeout() { return (timeoutMS / 1000); }
+ static bool isIPv6() { return UClientImage_Base::bIPv6; }
+ static UString getHost() { return *host; }
// The directory out of which you will serve your documents...
- UString document_root;
+ static UString* document_root;
static UString getDocumentRoot()
{
U_TRACE(0, "UServer_Base::getDocumentRoot()")
- U_INTERNAL_ASSERT_POINTER(pthis)
+ U_INTERNAL_ASSERT_POINTER(document_root)
- U_RETURN_STRING(pthis->document_root);
+ U_RETURN_STRING(*document_root);
}
static bool isFileInsideDocumentRoot(const UString& path)
{
U_TRACE(0, "UServer_Base::isFileInsideDocumentRoot(%.*S)", U_STRING_TO_TRACE(path))
- U_INTERNAL_ASSERT_POINTER(pthis)
+ U_INTERNAL_ASSERT_POINTER(document_root)
- bool result = (path.size() >= pthis->document_root.size());
+ bool result = (path.size() >= document_root->size());
U_RETURN(result);
}
@@ -312,9 +312,9 @@ class U_EXPORT UServer_Base : public UEventFd {
U_RETURN_POINTER(shared_data_ptr, void);
}
- static UClientImage_Base* pindex;
- static UClientImage_Base* vClientImage;
+ static UClientImage_Base* pClientIndex;
static UClientImage_Base* pClientImage;
+ static UClientImage_Base* vClientImage;
static UClientImage_Base* eClientImage;
static const char* getClientAddress()
@@ -403,7 +403,7 @@ class U_EXPORT UServer_Base : public UEventFd {
// NETWORK CTX
- static UString getIPAddress() { return pthis->IP_address; }
+ static UString getIPAddress() { return *IP_address; }
static UString getMacAddress( const char* device_or_ip) { return USocketExt::getMacAddress(socket->getFd(), device_or_ip); }
static UString getNetworkAddress(const char* device) { return USocketExt::getNetworkAddress(socket->getFd(), device); }
static UString getNetworkDevice( const char* exclude) { return USocketExt::getNetworkDevice(exclude); }
@@ -415,25 +415,25 @@ class U_EXPORT UServer_Base : public UEventFd {
#endif
protected:
- UString server, // host name or ip address for the listening socket
- as_user, // change the current working directory to the user's home dir, and downgrade security to that user account
- log_file, // locations for file log
- dh_file, // These are the 1024 bit DH parameters from "Assigned Number for SKIP Protocols"
- cert_file, // locations for certificate of server
- key_file, // locations for private key of server
- password, // password for private key of server
- ca_file, // locations of trusted CA certificates used in the verification
- ca_path, // locations of trusted CA certificates used in the verification
- name_sock, // name file for the listening socket
- IP_address, // IP address of this server
- allow_IP, // Interpret a "HOST/BITS" IP mask specification. (Ex. 192.168.1.64/28)
- allow_IP_prv;// Interpret a "HOST/BITS" IP mask specification. (Ex. 192.168.1.64/28)
-
- static int port, // the port number to bind to
- iBackLog, // max number of ready to be delivered connections to accept()
- timeoutMS, // the time-out value in milliseconds for client request
- cgi_timeout, // the time-out value in seconds for output cgi process
- verify_mode; // mode of verification ssl connection
+ static int port, // the port number to bind to
+ iBackLog, // max number of ready to be delivered connections to accept()
+ timeoutMS, // the time-out value in milliseconds for client request
+ cgi_timeout, // the time-out value in seconds for output cgi process
+ verify_mode; // mode of verification ssl connection
+
+ static UString* server; // host name or ip address for the listening socket
+ static UString* as_user; // change the current working directory to the user's home dir, and downgrade security to that user account
+ static UString* log_file; // locations for file log
+ static UString* dh_file; // These are the 1024 bit DH parameters from "Assigned Number for SKIP Protocols"
+ static UString* cert_file; // locations for certificate of server
+ static UString* key_file; // locations for private key of server
+ static UString* password; // password for private key of server
+ static UString* ca_file; // locations of trusted CA certificates used in the verification
+ static UString* ca_path; // locations of trusted CA certificates used in the verification
+ static UString* name_sock; // name file for the listening socket
+ static UString* IP_address; // IP address of this server
+ static UString* allow_IP; // Interpret a "HOST/BITS" IP mask specification. (Ex. 192.168.1.64/28)
+ static UString* allow_IP_prv; // Interpret a "HOST/BITS" IP mask specification. (Ex. 192.168.1.64/28)
static UString* host;
static UProcess* proc;
@@ -488,12 +488,14 @@ class U_EXPORT UServer_Base : public UEventFd {
UTimeoutConnection& operator=(const UTimeoutConnection&) { return *this; }
};
- static UVector<UServerPlugIn*>* vplugin;
+ static uint32_t vplugin_size;
static UVector<UString>* vplugin_name;
+ static UVector<UString>* vplugin_name_static;
+ static UVector<UServerPlugIn*>* vplugin;
static const char* getNumConnection();
- static void runAsUser(const char* user);
+ static void runLoop(const char* user);
static bool handlerTimeoutConnection(void* cimg);
static void handlerCloseConnection(UClientImage_Base* ptr);
@@ -546,7 +548,7 @@ class U_EXPORT UServer_Base : public UEventFd {
friend class UModProxyService;
friend class UClientImage_Base;
- static struct linger lng;
+// static struct linger lng;
static void loadStaticLinkedModules(const char* name) U_NO_EXPORT;
@@ -571,7 +573,7 @@ template <class Socket> class U_EXPORT UServer : public UServer_Base {
// MANAGE ALL...
- void go()
+ static void go()
{
U_TRACE(0, "UServer<Socket>::go()")
@@ -629,9 +631,9 @@ template <> class U_EXPORT UServer<USSLSocket> : public UServer_Base {
// SERVICES
- static USSLSocket* getSocket() { return (USSLSocket*) pthis->socket; }
+ static USSLSocket* getSocket() { return (USSLSocket*)socket; }
- bool askForClientCertificate()
+ static bool askForClientCertificate()
{
U_TRACE(0, "UServer<USSLSocket>::askForClientCertificate()")
@@ -658,21 +660,22 @@ template <> class U_EXPORT UServer<USSLSocket> : public UServer_Base {
// MANAGE ALL...
- void go()
+ static void go()
{
U_TRACE(0, "UServer<USSLSocket>::go()")
U_INTERNAL_ASSERT(getSocket()->isSSL())
- U_INTERNAL_ASSERT( dh_file.isNullTerminated())
- U_INTERNAL_ASSERT( ca_file.isNullTerminated())
- U_INTERNAL_ASSERT( ca_path.isNullTerminated())
- U_INTERNAL_ASSERT( key_file.isNullTerminated())
- U_INTERNAL_ASSERT( password.isNullTerminated())
- U_INTERNAL_ASSERT(cert_file.isNullTerminated())
+ U_INTERNAL_ASSERT( dh_file->isNullTerminated())
+ U_INTERNAL_ASSERT( ca_file->isNullTerminated())
+ U_INTERNAL_ASSERT( ca_path->isNullTerminated())
+ U_INTERNAL_ASSERT( key_file->isNullTerminated())
+ U_INTERNAL_ASSERT( password->isNullTerminated())
+ U_INTERNAL_ASSERT(cert_file->isNullTerminated())
// Load our certificate
- if (getSocket()->setContext(dh_file.data(), cert_file.data(), key_file.data(), password.data(), ca_file.data(), ca_path.data(), verify_mode) == false)
+ if (getSocket()->setContext(dh_file->data(), cert_file->data(), key_file->data(),
+ password->data(), ca_file->data(), ca_path->data(), verify_mode) == false)
{
U_ERROR("SSL setContext() failed...");
}
View
8 include/ulib/net/server/server_rdb.h
@@ -47,7 +47,7 @@ class U_EXPORT URDBServer : public UServer<UTCPSocket> {
// Open a reliable database
- bool open(const UString& pathdb, uint32_t log_size = 1024 * 1024)
+ static bool open(const UString& pathdb, uint32_t log_size = 1024 * 1024)
{
U_TRACE(0, "URDBServer::open(%.*S,%u)", U_STRING_TO_TRACE(pathdb), log_size)
@@ -65,7 +65,7 @@ class U_EXPORT URDBServer : public UServer<UTCPSocket> {
#endif
protected:
- URDB* rdb; // need pointer for object dump...
+ static URDB* rdb;
// method VIRTUAL to redefine
@@ -84,8 +84,8 @@ class U_EXPORT URDBServer : public UServer<UTCPSocket> {
}
private:
- URDBServer(const URDBServer& s) : UServer<UTCPSocket>(0), rdb(s.rdb) {}
- URDBServer& operator=(const URDBServer&) { return *this; }
+ URDBServer(const URDBServer& s) : UServer<UTCPSocket>(0) {}
+ URDBServer& operator=(const URDBServer&) { return *this; }
};
#endif
View
13 include/ulib/notifier.h
@@ -55,8 +55,8 @@ class U_EXPORT UNotifier {
// SERVICES
- static void init();
- static void clear(bool bthread);
+ static void clear();
+ static void init(bool bacquisition);
static void erase( UEventFd* handler_event);
static void modify(UEventFd* handler_event);
static void insert(UEventFd* handler_event);
@@ -90,9 +90,7 @@ class U_EXPORT UNotifier {
U_RETURN(false);
}
- // return false if there are no more events registered
-
- static bool waitForEvent(UEventTime* timeout);
+ static void waitForEvent(UEventTime* timeout);
// READ - WRITE
@@ -111,7 +109,6 @@ class U_EXPORT UNotifier {
protected:
static int nfd_ready; // the number of file descriptors ready for the requested I/O
- static void* pthread;
static UEventFd** lo_map_fd;
static UGenericHashMap<int,UEventFd*>* hi_map_fd; // maps a fd to a node pointer
@@ -133,6 +130,10 @@ class U_EXPORT UNotifier {
static int waitForEvent(int timeoutMS = -1);
#endif
+#if defined(HAVE_PTHREAD_H) && defined(ENABLE_THREAD) && defined(U_SERVER_THREAD_APPROACH_SUPPORT)
+ static void* pthread;
+#endif
+
static UEventFd* find(int fd);
static int waitForEvent(int fd_max, fd_set* read_set, fd_set* write_set, UEventTime* timeout);
View
2  include/ulib/ssl/net/ssl_session.h
@@ -36,7 +36,7 @@ class U_EXPORT USSLSession {
// SERVICES
static void deleteSessionCache();
- static bool initSessionCache(SSL_CTX* ctx, const char* location, uint32_t sz);
+ static bool initSessionCache(SSL_CTX* ctx, const UString& pathdb, uint32_t sz);
static int newSession(SSL* ssl, SSL_SESSION* sess);
static void removeSession(SSL_CTX* ctx, SSL_SESSION* sess);
View
11 include/ulib/timer.h
@@ -62,8 +62,8 @@ class U_EXPORT UTimer {
}
static void stop();
- static void setTimer();
- static void init(bool async = true);
+ static void init(bool async);
+ static void setTimer(bool bsignal);
static void clear(bool clean_alarm);
static void insert(UEventTime* alarm, bool set_timer = true);
@@ -83,12 +83,7 @@ class U_EXPORT UTimer {
// manage signal
- static RETSIGTYPE handlerAlarm(int signo)
- {
- U_TRACE(0, "[SIGALRM] UTimer::handlerAlarm(%d)", signo)
-
- setTimer();
- }
+ static RETSIGTYPE handlerAlarm(int signo);
// STREAM
View
29 include/ulib/utility/uhttp.h
@@ -36,9 +36,11 @@
#define U_MAX_UPLOAD_PROGRESS 16
#define U_MIN_SIZE_FOR_PARTIAL_WRITE (16U * 1024U)
-#define U_HTTP_BODY(str) (str).substr(u_http_info.endHeader, u_http_info.clength)
-#define U_HTTP_HEADER(str) (str).substr(u_http_info.startHeader, u_http_info.szHeader)
-#define U_HTTP_URI_EQUAL(str) ((str).equal(U_HTTP_URI_TO_PARAM))
+#define U_HTTP_BODY(str) (str).substr(u_http_info.endHeader, u_http_info.clength)
+#define U_HTTP_HEADER(str) (str).substr(u_http_info.startHeader, u_http_info.szHeader)
+#define U_HTTP_URI_EQUAL(str) ((str).equal(U_HTTP_URI_TO_PARAM))
+#define U_HTTP_URI_DOSMATCH(mask,len,flags) (u_dosmatch_with_OR(U_HTTP_URI_TO_PARAM, mask, len, flags))
+#define U_HTTP_URI_OR_ALIAS_STRNEQ(req,str) (U_HTTP_URI_STRNEQ(str) || (req).equal(U_CONSTANT_TO_PARAM(str)))
class UFile;
class UEventFd;
@@ -176,12 +178,12 @@ class U_EXPORT UHTTP {
{ setHTTPInfo(U_STRING_TO_PARAM(method), U_STRING_TO_PARAM(uri)); }
static bool isHTTPRequest(const char* ptr) __pure;
- static bool scanfHTTPHeader( const char* ptr);
+ static bool scanfHTTPHeader( const char* ptr, uint32_t size);
static const char* getHTTPStatus();
static const char* getHTTPStatusDescription(uint32_t nResponseCode);
- static bool readHTTPRequest(USocket* socket);
+ static bool readHTTPRequest();
static bool findEndHeader( const UString& buffer);
static bool readHTTPHeader( USocket* socket, UString& buffer);
static bool readHTTPBody( USocket* socket, UString* buffer, UString& body);
@@ -258,6 +260,7 @@ class U_EXPORT UHTTP {
// SERVICES
+ static UString* uri;
static UString* alias;
static UString* cbuffer;
static UStringRep* pkey;
@@ -275,7 +278,7 @@ class U_EXPORT UHTTP {
static bool virtual_host, enable_caching_by_proxy_servers, telnet_enable, bsendfile;
static uint32_t limit_request_body, request_read_timeout, min_size_for_sendfile, range_start, range_size;
- static int checkHTTPRequest();
+ static bool manageHTTPRequest();
static void writeApacheLikeLog();
static bool callService(const UString& path);
static void manageHTTPServletRequest(bool as_service);
@@ -284,11 +287,21 @@ class U_EXPORT UHTTP {
static bool checkHTTPContentLength(UString& x, uint32_t length, uint32_t pos = U_NOT_FOUND);
static uint32_t getUserAgent();
+ static UString getRequestURI();
static UString getDocumentName();
static UString getDirectoryURI();
- static UString getRequestURI(bool bquery);
+ static UString getRequestURIWithQuery();
static UString getHeaderMimeType(const char* content, const char* content_type, uint32_t size, time_t expire);
+ static void endHTTPRequestProcessing()
+ {
+ U_TRACE(0, "UHTTP::endHTTPRequestProcessing()")
+
+ if (UHTTP::apache_like_log) UHTTP::writeApacheLikeLog();
+
+ u_http_info.method = 0; // NB: this mark the end of http request processing...
+ }
+
static const char* getHTTPHeaderValuePtr(const UString& request, const UString& name, bool nocase)
{
U_TRACE(0, "UHTTP::getHTTPHeaderValuePtr(%.*S,%.*S,%b)", U_STRING_TO_TRACE(request), U_STRING_TO_TRACE(name), nocase)
@@ -1006,10 +1019,10 @@ class U_EXPORT UHTTP {
static bool openFile() U_NO_EXPORT;
static void in_CREATE() U_NO_EXPORT;
static void in_DELETE() U_NO_EXPORT;
- static void checkPath() U_NO_EXPORT;
static bool processFileCache() U_NO_EXPORT;
static void processRewriteRule() U_NO_EXPORT;
static bool checkPath(uint32_t len) U_NO_EXPORT;
+ static void checkPath(bool bnostat) U_NO_EXPORT;
static void setCGIShellScript(UString& command) U_NO_EXPORT;
static bool runDynamicPage(UString* penvironment) U_NO_EXPORT;
static void manageBufferResize(const char* rpointer1, const char* rpointer2) U_NO_EXPORT;
View
11 m4/ac_compilation_options.m4
@@ -69,6 +69,17 @@ AC_DEFUN([AC_COMPILATION_OPTIONS],[
fi
AC_MSG_RESULT([$enable_CRPWS])
+ AC_MSG_CHECKING(if you want to enable server thread approach support)
+ AC_ARG_ENABLE(thread-approach,
+ [ --enable-thread-approach enable server thread approach support [[default=no]]])
+ if test -z "$enable_thread_approach" ; then
+ enable_thread_approach="no"
+ fi
+ if test "$enable_thread_approach" = "yes"; then
+ AC_DEFINE(U_SERVER_THREAD_APPROACH_SUPPORT, 1, [enable server thread approach support])
+ fi
+ AC_MSG_RESULT([$enable_thread_approach])
+
AC_MSG_CHECKING(if you want to enable use of precompiled headers)
AC_ARG_ENABLE(pch,
[ --enable-pch enables precompiled header support (currently only gcc >= 3.4) [[default=no]]])
View
28 openwrt/package/nodog/Makefile
@@ -16,8 +16,10 @@ STAMP_CONFIGURED:=$(STAMP_CONFIGURED)_$(call confvar, CONFIG_NODOG_DEBUG)
define Package/nodog
TITLE:=nocat enhanced
URL:=http://www.unirel.com/ULib
- DEPENDS:= +libstdcpp +libopenssl +zlib $(if $(CONFIG_NODOG_UUID),+libuuid) +iptables-mod-ipopt +iptables-mod-nat +iptables-mod-nat-extra
-## DEPENDS:= +libstdcpp +zlib $(if $(CONFIG_NODOG_UUID),+libuuid) $(if $(CONFIG_NODOG_OPENSSL),+libopenssl) $(if $(CONFIG_NODOG_CYASSL),+libcyassl)
+ DEPENDS:= +libstdcpp +libopenssl +libpcre +zlib $(if $(CONFIG_NODOG_UUID),+libuuid)
+## DEPENDS:= +libstdcpp +libpcre +zlib $(if $(CONFIG_NODOG_UUID),+libuuid) \
+## $(if $(CONFIG_NODOG_OPENSSL),+libopenssl) $(if $(CONFIG_NODOG_CYASSL),+libcyassl) \
+## +iptables-mod-ipopt +iptables-mod-nat +iptables-mod-nat-extra
endef
define Package/nodog/Description
@@ -32,24 +34,18 @@ define Package/nodog/config
endef
define Package/nodog/conffiles
-/etc/nodog.conf
-/etc/nodog.freesite
+/etc/nodog.key
+/etc/nodog.portal
/etc/uclient.conf
/etc/init.d/nodog
-/usr/lib/nodog/firewall/dump.fw
-/usr/lib/nodog/firewall/access.fw
-/usr/lib/nodog/firewall/throttle.fw
-/usr/lib/nodog/firewall/initialize.fw
-/usr/lib/nodog/firewall/reset.fw
-/usr/lib/nodog/bin/upload-logs.sh
+/usr/lib/nodog/firewall/nodog.fw
+/usr/lib/nodog/firewall/tcrules.awk
endef
NODOG_OPTIONS:= --with-ssl --with-libz \
--without-expat --without-magic \
--disable-static --disable-new-ldflags --disable-zip --disable-LFS --disable-gcc-optimized --disable-thread --disable-HCRS \
- --enable-static-module="mod_proxy mod_nocat mod_http" \
- $(if $(CONFIG_NODOG_UUID),--with-libuuid,--without-libuuid) $(if $(CONFIG_NODOG_DEBUG),--enable-debug)
-## --enable-linux-netfilter
+ --enable-static-module="mod_proxy mod_nocat mod_http" $(if $(CONFIG_NODOG_UUID),--with-libuuid,--without-libuuid) $(if $(CONFIG_NODOG_DEBUG),--enable-debug)
define Build/Configure
$(call Build/Configure/Default, \
@@ -70,11 +66,11 @@ define Package/nodog/install
mkdir -p $(PKG_INSTALL_DIR)
$(MAKE) -C $(PKG_BUILD_DIR) DESTDIR="$(PKG_INSTALL_DIR)" install
$(INSTALL_DIR) $(1)/etc $(1)/usr/sbin $(1)/usr/lib/ulib $(1)/usr/lib/nodog
- $(CP) -a $(PKG_INSTALL_DIR)/usr/lib/libulib* $(1)/usr/lib/
## $(CP) -a $(PKG_INSTALL_DIR)/usr/lib/ulib/mod_proxy* $(1)/usr/lib/ulib
+ $(CP) -a $(PKG_INSTALL_DIR)/usr/lib/libulib* $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/bin/uclient $(PKG_INSTALL_DIR)/usr/bin/userver_tcp $(1)/usr/sbin/
- $(CP) -r $(PKG_BUILD_DIR)/tests/examples/nocat/* $(1)/usr/lib/nodog
- $(CP) -r $(PKG_BUILD_DIR)/tests/examples/nocat/.ht* $(1)/usr/lib/nodog
+ $(CP) -r $(PKG_BUILD_DIR)/tests/examples/nocat/* \
+ $(PKG_BUILD_DIR)/tests/examples/nocat/.ht* $(1)/usr/lib/nodog
$(CP) -r $(1)/usr/lib/nodog/etc $(1)/
$(RM) -rf $(1)/usr/lib/nodog/etc
endef
View
5 openwrt/package/userver/Config.in
@@ -0,0 +1,5 @@
+# userver config
+config USERVER_DEBUG
+ bool "Enable compilation of debugging features"
+ depends on DEVEL && PACKAGE_userver
+ default n
View
76 openwrt/package/userver/Makefile
@@ -0,0 +1,76 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=userver
+PKG_VERSION:=1.1.0
+PKG_RELEASE:=12
+
+PKG_SOURCE:=ULib-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.unirel.com/ULib
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/ulib-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+STAMP_CONFIGURED:=$(STAMP_CONFIGURED)_$(call confvar, CONFIG_USERVER_DEBUG)
+
+define Package/userver
+ TITLE:=application server by ULib
+ URL:=http://www.unirel.com/ULib
+ DEPENDS:= +libstdcpp +libopenssl +zlib +libuuid +libpcre
+endef
+
+define Package/userver/Description
+application server by ULib
+endef
+
+define Package/userver/config
+ source "$(SOURCE)/Config.in"
+endef
+
+define Package/userver/conffiles
+/etc/init.d/userver
+/srv/userver/etc/firenze_ssl.cfg
+/srv/userver/etc/firenze_tcp.cfg
+/srv/userver/etc/uclient-firenze.cfg
+/srv/userver/bin/reset_policy.sh
+/srv/userver/bin/get_users_info.sh
+/srv/userver/bin/card_activation.sh
+/srv/userver/bin/send_req_to_portal.sh
+/srv/userver/bin/check_for_assertion.sh
+/srv/userver/bin/get_users_info_for_ap.sh
+endef
+
+USERVER_OPTIONS:= --with-ssl --with-libz --with-libuuid --with-pcre \
+ --without-expat --without-magic \
+ --disable-static --disable-new-ldflags --disable-zip --disable-LFS --disable-gcc-optimized --disable-HCRS \
+ --enable-static-module="mod_proxy mod_ssi mod_http" \
+ $(if $(CONFIG_USERVER_DEBUG),--enable-debug)
+
+define Build/Configure
+ $(call Build/Configure/Default, \
+ --prefix=$(PKG_INSTALL_DIR)/usr \
+ $(USERVER_OPTIONS))
+endef
+
+define Build/Compile
+ rm -rf $(PKG_INSTALL_DIR)
+ mkdir -p $(PKG_INSTALL_DIR)
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ CC="$(TARGET_CC)" \
+ AR="$(TARGET_CROSS)ar r" \
+ RANLIB="$(TARGET_CROSS)ranlib"
+endef
+
+define Package/userver/install
+ mkdir -p $(PKG_INSTALL_DIR)
+ $(MAKE) -C $(PKG_BUILD_DIR) DESTDIR="$(PKG_INSTALL_DIR)" install
+ $(INSTALL_DIR) $(1)/etc $(1)/usr/sbin $(1)/usr/lib
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/rdbgen \
+ $(PKG_INSTALL_DIR)/usr/bin/uclient \
+ $(PKG_INSTALL_DIR)/usr/bin/userver_tcp \
+ $(PKG_INSTALL_DIR)/usr/bin/userver_ssl $(1)/usr/sbin/
+ $(CP) -a $(PKG_INSTALL_DIR)/usr/lib/libulib* \
+ $(PKG_INSTALL_DIR)/usr/lib/ulib/usp/wi_auth.so $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,userver))
View
25 src/ulib/container/vector.cpp
@@ -680,6 +680,31 @@ UVector<UString>* UVector<UString>::duplicate(UVector<UString>* v)
U_RETURN_POINTER(v1,UVector<UString>);
}
+__pure bool UVector<UString>::operator==(const UVector<UString>& v) const
+{
+ U_TRACE(0, "UVector<UString>::operator==(%p)", &v)
+
+ U_CHECK_MEMORY
+
+ if (_length == v._length)
+ {
+ UStringRep* r1;
+ UStringRep* r2;
+
+ for (uint32_t i = 0; i < _length; ++i)
+ {
+ r1 = UVector<UStringRep*>::at(i);
+ r2 = v.UVector<UStringRep*>::at(i);
+
+ if (r1->equal(r2) == false) U_RETURN(false);
+ }
+
+ U_RETURN(true);
+ }
+
+ U_RETURN(false);
+}
+
// THREE-WAY RADIX QUICKSORT
// ------------------------------------------------------
// Multikey Quicksort - Dr. Dobb's Journal, November 1998
View
24 src/ulib/event/event_time.cpp
@@ -79,6 +79,30 @@ __pure bool UEventTime::isOld() const
U_RETURN(result);
}
+__pure bool UEventTime::isExpired() const
+{
+ U_TRACE(0, "UEventTime::isExpired()")
+
+ U_CHECK_MEMORY
+
+ U_INTERNAL_DUMP("this = { %ld %6ld }", ctime.tv_sec + tv_sec, ctime.tv_usec + tv_usec)
+
+ long diff = (ctime.tv_sec + tv_sec - u_now->tv_sec) * 1000L +
+ ((ctime.tv_usec + tv_usec - u_now->tv_usec) / 1000L);
+
+ U_DUMP("diff = %ld", diff)
+
+ if (diff <= 0) U_RETURN(true);
+
+ long delta = UTimeVal::getMilliSecond() / 128;
+
+ U_DUMP("delta = %ld", diff, delta)
+
+ if (diff <= delta) U_RETURN(true);
+
+ U_RETURN(false);
+}
+
__pure bool UEventTime::operator<(const UEventTime& t) const
{
U_TRACE(0, "UEventTime::operator<(%O)", U_OBJECT_TO_TRACE(t))
View
15 src/ulib/file_config.cpp
@@ -117,11 +117,15 @@ bool UFileConfig::processData()
UCommand cmd(command);
UString output(U_CAPACITY);
- bool esito = cmd.execute(&data, &output, -1, fd_stderr);
+ (void) cmd.execute(&data, &output, -1, fd_stderr);
UServer_Base::logCommandMsgError(cmd.getCommand(), true);
-
- if (esito == false) U_RETURN(false);
+
+ // ------------------------------------------
+ // NB: sometime we have problem with comments
+ // ------------------------------------------
+ // if (esito == false) U_RETURN(false);
+ // ------------------------------------------
data = output;
}
@@ -195,7 +199,6 @@ bool UFileConfig::searchForObjectStream(const char* section, uint32_t len)
const char* save_start = _start;
retry:
-
while (_start < _end)
{
_start = u_skip(_start, _end, 0, '#');
@@ -237,7 +240,7 @@ bool UFileConfig::searchForObjectStream(const char* section, uint32_t len)
_size = (_end - ++_start); // NB: we advance one char (to call u_skip() after...)
- U_INTERNAL_DUMP("_size = %u", _size)
+ U_INTERNAL_DUMP("_size = %u _end = %.*S", _size, 10, _end)
}
// FOUND
@@ -283,6 +286,8 @@ bool UFileConfig::loadTable(UHashMap<UString>& tbl)
_start += pos;
_size -= pos;
+ U_INTERNAL_DUMP("_size = %u _start = %.*S", _size, 10, _start)
+
if (tbl.empty() == false) U_RETURN(true);
}
}
View
8 src/ulib/mime/header.cpp
@@ -208,8 +208,12 @@ uint32_t UMimeHeader::getAttributeFromKeyValue(const UString& key_value, UVector
n = name_value.split(key_value.substr(pos + 1), " =;"); // NB: I can't use also '"' char...
- U_INTERNAL_ASSERT( n >= 2)
- U_INTERNAL_ASSERT((n & 1) == 0) // pari...
+ if ((n & 1)) // NB: it is even...
+ {
+ (void) name_value.pop();
+
+ n -= 1;
+ }
}
}
View
2  src/ulib/net/client/client.cpp
@@ -186,7 +186,7 @@ void UClient_Base::loadConfigParam(UFileConfig& cfg)
if (UServer_Base::isLog() == false) log = U_NEW(ULog(log_file, cfg.readLong(*UServer_Base::str_LOG_FILE_SZ), "(pid %P) %10D> "));
else
{
- U_ASSERT_EQUALS(log_file, UServer_Base::pthis->log_file)
+ U_ASSERT_EQUALS(log_file, *UServer_Base::pthis->log_file)
setLogShared();
View
1  src/ulib/net/server/client_image.cpp
@@ -688,7 +688,6 @@ int UClientImage_Base::handlerRead()
#ifdef U_HTTP_CACHE_REQUEST
end:
#endif
-
last_event = u_now->tv_sec;
U_RETURN(U_NOTIFIER_OK);
View
7 src/ulib/net/server/plugin/mod_fcgi.cpp
@@ -258,6 +258,13 @@ int UFCGIPlugIn::handlerInit()
set_FCGIBeginRequest();
+ // NB: FCGI is NOT a static page...
+
+ if (UHTTP::valias == 0) UHTTP::valias = U_NEW(UVector<UString>(2U));
+
+ UHTTP::valias->push_back(*UHTTP::fcgi_uri_mask);
+ UHTTP::valias->push_back(U_STRING_FROM_CONSTANT("/nostat"));
+
U_RETURN(U_PLUGIN_HANDLER_GO_ON);
}
View
55 src/ulib/net/server/plugin/mod_http.cpp
@@ -107,6 +107,15 @@ int UHttpPlugIn::handlerRead()
U_RETURN(U_NOTIFIER_OK);
}
+void UHttpPlugIn::handlerDelete()
+{
+ U_TRACE(0, "UHttpPlugIn::handlerDelete()")
+
+ U_INTERNAL_DUMP("UEventFd::fd = %d", UEventFd::fd)
+
+ UEventFd::fd = 0;
+}
+
// Server-wide hooks
int UHttpPlugIn::handlerConfig(UFileConfig& cfg)
@@ -149,7 +158,8 @@ int UHttpPlugIn::handlerConfig(UFileConfig& cfg)
UVector<UString> tmp;
- if (cfg.loadVector(tmp, "ALIAS") && tmp.empty() == false)
+ if (cfg.loadVector(tmp, "ALIAS") &&
+ tmp.empty() == false)
{
U_INTERNAL_ASSERT_EQUALS(UHTTP::valias,0)
@@ -158,7 +168,8 @@ int UHttpPlugIn::handlerConfig(UFileConfig& cfg)
tmp.clear();
}
- if (cfg.loadVector(tmp, "REWRITE_RULE_NF") && tmp.empty() == false)
+ if (cfg.loadVector(tmp, "REWRITE_RULE_NF") &&
+ tmp.empty() == false)
{
U_INTERNAL_ASSERT_EQUALS(UHTTP::vRewriteRule,0)
@@ -256,11 +267,14 @@ int UHttpPlugIn::handlerConfig(UFileConfig& cfg)
// NB: we ask to notify for change of file system (inotify)
// in the thread approach this is very dangerous...
- if (UNotifier::pthread == 0) UServer_Base::handler_inotify = this;
- else
+ UServer_Base::handler_inotify = this;
+
+# if defined(HAVE_PTHREAD_H) && defined(ENABLE_THREAD) && defined(U_SERVER_THREAD_APPROACH_SUPPORT)
+ if (UNotifier::pthread)
{
- U_SRV_LOG("Sorry, I can't enable inode based directory notification because PREFORK_CHILD == -1");
+ U_SRV_LOG("Sorry, I can't enable inode based directory notification because PREFORK_CHILD == -1 (server thread approach)");
}
+# endif
}
# endif
@@ -321,7 +335,7 @@ int UHttpPlugIn::handlerRun()
U_INTERNAL_ASSERT_POINTER(UHTTP::cache_file)
- // NB: now we have shared data allocated by UServer...
+ // NB: we use this method because now we have the shared data allocated by UServer...
if (UServer_Base::isLog()) UServer_Base::mod_name->snprintf("[usp_init] ", 0);
@@ -364,7 +378,12 @@ int UHttpPlugIn::handlerREAD()
{
result = UHTTP::checkHTTPRequestCache();
- if (result != U_PLUGIN_HANDLER_FINISHED) U_RETURN(result);
+ if (result != U_PLUGIN_HANDLER_FINISHED)
+ {
+ if (UHTTP::apache_like_log) UHTTP::writeApacheLikeLog();
+
+ U_RETURN(result);
+ }
}
UHTTP::clearHTTPRequestCache();
@@ -373,24 +392,18 @@ int UHttpPlugIn::handlerREAD()
if (UClientImage_Base::isPipeline() == false) UClientImage_Base::initAfterGenericRead();
#endif
- if (UHTTP::readHTTPRequest(UServer_Base::pClientImage->socket) == false)
- {
- if (UHTTP::apache_like_log) UHTTP::writeApacheLikeLog();
+ if (UHTTP::manageHTTPRequest() == false) U_RETURN(U_PLUGIN_HANDLER_ERROR);
- U_RETURN(U_PLUGIN_HANDLER_ERROR);
- }
+ // NB: we check if we can shortcut the http request processing (only in the context of U_PLUGIN_HANDLER_FINISHED)...
- result = UHTTP::checkHTTPRequest();
+ UServer_Base::bpluginsHandlerRequest = (UClientImage_Base::write_off == false &&
+ UHTTP::isHTTPRequestAlreadyProcessed() == false);
- if (result == U_PLUGIN_HANDLER_FINISHED)
- {
- UServer_Base::bpluginsHandlerRequest = (UClientImage_Base::write_off == false &&
- UHTTP::isHTTPRequestAlreadyProcessed() == false);
+ U_INTERNAL_DUMP("UServer_Base::bpluginsHandlerRequest = %b", UServer_Base::bpluginsHandlerRequest)
- U_INTERNAL_DUMP("UServer_Base::bpluginsHandlerRequest = %b", UServer_Base::bpluginsHandlerRequest)
+ if (UServer_Base::bpluginsHandlerRequest) U_RETURN(U_PLUGIN_HANDLER_FINISHED);
- if (UServer_Base::bpluginsHandlerRequest == false) result = handlerRequest();
- }
+ result = handlerRequest();
U_RETURN(result);
}
@@ -467,7 +480,7 @@ int UHttpPlugIn::handlerRequest()
}
end:
- if (UHTTP::apache_like_log) UHTTP::writeApacheLikeLog();
+ UHTTP::endHTTPRequestProcessing();
// check for "Connection: close" in headers
View
42 src/ulib/net/server/plugin/mod_nocat.cpp
@@ -2202,7 +2202,7 @@ int UNoCatPlugIn::handlerRequest()
Url url;
int refresh = 0;
UModNoCatPeer* peer = 0;
- UString _host(U_HTTP_HOST_TO_PARAM), buffer(U_CAPACITY);
+ UString _host(U_HTTP_HOST_TO_PARAM), buffer(U_CAPACITY), request_uri = UHTTP::getRequestURI();
U_INTERNAL_DUMP("_host = %.*S UServer_Base::getClientAddress() = %S", U_STRING_TO_TRACE(_host), UServer_Base::getClientAddress())
@@ -2210,15 +2210,22 @@ int UNoCatPlugIn::handlerRequest()
if (UServer_Base::isLog() == false) (void) U_SYSCALL(gettimeofday, "%p,%p", u_now, 0);
- // NB: check for request from AUTHs
+ // ----------------------------------------------
+ // NB: check for request from AUTH, which may be:
+ // ----------------------------------------------
+ // a) /users - report list ip of peers permitted
+ // b) /check - check system and report info
+ // c) /status - report status user
+ // d) /logout - logout specific user
+ // ----------------------------------------------
uint32_t index_AUTH = vauth_ip->contains(UServer_Base::getClientAddress());
if (index_AUTH != U_NOT_FOUND)
{
- U_SRV_LOG("request from AUTH: %.*S", U_HTTP_URI_TO_TRACE);
+ U_SRV_LOG("request from AUTH(%u): %.*S alias %.*S", index_AUTH, U_STRING_TO_TRACE(request_uri), U_HTTP_URI_TO_TRACE);
- if (U_HTTP_URI_STRNEQ("/check"))
+ if (U_HTTP_URI_OR_ALIAS_STRNEQ(request_uri, "/check"))
{
if (flag_check_system == false) checkSystem();
@@ -2227,7 +2234,7 @@ int UNoCatPlugIn::handlerRequest()
goto end;
}
- if (U_HTTP_URI_STRNEQ("/status"))
+ if (U_HTTP_URI_OR_ALIAS_STRNEQ(request_uri, "/status"))
{
UString _label;
@@ -2272,7 +2279,7 @@ int UNoCatPlugIn::handlerRequest()
goto end;
}
- if (U_HTTP_URI_STRNEQ("/logout") &&
+ if (U_HTTP_URI_OR_ALIAS_STRNEQ(request_uri, "/logout") &&
u_http_info.query_len)
{
// NB: request from AUTH to logout user (ip=192.168.301.223&mac=00:e0:4c:d4:63:f5)
@@ -2330,7 +2337,7 @@ int UNoCatPlugIn::handlerRequest()
goto end;
}
- if (U_HTTP_URI_STRNEQ("/users"))
+ if (U_HTTP_URI_OR_ALIAS_STRNEQ(request_uri, "/users"))
{
// NB: request from AUTH to get list info on peers permitted
@@ -2374,11 +2381,20 @@ int UNoCatPlugIn::handlerRequest()
goto end;
}
+ // ---------------------------------------------------------------
+ // NB: other kind of message, which may be:
+ // ---------------------------------------------------------------
+ // a) /cpe - specific request, force redirect via https
+ // b) /test - force redirect even without a firewall
+ // e) /ticket - authorization ticket with info
+ // h) /login_validate - before authorization ticket with info
+ // ---------------------------------------------------------------
+
index_AUTH = getIndexAUTH(UServer_Base::getClientAddress());
url = *((*vauth_url)[index_AUTH]);
peer = (*peers)[UServer_Base::getClientAddress()];
- if (U_HTTP_URI_STRNEQ("/cpe"))
+ if (U_HTTP_URI_OR_ALIAS_STRNEQ(request_uri, "/cpe"))
{
(void) buffer.assign(U_CONSTANT_TO_PARAM("http://www.google.com"));
@@ -2388,14 +2404,14 @@ int UNoCatPlugIn::handlerRequest()
goto set_redirect_to_AUTH;
}
- if (U_HTTP_URI_STRNEQ("/test"))
+ if (U_HTTP_URI_OR_ALIAS_STRNEQ(request_uri, "/test"))
{
(void) buffer.assign(U_CONSTANT_TO_PARAM("http://www.google.com"));
goto set_redirect_to_AUTH;
}
- if (U_HTTP_URI_STRNEQ("/login_validate") &&
+ if (U_HTTP_URI_OR_ALIAS_STRNEQ(request_uri, "/login_validate") &&
u_http_info.query_len)
{
// user has pushed the login button
@@ -2433,7 +2449,7 @@ int UNoCatPlugIn::handlerRequest()
goto set_redirect_to_AUTH;
}
- if (U_HTTP_URI_STRNEQ( "/ticket") &&
+ if (U_HTTP_URI_OR_ALIAS_STRNEQ(request_uri, "/ticket") &&
U_HTTP_QUERY_STRNEQ("ticket="))
{
// user with a ticket
@@ -2497,10 +2513,6 @@ int UNoCatPlugIn::handlerRequest()
end:
UHTTP::setHTTPRequestProcessed();
-
- // NB: maybe we have a check delayed because of http request processing...
-
- u_http_info.method = 0;
}
U_RETURN(U_PLUGIN_HANDLER_GO_ON);
View
4 src/ulib/net/server/plugin/mod_proxy.cpp
@@ -160,8 +160,8 @@ int UProxyPlugIn::handlerRequest()
U_ASSERT_EQUALS(UClientImage_Base::wbuffer->empty(), false)
- if ( UHTTP::isHTTPRequest( ptr) == false ||
- (U_HTTP_INFO_INIT(0), UHTTP::scanfHTTPHeader(ptr)) == false)
+ if ( UHTTP::isHTTPRequest( ptr) == false ||
+ (U_HTTP_INFO_INIT(0), UHTTP::scanfHTTPHeader(ptr, UClientImage_Base::wbuffer->size())) == false)
{
err = UModProxyService::INTERNAL_ERROR;
View
2  src/ulib/net/server/plugin/mod_proxy_service.cpp
@@ -160,7 +160,7 @@ UModProxyService::findService(const char* host, uint32_t host_len, const char* m
U_INTERNAL_DUMP("uri = %.*S", U_HTTP_URI_TO_TRACE)
UModProxyService* elem;
- UString uri = UHTTP::getRequestURI(false);
+ UString uri = UHTTP::getRequestURI();
for (uint32_t i = 0, n = vservice.size(); i < n; ++i)
{
View
7 src/ulib/net/server/plugin/mod_scgi.cpp
@@ -124,6 +124,13 @@ int USCGIPlugIn::handlerInit()
(void) UServer_Base::senvironment->append(U_CONSTANT_TO_PARAM("SCGI=1\n"));
+ // NB: SCGI is NOT a static page...
+
+ if (UHTTP::valias == 0) UHTTP::valias = U_NEW(UVector<UString>(2U));
+
+ UHTTP::valias->push_back(*UHTTP::scgi_uri_mask);
+ UHTTP::valias->push_back(U_STRING_FROM_CONSTANT("/nostat"));
+
U_RETURN(U_PLUGIN_HANDLER_GO_ON);
}
View
7 src/ulib/net/server/plugin/mod_soap.cpp
@@ -64,6 +64,13 @@ int USoapPlugIn::handlerInit()
{
U_SRV_LOG("initialization of plugin success");
+ // NB: SOAP is NOT a static page...
+
+ if (UHTTP::valias == 0) UHTTP::valias = U_NEW(UVector<UString>(2U));
+
+ UHTTP::valias->push_back(U_STRING_FROM_CONSTANT("/soap"));
+ UHTTP::valias->push_back(U_STRING_FROM_CONSTANT("/nostat"));
+
goto end;
}
View
7 src/ulib/net/server/plugin/mod_tsa.cpp
@@ -61,6 +61,13 @@ int UTsaPlugIn::handlerInit()
{
U_SRV_LOG("initialization of plugin success");
+ // NB: TSA is NOT a static page...
+
+ if (UHTTP::valias == 0) UHTTP::valias = U_NEW(UVector<UString>(2U));
+
+ UHTTP::valias->push_back(U_STRING_FROM_CONSTANT("/tsa"));
+ UHTTP::valias->push_back(U_STRING_FROM_CONSTANT("/nostat"));
+
goto end;
}
View
942 src/ulib/net/server/server.cpp
@@ -102,20 +102,36 @@ time_t UServer_Base::last_timeout;
time_t UServer_Base::threshold_for_timeout;
uint32_t UServer_Base::start;
uint32_t UServer_Base::count;
+uint32_t UServer_Base::vplugin_size;
uint32_t UServer_Base::shared_data_add;
UString* UServer_Base::mod_name;
UString* UServer_Base::host;
UString* UServer_Base::senvironment;
+UString* UServer_Base::server;
+UString* UServer_Base::as_user;
+UString* UServer_Base::log_file;
+UString* UServer_Base::dh_file;
+UString* UServer_Base::cert_file;
+UString* UServer_Base::key_file;
+UString* UServer_Base::password;
+UString* UServer_Base::ca_file;
+UString* UServer_Base::ca_path;
+UString* UServer_Base::name_sock;
+UString* UServer_Base::IP_address;
+UString* UServer_Base::allow_IP;
+UString* UServer_Base::allow_IP_prv;
+UString* UServer_Base::document_root;
USocket* UServer_Base::socket;
UProcess* UServer_Base::proc;
UEventFd* UServer_Base::handler_inotify;
UEventTime* UServer_Base::ptime;
UServer_Base* UServer_Base::pthis;
-struct linger UServer_Base::lng = { 1, 0 };
+// struct linger UServer_Base::lng = { 1, 0 };
UVector<UString>* UServer_Base::vplugin_name;
-UClientImage_Base* UServer_Base::pindex;
-UClientImage_Base* UServer_Base::vClientImage;
+UVector<UString>* UServer_Base::vplugin_name_static;
+UClientImage_Base* UServer_Base::pClientIndex;
UClientImage_Base* UServer_Base::pClientImage;
+UClientImage_Base* UServer_Base::vClientImage;
UClientImage_Base* UServer_Base::eClientImage;
UVector<UIPAllow*>* UServer_Base::vallow_IP;
UVector<UIPAllow*>* UServer_Base::vallow_IP_prv;
@@ -241,7 +257,7 @@ class UClientThread : public UThread {
{
U_TRACE(0, "UClientThread::run()")
- while (UServer_Base::flag_loop) (void) UNotifier::waitForEvent(UServer_Base::ptime);
+ while (UServer_Base::flag_loop) UNotifier::waitForEvent(UServer_Base::ptime);
}
};
@@ -415,6 +431,21 @@ UServer_Base::UServer_Base(UFileConfig* cfg)
U_INTERNAL_ASSERT_EQUALS(pthis,0)
U_INTERNAL_ASSERT_EQUALS(senvironment,0)
+ server = U_NEW(UString);
+ as_user = U_NEW(UString);
+ log_file = U_NEW(UString);
+ dh_file = U_NEW(UString);
+ cert_file = U_NEW(UString);
+ key_file = U_NEW(UString);
+ password = U_NEW(UString);
+ ca_file = U_NEW(UString);
+ ca_path = U_NEW(UString);
+ name_sock = U_NEW(UString);
+ IP_address = U_NEW(UString);
+ allow_IP = U_NEW(UString);
+ allow_IP_prv = U_NEW(UString);
+ document_root = U_NEW(UString);
+
if (str_ENABLE_IPV6 == 0) str_allocate();
port = U_DEFAULT_PORT;
@@ -457,15 +488,14 @@ UServer_Base::~UServer_Base()
UClientImage_Base::initAfterGenericRead();
- if (vplugin)
- {
- delete vplugin;
- delete vplugin_name;
+ U_INTERNAL_ASSERT_POINTER(vplugin)
-# ifdef HAVE_MODULES
- UPlugIn<void*>::clear();
-# endif
- }
+ delete vplugin;
+ delete vplugin_name;
+
+#ifdef HAVE_MODULES
+ UPlugIn<void*>::clear();
+#endif
U_INTERNAL_ASSERT_EQUALS(handler_inotify,0)
@@ -473,7 +503,7 @@ UServer_Base::~UServer_Base()
UEventFd::fd = 0; // NB: to avoid delete itself...
- UNotifier::clear(preforked_num_kids == -1);
+ UNotifier::clear();
if (vClientImage)
{
@@ -518,7 +548,7 @@ UServer_Base::~UServer_Base()
delete socket;
#ifndef __MINGW32__
- if (as_user.empty() &&
+ if (as_user->empty() &&
isChild() == false)
{
u_need_root(false);
@@ -547,6 +577,21 @@ UServer_Base::~UServer_Base()
#ifdef USE_LIBSSL
if (UServices::CApath) delete UServices::CApath;
#endif
+
+ delete server;
+ delete as_user;
+ delete log_file;
+ delete dh_file;
+ delete cert_file;
+ delete key_file;
+ delete password;
+ delete ca_file;
+ delete ca_path;
+ delete name_sock;
+ delete IP_address;
+ delete allow_IP;
+ delete allow_IP_prv;
+ delete document_root;
}
void UServer_Base::loadConfigParam(UFileConfig& cfg)
@@ -604,12 +649,12 @@ void UServer_Base::loadConfigParam(UFileConfig& cfg)
// >1 - pool of serialized processes plus monitoring process
// --------------------------------------------------------------------------------------------------------------------------------------
- server = cfg[*str_SERVER];
- log_file = cfg[*str_LOG_FILE];
- allow_IP = cfg[*str_ALLOWED_IP];
- allow_IP_prv = cfg[*str_ALLOWED_IP_PRIVATE];
- name_sock = cfg[*str_SOCKET_NAME];
- IP_address = cfg[*str_IP_ADDRESS];
+ *server = cfg[*str_SERVER];
+ *log_file = cfg[*str_LOG_FILE];
+ *allow_IP = cfg[*str_ALLOWED_IP];
+ *allow_IP_prv = cfg[*str_ALLOWED_IP_PRIVATE];
+ *name_sock = cfg[*str_SOCKET_NAME];
+ *IP_address = cfg[*str_IP_ADDRESS];
port = cfg.readLong(*str_PORT, U_DEFAULT_PORT);
iBackLog = cfg.readLong(*str_LISTEN_BACKLOG, SOMAXCONN);
@@ -632,12 +677,12 @@ void UServer_Base::loadConfigParam(UFileConfig& cfg)
UClientImage_Base::setMsgWelcome(cfg[*str_MSG_WELCOME]);
#ifdef USE_LIBSSL
- dh_file = cfg[*str_DH_FILE];
- ca_file = cfg[*str_CA_FILE];
- ca_path = cfg[*str_CA_PATH];
- key_file = cfg[*str_KEY_FILE];
- password = cfg[*str_PASSWORD];
- cert_file = cfg[*str_CERT_FILE];
+ *dh_file = cfg[*str_DH_FILE];
+ *ca_file = cfg[*str_CA_FILE];
+ *ca_path = cfg[*str_CA_PATH];
+ *key_file = cfg[*str_KEY_FILE];
+ *password = cfg[*str_PASSWORD];
+ *cert_file = cfg[*str_CERT_FILE];
verify_mode = cfg.readLong(*str_VERIFY_MODE);
#endif
@@ -670,27 +715,27 @@ void UServer_Base::loadConfigParam(UFileConfig& cfg)
// open log
- if (log_file.empty() == false) log = U_NEW(ULog(log_file, cfg.readLong(*str_LOG_FILE_SZ), "(pid %P) %10D> "));
+ if (log_file->empty() == false) log = U_NEW(ULog(*log_file, cfg.readLong(*str_LOG_FILE_SZ), "(pid %P) %10D> "));
// If you want the webserver to run as a process of a defined user, you can do it.
// For the change of user to work, it's necessary to execute the server with root privileges.
// If it's started by a user that that doesn't have root privileges, this step will be omitted.
- as_user = cfg[*str_RUN_AS_USER];
+ *as_user = cfg[*str_RUN_AS_USER];
- if (as_user.empty() == false)
+ if (as_user->empty() == false)
{
if (UServices::isSetuidRoot() == false)
{
U_SRV_LOG("The \"RUN_AS_USER\" directive makes sense only if the master process runs with super-user privileges, ignored");
- as_user.clear();
+ as_user->clear();
}
else
{
- U_INTERNAL_ASSERT(as_user.isNullTerminated())
+ U_INTERNAL_ASSERT(as_user->isNullTerminated())
- struct passwd* pw = (struct passwd*) U_SYSCALL(getpwnam, "%S", as_user.data());
+ struct passwd* pw = (struct passwd*) U_SYSCALL(getpwnam, "%S", as_user->data());
if (pw && pw->pw_dir) u_setHOME(pw->pw_dir);
}
@@ -698,49 +743,50 @@ void UServer_Base::loadConfigParam(UFileConfig& cfg)
// DOCUMENT_ROOT: The directory out of which you will serve your documents
- document_root = cfg[*str_DOCUMENT_ROOT];
+ *document_root = cfg[*str_DOCUMENT_ROOT];
- if (document_root.empty() ||
- document_root.equal(U_CONSTANT_TO_PARAM(".")))
+ if (document_root->empty() ||
+ document_root->equal(U_CONSTANT_TO_PARAM(".")))
{
- (void) document_root.replace(u_cwd, u_cwd_len);
+ (void) document_root->replace(u_cwd, u_cwd_len);
}
else
{
- U_INTERNAL_ASSERT(document_root.isNullTerminated())
+ U_INTERNAL_ASSERT(document_root->isNullTerminated())
- char c = document_root.c_char(0);
+ char c = document_root->c_char(0);
if (c == '~' ||
c == '$')
{
- document_root = UStringExt::expandPath(document_root, 0);
+ *document_root = UStringExt::expandPath(*document_root, 0);
- if (document_root.empty())
+ if (document_root->empty())
{
- U_ERROR("var DOCUMENT_ROOT %S expansion FAILED. Going down...", document_root.data());
+ U_ERROR("var DOCUMENT_ROOT %S expansion FAILED. Going down...", document_root->data());
}
}
- (void) u_canonicalize_pathname(document_root.data());
+ (void) u_canonicalize_pathname(document_root->data());
- U_INTERNAL_DUMP("document_root = %S", document_root.data())
+ U_INTERNAL_DUMP("document_root = %S", document_root->data())
}
- if (document_root.first_char() == '.') document_root = UFile::getRealPath(document_root.data());
+ if (document_root->first_char() == '.') *document_root = UFile::getRealPath(document_root->data());
- if (UFile::chdir(document_root.data(), false) == false)
+ if (UFile::chdir(document_root->data(), false) == false)
{
- U_ERROR("chdir to working directory (DOCUMENT_ROOT) %S FAILED. Going down...", document_root.data());
+ U_ERROR("chdir to working directory (DOCUMENT_ROOT) %S FAILED. Going down...", document_root->data());
}
U_SRV_LOG("Working directory (DOCUMENT_ROOT) changed to %S", u_cwd);
// load plugin modules and call server-wide hooks handlerConfig()...
- UString plugin_dir = cfg[*str_PLUGIN_DIR];
+ UString plugin_dir = cfg[*str_PLUGIN_DIR],
+ plugin_list = cfg[*str_PLUGIN];
- if (loadPlugins(plugin_dir, cfg[*str_PLUGIN], &cfg) == U_PLUGIN_HANDLER_ERROR)
+ if (loadPlugins(plugin_dir, plugin_list, &cfg) == U_PLUGIN_HANDLER_ERROR)
{
U_ERROR("Plugins load FAILED. Going down...");
}
@@ -755,165 +801,174 @@ U_NO_EXPORT void UServer_Base::loadStaticLinkedModules(const char* name)
{
U_TRACE(0, "UServer_Base::loadStaticLinkedModules(%S)", name)
+ U_INTERNAL_ASSERT_POINTER(vplugin_name)
+ U_INTERNAL_ASSERT_MAJOR(vplugin_size, 0)
+
UString x(name);
- UServerPlugIn* _plugin = 0;
-#ifdef U_STATIC_HANDLER_RPC
- if (x.equal(U_CONSTANT_TO_PARAM("mod_rpc"))) { _plugin = U_NEW(URpcPlugIn); goto next; }
-#endif
-#ifdef U_STATIC_HANDLER_SHIB
- if (x.equal(U_CONSTANT_TO_PARAM("mod_shib"))) { _plugin = U_NEW(UShibPlugIn); goto next; }
-#endif
-#ifdef U_STATIC_HANDLER_ECHO
- if (x.equal(U_CONSTANT_TO_PARAM("mod_echo"))) { _plugin = U_NEW(UEchoPlugIn); goto next; }
-#endif
-#ifdef U_STATIC_HANDLER_STREAM
- if (x.equal(U_CONSTANT_TO_PARAM("mod_stream"))) { _plugin = U_NEW(UStreamPlugIn); goto next; }
-#endif
-#ifdef U_STATIC_HANDLER_SOCKET
- if (x.equal(U_CONSTANT_TO_PARAM("mod_socket"))) { _plugin = U_NEW(UWebSocketPlugIn); goto next; }
-#endif
-#ifdef U_STATIC_HANDLER_SCGI
- if (x.equal(U_CONSTANT_TO_PARAM("mod_scgi"))) { _plugin = U_NEW(USCGIPlugIn); goto next; }
-#endif
-#ifdef U_STATIC_HANDLER_FCGI
- if (x.equal(U_CONSTANT_TO_PARAM("mod_fcgi"))) { _plugin = U_NEW(UFCGIPlugIn); goto next; }
-#endif
-#ifdef U_STATIC_HANDLER_GEOIP
- if (x.equal(U_CONSTANT_TO_PARAM("mod_geoip"))) { _plugin = U_NEW(UGeoIPPlugIn); goto next; }
-#endif
-#ifdef U_STATIC_HANDLER_PROXY
- if (x.equal(U_CONSTANT_TO_PARAM("mod_proxy"))) { _plugin = U_NEW(UProxyPlugIn); goto next; }
-#endif
-#ifdef U_STATIC_HANDLER_SOAP
- if (x.equal(U_CONSTANT_TO_PARAM("mod_soap"))) { _plugin = U_NEW(USoapPlugIn); goto next; }
-#endif
-#ifdef U_STATIC_HANDLER_SSI
- if (x.equal(U_CONSTANT_TO_PARAM("mod_ssi"))) { _plugin = U_NEW(USSIPlugIn); goto next; }
-#endif
-#ifdef U_STATIC_HANDLER_TSA
- if (x.equal(U_CONSTANT_TO_PARAM("mod_tsa"))) { _plugin = U_NEW(UTsaPlugIn); goto next; }
-#endif
-#ifdef U_STATIC_HANDLER_NOCAT
- if (x.equal(U_CONSTANT_TO_PARAM("mod_nocat"))) { _plugin = U_NEW(UNoCatPlugIn); goto next; }
-#endif
-#ifdef U_STATIC_HANDLER_HTTP
- if (x.equal(U_CONSTANT_TO_PARAM("mod_http"))) { _plugin = U_NEW(UHttpPlugIn); goto next; }
-#endif
+ if (vplugin_name->find(x) != U_NOT_FOUND) // NB: we load only the plugin that we want from configuration (PLUGIN var)...
+ {
+ UServerPlugIn* _plugin = 0;
- goto next;
+# ifdef U_STATIC_HANDLER_RPC
+ if (x.equal(U_CONSTANT_TO_PARAM("mod_rpc"))) { _plugin = U_NEW(URpcPlugIn); goto next; }
+# endif
+# ifdef U_STATIC_HANDLER_SHIB
+ if (x.equal(U_CONSTANT_TO_PARAM("mod_shib"))) { _plugin = U_NEW(UShibPlugIn); goto next; }
+# endif
+# ifdef U_STATIC_HANDLER_ECHO
+ if (x.equal(U_CONSTANT_TO_PARAM("mod_echo"))) { _plugin = U_NEW(UEchoPlugIn); goto next; }
+# endif
+# ifdef U_STATIC_HANDLER_STREAM
+ if (x.equal(U_CONSTANT_TO_PARAM("mod_stream"))) { _plugin = U_NEW(UStreamPlugIn); goto next; }
+# endif
+# ifdef U_STATIC_HANDLER_SOCKET
+ if (x.equal(U_CONSTANT_TO_PARAM("mod_socket"))) { _plugin = U_NEW(UWebSocketPlugIn); goto next; }
+# endif
+# ifdef U_STATIC_HANDLER_SCGI
+ if (x.equal(U_CONSTANT_TO_PARAM("mod_scgi"))) { _plugin = U_NEW(USCGIPlugIn); goto next; }
+# endif
+# ifdef U_STATIC_HANDLER_FCGI
+ if (x.equal(U_CONSTANT_TO_PARAM("mod_fcgi"))) { _plugin = U_NEW(UFCGIPlugIn); goto next; }
+# endif
+# ifdef U_STATIC_HANDLER_GEOIP
+ if (x.equal(U_CONSTANT_TO_PARAM("mod_geoip"))) { _plugin = U_NEW(UGeoIPPlugIn); goto next; }
+# endif
+# ifdef U_STATIC_HANDLER_PROXY
+ if (x.equal(U_CONSTANT_TO_PARAM("mod_proxy"))) { _plugin = U_NEW(UProxyPlugIn); goto next; }
+# endif
+# ifdef U_STATIC_HANDLER_SOAP
+ if (x.equal(U_CONSTANT_TO_PARAM("mod_soap"))) { _plugin = U_NEW(USoapPlugIn); goto next; }
+# endif
+# ifdef U_STATIC_HANDLER_SSI
+ if (x.equal(U_CONSTANT_TO_PARAM("mod_ssi"))) { _plugin = U_NEW(USSIPlugIn); goto next; }
+# endif
+# ifdef U_STATIC_HANDLER_TSA
+ if (x.equal(U_CONSTANT_TO_PARAM("mod_tsa"))) { _plugin = U_NEW(UTsaPlugIn); goto next; }
+# endif
+# ifdef U_STATIC_HANDLER_NOCAT
+ if (x.equal(U_CONSTANT_TO_PARAM("mod_nocat"))) { _plugin = U_NEW(UNoCatPlugIn); goto next; }
+# endif
+# ifdef U_STATIC_HANDLER_HTTP
+ if (x.equal(U_CONSTANT_TO_PARAM("mod_http"))) { _plugin = U_NEW(UHttpPlugIn); goto next; }
+# endif
+#if defined(U_STATIC_HANDLER_RPC) || defined(U_STATIC_HANDLER_SHIB) || defined(U_STATIC_HANDLER_ECHO) || \
+ defined(U_STATIC_HANDLER_STREAM) || defined(U_STATIC_HANDLER_SOCKET) || defined(U_STATIC_HANDLER_SCGI) || \
+ defined(U_STATIC_HANDLER_FCGI) || defined(U_STATIC_HANDLER_GEOIP) || defined(U_STATIC_HANDLER_PROXY) || \
+ defined(U_STATIC_HANDLER_SOAP) || defined(U_STATIC_HANDLER_SSI) || defined(U_STATIC_HANDLER_TSA) || \
+ defined(U_STATIC_HANDLER_NOCAT) || defined(U_STATIC_HANDLER_HTTP)
next:
- U_INTERNAL_ASSERT_POINTER(_plugin)
-
- vplugin_name->push_back(x);
- vplugin->push_back(_plugin);
+#endif
+ if (_plugin)
+ {
+ vplugin->push_back(_plugin);
+ vplugin_name_static->push_back(x);
- if (isLog()) ULog::log("[%s] Link of static plugin ok\n", name);
+ if (isLog()) ULog::log("[%s] Link of static plugin ok\n", name);
+ }
+ }
}
int UServer_Base::loadPlugins(UString& plugin_dir, const UString& plugin_list, UFileConfig* cfg)
{
U_TRACE(0, "UServer_Base::loadPlugins(%.*S,%.*S,%p)", U_STRING_TO_TRACE(plugin_dir), U_STRING_TO_TRACE(plugin_list), cfg)
- UString name;
- UVector<UString> vec;
- uint32_t i, length, pos;
- UServerPlugIn* _plugin = 0;
- int result = U_PLUGIN_HANDLER_ERROR;
-
- vplugin_name = U_NEW(UVector<UString>(10U));
- vplugin = U_NEW(UVector<UServerPlugIn*>(10U));
-
- if (plugin_list.empty() == false)
+#ifdef HAVE_MODULES
+ if (plugin_dir.empty() == false)
{
-# ifdef HAVE_MODULES
- if (plugin_dir.empty() == false)
- {
- // NB: we can't use relativ path because after we call chdir()...
-
- if (plugin_dir.first_char() == '.')
- {
- U_INTERNAL_ASSERT(plugin_dir.isNullTerminated())
+ // NB: we can't use relativ path because after we call chdir()...
- plugin_dir = UFile::getRealPath(plugin_dir.data());
- }
+ if (plugin_dir.first_char() == '.')
+ {
+ U_INTERNAL_ASSERT(plugin_dir.isNullTerminated())
- UPlugIn<void*>::setPluginDirectory(plugin_dir.c_strdup());
+ plugin_dir = UFile::getRealPath(plugin_dir.data());
}
-# endif
- /* I do know that to include code in the middle of a function is hacky and dirty,
- * but this is the best solution that I could figure out. If you have some idea to
- * clean it up, please, don't hesitate and let me know.
- */
+ UPlugIn<void*>::setPluginDirectory(plugin_dir.c_strdup());
+ }
+#endif
-# include "plugin/loader.autoconf.cpp"
+ vplugin = U_NEW(UVector<UServerPlugIn*>(10U));
+ vplugin_name = U_NEW(UVector<UString>(10U));
+ vplugin_name_static = U_NEW(UVector<UString>(20U));
- bool bnostatic = vplugin->empty();
+ UString name;
+ uint32_t i, pos;
+ UServerPlugIn* _plugin;
+ int result = U_PLUGIN_HANDLER_ERROR;
- for (i = 0, length = vec.split(plugin_list); i < length; ++i)
- {
- name = vec[i];
- pos = vplugin_name->find(name);
+ // NB: we don't want to use substr() because of dependency from config var PLUGIN...
- U_INTERNAL_DUMP("i = %u name = %.*S pos = %u", i, U_STRING_TO_TRACE(name), pos)
+ if (plugin_list.empty()) vplugin_size = 1, vplugin_name->push(U_CONSTANT_TO_PARAM("mod_http"));
+ else vplugin_size = vplugin_name->split( U_STRING_TO_PARAM(plugin_list));
- if (pos == U_NOT_FOUND)
- {
-# ifdef HAVE_MODULES
- _plugin = UPlugIn<UServerPlugIn*>::create(U_STRING_TO_PARAM(name));
-# endif
+ /* I do know that to include code in the middle of a function is hacky and dirty,
+ * but this is the best solution that I could figure out. If you have some idea to
+ * clean it up, please, don't hesitate and let me know.
+ */
- if (_plugin == 0)
- {
- U_SRV_LOG("Load of plugin '%.*s' FAILED", U_STRING_TO_TRACE(name));
+# include "plugin/loader.autoconf.cpp"
- goto end;
- }
+ for (i = 0; i < vplugin_size; ++i)
+ {
+ name = vplugin_name->at(i);
+ pos = vplugin_name_static->find(name);
+ _plugin = 0;
- name.duplicate();
+ U_INTERNAL_DUMP("i = %u pos = %u name = %.*S", i, pos, U_STRING_TO_TRACE(name))
- vplugin->push_back(_plugin);
- vplugin_name->push_back(name);
+ if (pos == U_NOT_FOUND)
+ {
+# ifdef HAVE_MODULES
+ _plugin = UPlugIn<UServerPlugIn*>::create(U_STRING_TO_PARAM(name));
+# endif
- if (isLog()) ULog::log("[%.*s] Load of plugin success\n", U_STRING_TO_TRACE(name));
- }
- else
+ if (_plugin == 0)
{
- U_INTERNAL_ASSERT_EQUALS(bnostatic, false)
+ U_SRV_LOG("Load of plugin '%.*s' FAILED", U_STRING_TO_TRACE(name));
- if (pos != i)
- {
- vplugin->swap(pos, i);
- vplugin_name->swap(pos, i);
- }
+ goto end;
}
- U_INTERNAL_ASSERT_EQUALS(vplugin->size(), vplugin_name->size())
+ vplugin->insert(i, _plugin);
+ vplugin_name_static->insert(i, name);
+
+ if (isLog()) ULog::log("[%.*s] Load of plugin success\n", U_STRING_TO_TRACE(name));
}
}
+ U_INTERNAL_ASSERT_MAJOR(vplugin_size, 0)
+ U_INTERNAL_ASSERT_EQUALS(vplugin->size(), vplugin_size)
+ U_INTERNAL_ASSERT_EQUALS(*vplugin_name, *vplugin_name_static)
+
+ delete vplugin_name_static;
+
if (cfg)
{
- for (i = 0, length = vplugin->size(); i < length; ++i)
- {
- name = vplugin_name->at(i);
+ // NB: we load configuration in reverse order respect to config var PLUGIN...
- if (cfg->searchForObjectStream(U_STRING_TO_PARAM(name)))
- {
- cfg->clear();
+ i = vplugin_size;
- if (isLog()) mod_name->snprintf("[%.*s] ", U_STRING_TO_TRACE(name));
+ do {
+ name = vplugin_name->at(--i);
- _plugin = vplugin->at(i);
- result = _plugin->handlerConfig(*cfg);
+ if (cfg->searchForObjectStream(U_STRING_TO_PARAM(name)) == false) continue;
- cfg->reset();
+ cfg->clear();
- if (result != U_PLUGIN_HANDLER_GO_ON) goto end;
- }
+ if (isLog()) mod_name->snprintf("[%.*s] ", U_STRING_TO_TRACE(name));
+
+ _plugin = vplugin->at(i);
+
+ result = _plugin->handlerConfig(*cfg);
+
+ cfg->reset();
+
+ if (result != U_PLUGIN_HANDLER_GO_ON) goto end;
}
+ while (i);
}
result = U_PLUGIN_HANDLER_FINISHED;
@@ -926,44 +981,85 @@ int UServer_Base::loadPlugins(UString& plugin_dir, const UString& plugin_list, U
// manage plugin handler hooks...
-#define U_PLUGIN_HANDLER(xxx) \
- \
-int U