1
0
mirror of https://github.com/stefanocasazza/ULib.git synced 2025-09-28 19:05:55 +08:00

completion management dedicated server process

This commit is contained in:
stefanocasazza 2015-02-04 19:45:56 +01:00
parent c03d8716bb
commit 424c0fc222
46 changed files with 4062 additions and 4062 deletions

View File

@ -101,6 +101,7 @@ extern U_EXPORT int runDynamicPage_wi_auth(UClientImage_Base* client_image);
POST_ENTRY(admin_execute_recovery),
POST_ENTRY(admin_recovery),
POST_ENTRY(admin_view_user),
POST_ENTRY(info),
POST_ENTRY(login_request),
POST_ENTRY(login_request_IdP),
POST_ENTRY(password),

View File

@ -68,6 +68,7 @@ static UHTTP::service_info POST_table[] = { // NB: the table must be ordered alp
POST_ENTRY(admin_execute_recovery),
POST_ENTRY(admin_recovery),
POST_ENTRY(admin_view_user),
POST_ENTRY(info),
POST_ENTRY(login_request),
POST_ENTRY(login_request_IdP),
POST_ENTRY(password),

View File

@ -126,8 +126,12 @@ loop:
if (result)
{
if (outpath.empty()) (void) write(1, U_STRING_TO_PARAM(result));
else UFile::writeTo(outpath, result);
# ifdef USE_LIBZ
if (UStringExt::isGzip(result)) result = UStringExt::gunzip(result);
# endif
if (outpath) UFile::writeTo(outpath, result);
else (void) write(1, U_STRING_TO_PARAM(result));
}
if (queue_time)

View File

@ -27,6 +27,7 @@
class UHTTP;
class UHttpPlugIn;
class UFileConfig;
class UNoCatPlugIn;
template <class T> class UVector;
template <class T> class UOrmTypeHandler;
@ -415,7 +416,7 @@ public:
void clear() // erase all element
{
U_TRACE(0, "UVector<T*>::clear()")
U_TRACE(0+256, "UVector<T*>::clear()")
U_CHECK_MEMORY
@ -1202,6 +1203,8 @@ public:
protected:
uint32_t loadFromData(const char* start, uint32_t size);
UStringRep* getStringRep(uint32_t pos) { return UVector<UStringRep*>::at(pos); }
private:
static void mksort(UStringRep** a, int n, int depth);
bool _isEqual(UVector<UString>& vec, bool ignore_case);
@ -1217,6 +1220,7 @@ private:
friend class UHTTP;
friend class UHttpPlugIn;
friend class UFileConfig;
friend class UNoCatPlugIn;
};
#endif

View File

@ -973,6 +973,10 @@ public:
if (result &&
U_IS_HTTP_ERROR(u_http_info.nResponseCode) == false)
{
# ifdef USE_LIBZ
if (UStringExt::isGzip(result)) result = UStringExt::gunzip(result);
# endif
UVector<UString> vec(result);
for (uint32_t i = 0, n = vec.size(); i < n; i += 5)
@ -2735,6 +2739,10 @@ static bool askNodogToLogoutUser(const UString& _ip, const UString& _mac, bool b
U_INTERNAL_ASSERT(U_IS_HTTP_SUCCESS(u_http_info.nResponseCode))
# ifdef USE_LIBZ
if (UStringExt::isGzip(result)) result = UStringExt::gunzip(result);
# endif
if (U_STRING_FIND(result, 0, "DENY") == U_NOT_FOUND)
{
U_LOGGER("*** USER STATUS NOT DENY: UID(%.*s) IP(%.*s) MAC(%.*s) AP(%.*s) ***",
@ -2757,7 +2765,7 @@ static bool askNodogToLogoutUser(const UString& _ip, const UString& _mac, bool b
U_STRING_TO_TRACE(*UClientImage_Base::request_uri),
U_STRING_TO_TRACE(*uid), U_STRING_TO_TRACE(_ip), U_STRING_TO_TRACE(_mac), U_STRING_TO_TRACE(*ap_address));
(void) client->sendRequestAsync(*url_nodog, false, log_msg, file_WARNING->getFd());
(void) client->sendGETRequestAsync(*url_nodog, false, log_msg, file_WARNING->getFd());
U_RETURN(false);
}
@ -3491,7 +3499,12 @@ static void GET_admin_export_view_using_historical_as_csv()
U_TRACE(5, "::GET_admin_export_view_using_historical_as_csv()")
if (UServer_Base::bssl == false) USSIPlugIn::setBadRequest();
else USSIPlugIn::setAlternativeResponse(file_UTILIZZO->_getContent());
else
{
UString body = file_UTILIZZO->_getContent();
USSIPlugIn::setAlternativeResponse(body);
}
}
static void GET_admin_historical_statistics_login()
@ -3784,6 +3797,10 @@ static void GET_error_ap()
U_ASSERT( vuid->empty())
U_ASSERT(vallow_IP_user->empty())
# ifdef USE_LIBZ
if (UStringExt::isGzip(result)) result = UStringExt::gunzip(result);
# endif
UIPAllow* elem;
UVector<UString> vec(result);
@ -4029,9 +4046,20 @@ static void GET_get_config()
UFileConfig cfg(_body, true);
if (cfg.processData()) _body = cfg.getData();
UHTTP::mime_index = U_know;
if (cfg.processData())
{
_body = cfg.getData();
# ifdef USE_LIBZ
if (U_http_is_accept_gzip &&
_body.size() > U_MIN_SIZE_FOR_DEFLATE)
{
_body = UStringExt::deflate(_body, 1);
}
# endif
}
}
}
}
@ -4253,6 +4281,17 @@ next:
if (vec.empty() == false) askNodogToLogoutUser(vec, false);
}
static void POST_info()
{
U_TRACE(5, "::POST_info()")
#ifdef USE_LIBZ
if (UStringExt::isGzip(*UClientImage_Base::body)) *UClientImage_Base::body = UStringExt::gunzip(*UClientImage_Base::body);
#endif
GET_info();
}
static void GET_logged()
{
U_TRACE(5, "::GET_logged()")
@ -4651,6 +4690,10 @@ static void GET_login_validate()
if (result &&
U_IS_HTTP_ERROR(u_http_info.nResponseCode) == false)
{
# ifdef USE_LIBZ
if (UStringExt::isGzip(result)) result = UStringExt::gunzip(result);
# endif
UVector<UString> vec1(result);
for (uint32_t i = 0, n = vec1.size(); i < n; i += 5)

View File

@ -14,20 +14,21 @@
#ifndef ULIB_CHTTP_H
#define ULIB_CHTTP_H 1
/* -------------------------------------------------------------------------------------------------------
_ _ _
| |__ | |_| |_ _ __
| '_ \| __| __| '_ \
| | | | |_| |_| |_) |
|_| |_|\__|\__| .__/
|_|
---------------------------------------------------------------------------------------------------------
HTTP message handler
The status code is a three-digit integer, and the first digit identifies the general category of response
---------------------------------------------------------------------------------------------------------
*/
/**
* -------------------------------------------------------------------------------------------------------
* _ _ _
* | |__ | |_| |_ _ __
* | '_ \| __| __| '_ \
* | | | | |_| |_| |_) |
* |_| |_|\__|\__| .__/
* |_|
*
* ---------------------------------------------------------------------------------------------------------
* HTTP message handler
*
* The status code is a three-digit integer, and the first digit identifies the general category of response
* ---------------------------------------------------------------------------------------------------------
*/
/* 1xx indicates an informational message only */
#define HTTP_CONTINUE 100
@ -43,7 +44,7 @@
#define HTTP_RESET 205
#define HTTP_PARTIAL 206
#define HTTP_STATUS_207 207 /* "Multi-Status" */
#define HTTP_OPTIONS_RESPONSE 222 /* internal use, not standard */
#define HTTP_OPTIONS_RESPONSE 222 /* only internal use, not standard */
/* 3xx redirects the client to another URL */
#define HTTP_MULT_CHOICE 300
@ -159,7 +160,7 @@ typedef struct uhttpinfo {
#define U_http_ip_client_len u_http_info.flag[ 8]
#define U_http_websocket_len u_http_info.flag[ 9]
#define U_http2_settings_len u_http_info.flag[10]
#define U_http_is_accept_gzip u_http_info.flag[11] /* NB: this pos is locked by mod_proxy (UHttpClient_Base::u_http_info_save)... */
#define U_http_is_accept_gzip u_http_info.flag[11] /* NB: this position(11) is locked by mod_proxy (UHttpClient_Base::u_http_info_save)... */
#define U_http_content_type_len u_http_info.flag[12]
#define U_http_is_request_nostat u_http_info.flag[13]
#define U_http_accept_language_len u_http_info.flag[14]
@ -205,9 +206,6 @@ typedef struct uhttpmethodtype {
uint32_t len;
} uhttpmethodtype;
#define U_HTTP_METHOD_TO_PARAM u_http_method_list[U_http_method_num].name, u_http_method_list[U_http_method_num].len
#define U_HTTP_METHOD_TO_TRACE u_http_method_list[U_http_method_num].len, u_http_method_list[U_http_method_num].name
#define U_HTTP_URI_TO_PARAM u_http_info.uri, u_http_info.uri_len
#define U_HTTP_URI_TO_TRACE u_http_info.uri_len, u_http_info.uri
@ -249,6 +247,12 @@ typedef struct uhttpmethodtype {
#define U_HTTP_ACCEPT_LANGUAGE_TO_PARAM u_http_info.accept_language, U_http_accept_language_len
#define U_HTTP_ACCEPT_LANGUAGE_TO_TRACE U_http_accept_language_len, u_http_info.accept_language
#define U_HTTP_METHOD_TO_PARAM U_HTTP_METHOD_NUM_TO_PARAM(U_http_method_num)
#define U_HTTP_METHOD_TO_TRACE U_HTTP_METHOD_NUM_TO_TRACE(U_http_method_num)
#define U_HTTP_METHOD_NUM_TO_PARAM(num) u_http_method_list[num].name, u_http_method_list[num].len
#define U_HTTP_METHOD_NUM_TO_TRACE(num) u_http_method_list[num].len, u_http_method_list[num].name
/**
* The hostname of your server from header's request.
* The difference between U_HTTP_HOST_.. and U_HTTP_VHOST_.. is that

View File

@ -24,6 +24,7 @@ class UProxyPlugIn;
class UNoCatPlugIn;
class UServer_Base;
class UClient_Base;
class UHttpClient_Base;
class UClientImage_Base;
// Logging is the process of recording application actions and state to a secondary interface
@ -157,8 +158,8 @@ protected:
static void startup();
static void initStaticDate();
static void _updateStaticDate(char* ptr, int which);
static void logResponse(const UString& data, const char* name, const char* format, ...);
static void log(const struct iovec* iov, const char* name, const char* type, int ncount, const char* pipeline, const char* format, ...);
static void logResponse(const UString& data, const char* name, const char* format, ...);
static void log(const struct iovec* iov, const char* name, const char* type, int ncount, const char* msg, uint32_t msg_len, const char* format, ...);
static void updateStaticDate(char* ptr, int which)
{
@ -194,6 +195,7 @@ private:
friend class UNoCatPlugIn;
friend class UServer_Base;
friend class UClient_Base;
friend class UHttpClient_Base;
friend class UClientImage_Base;
};

View File

@ -155,7 +155,6 @@ public:
bool connect();
void clearData();
bool readHTTPResponse();
bool readResponse(uint32_t count = U_SINGLE_READ);
bool sendRequest(const UString& req, bool bread_response);
@ -178,11 +177,9 @@ public:
// Very simple RPC-like layer
//
// Requests and responses are build of little packets each containing a 4-byte ascii token, an 8-byte hex value or length,
// and optionally data corresponding to the length.
// and optionally data corresponding to the length
// -----------------------------------------------------------------------------------------------------------------------
bool readRPCResponse();
// Transmit token name (4 characters) and value (32-bit int, as 8 hex characters)
bool sendTokenInt(const char* token, uint32_t value)
@ -230,7 +227,9 @@ protected:
static bool log_shared_with_server, bIPv6;
bool connectServer();
bool readHTTPResponse();
bool setUrl(const UString& url); // NB: return if it has modified host or port...
bool sendRequest(bool bread_response);
#ifdef USE_LIBSSL

View File

@ -125,7 +125,11 @@ public:
// ASYNC MODE (it creates a copy of itself, return pid child if parent)
int sendRequestAsync(const UString& url, bool bqueue = true, const char* log_msg = 0, int log_fd = -1);
int sendGETRequestAsync(const UString& _url, bool bqueue, const char* log_msg, int log_fd = -1)
{ method_num = 0; return sendRequestAsync(_url, bqueue, log_msg, log_fd); }
int sendPOSTRequestAsync(const UString& _body, const UString& _url, bool bqueue, const char* log_msg, int log_fd = -1)
{ body = _body; method_num = 2; return sendRequestAsync(_url, bqueue, log_msg, log_fd); }
// QUEUE MODE
@ -153,9 +157,10 @@ protected:
static struct uhttpinfo u_http_info_save;
void parseRequest();
void composeRequest();
bool sendRequestEngine();
void parseRequest(uint32_t n = 3);
void composeRequest(const char* content_type = 0);
int sendRequestAsync(const UString& url, bool bqueue, const char* log_msg, int log_fd);
// Add the MIME-type headers to the request for HTTP server
@ -163,7 +168,7 @@ protected:
const char* uri, uint32_t uri_len, const char* extension, const char* content_type = 0);
// In response to a HTTP_UNAUTHORISED response from the HTTP server, this function will attempt
// to generate an Authentication header to satisfy the server.
// to generate an Authentication header to satisfy the server
bool createAuthorizationHeader();
int checkResponse(int& redirectCount);

View File

@ -17,6 +17,8 @@
#include <ulib/net/client/client.h>
#include <ulib/net/rpc/rpc_encoder.h>
class URDBClient_Base;
class U_EXPORT URPCClient_Base : public UClient_Base {
public:
@ -30,9 +32,9 @@ public:
UString request = URPCMethod::encoder->encodeMethodCall(method, UString::getStringNull());
if (UClient_Base::sendRequest(request, false) &&
UClient_Base::readRPCResponse() &&
UClient_Base::buffer.equal(U_CONSTANT_TO_PARAM("DONE")))
if (sendRequest(request, false) &&
readResponse(socket, buffer, response) &&
buffer.equal(U_CONSTANT_TO_PARAM("DONE")))
{
U_RETURN(true);
}
@ -64,6 +66,31 @@ protected:
delete URPCMethod::encoder;
}
static bool readResponse(USocket* sk, UString& buffer, UString& response)
{
U_TRACE(0, "URPCClient_Base::readResponse(%p,%.*S,%.*S)", sk, U_STRING_TO_TRACE(buffer), U_STRING_TO_TRACE(response))
uint32_t rstart = 0;
// NB: we force for U_SUBSTR_INC_REF case (string can be referenced more)...
buffer.setEmptyForce();
response.setEmptyForce();
if (URPC::readTokenString(sk, 0, buffer, rstart, response))
{
// NB: we force for U_SUBSTR_INC_REF case (string can be referenced more)...
buffer.size_adjust_force(U_TOKEN_NM);
}
U_INTERNAL_DUMP("buffer = %.*S response = %.*S)", U_STRING_TO_TRACE(buffer), U_STRING_TO_TRACE(response))
if (buffer) U_RETURN(true);
U_RETURN(false);
}
private:
#ifdef U_COMPILER_DELETE_MEMBERS
URPCClient_Base(const URPCClient_Base&) = delete;
@ -72,6 +99,8 @@ private:
URPCClient_Base(const URPCClient_Base&) : UClient_Base(0) {}
URPCClient_Base& operator=(const URPCClient_Base&) { return *this; }
#endif
friend class URDBClient_Base;
};
template <class Socket> class U_EXPORT URPCClient : public URPCClient_Base {

View File

@ -181,11 +181,11 @@ protected:
static UString* peer_present_in_arp_cache;
static UVector<Url*>* vauth_url;
static UVector<Url*>* vinfo_url;
static UVector<UString>* vauth;
static UVector<UString>* vauth_ip;
static UVector<UString>* openlist;
static UVector<UString>* varp_cache;
static UVector<UString>* vinfo_data;
static UVector<UIPAddress*>** vaddr;
static UHttpClient<UTCPSocket>* client;
static UHashMap<UModNoCatPeer*>* peers;
@ -210,26 +210,41 @@ protected:
// VARIE
static void getTraffic();
static void setNewPeer();
static void checkSystem();
static void checkOldPeer();
static void creatNewPeer();
static bool creatNewPeer(uint32_t index_AUTH);
static void preallocatePeers() { U_NEW_VECTOR_ULIB_OBJECT(peers_preallocate, num_peers_preallocate, UModNoCatPeer, 0); }
static bool checkFirewall();
static bool preallocatePeersFault();
static bool checkFirewall();
static uint32_t checkFirewall(UString& output);
static uint32_t getIndexAUTH(const char* ip_address) __pure;
static void checkSystem();
static void deny(bool disconnected);
static void executeCommand(int type);
static void addPeerInfo(time_t logout);
static bool getPeer(uint32_t i) __pure;
static void uploadFileToPortal(UFile& file);
static bool creatNewPeer(uint32_t index_AUTH);
static void sendInfoData(uint32_t index_AUTH);
static bool getPeerFromMAC(const UString& mac);
static bool checkAuthMessage(const UString& msg);
static void setStatusContent(const UString& label);
static void setHTTPResponse(const UString& content);
static void notifyAuthOfUsersInfo(uint32_t index_AUTH);
static bool getPeerStatus(UStringRep* key, void* value);
static bool checkPeerInfo(UStringRep* key, void* value);
static bool checkPeerStatus(UStringRep* key, void* value);
static bool getPeerListInfo(UStringRep* key, void* value);
static void setRedirectLocation(const UString& redirect, const Url& auth);
static void permit(const UString& UserDownloadRate, const UString& UserUploadRate);
static void sendMsgToPortal(uint32_t index_AUTH, const UString& msg, UString* poutput);
static void setFireWallCommand(UCommand& cmd, const UString& script, const UString& mac, const UString& ip);
static uint32_t checkFirewall(UString& output);
static uint32_t getIndexAUTH(const char* ip_address) __pure;
static UString getIPAddress(const char* ptr, uint32_t len);
static UString getSignedData(const char* ptr, uint32_t len);
static UString getUrlForSendMsgToPortal(uint32_t index_AUTH, const char* msg, uint32_t msg_len);
static void preallocatePeers() { U_NEW_VECTOR_ULIB_OBJECT(peers_preallocate, num_peers_preallocate, UModNoCatPeer, 0); }
static void getARPCache()
{
@ -238,32 +253,13 @@ protected:
(void) USocketExt::getARPCache(*arp_cache, *varp_cache);
}
static void sendMsgToPortal(const UString& msg)
static void sendMsgToAllPortal(const UString& msg)
{
U_TRACE(0, "UNoCatPlugIn::sendMsgToPortal(%.*S)", U_STRING_TO_TRACE(msg))
U_TRACE(0, "UNoCatPlugIn::sendMsgToAllPortal(%.*S)", U_STRING_TO_TRACE(msg))
for (uint32_t i = 0, n = vinfo_url->size(); i < n; ++i) sendMsgToPortal(i, msg, 0, false);
for (uint32_t i = 0, n = vauth_url->size(); i < n; ++i) sendMsgToPortal(i, msg, 0);
}
static void sendMsgToPortal(uint32_t index_AUTH, const UString& msg, UString* poutput, bool basync);
static UString getIPAddress(const char* ptr, uint32_t len);
static UString getSignedData(const char* ptr, uint32_t len);
static UString getUrlForSendMsgToPortal(uint32_t index_AUTH, const char* msg, uint32_t msg_len);
static void deny(bool disconnected);
static void permit(const UString& UserDownloadRate, const UString& UserUploadRate);
static void getTraffic();
static void executeCommand(int type);
static void setHTTPResponse(const UString& content);
static void notifyAuthOfUsersInfo(uint32_t index_AUTH);
static bool getPeerStatus(UStringRep* key, void* value);
static bool checkPeerInfo(UStringRep* key, void* value);
static bool checkPeerStatus(UStringRep* key, void* value);
static bool getPeerListInfo(UStringRep* key, void* value);
static void setFireWallCommand(UCommand& cmd, const UString& script, const UString& mac, const UString& ip);
static bool isPingAsyncPending()
{
U_TRACE(0, "UNoCatPlugIn::isPingAsyncPending()")

View File

@ -57,7 +57,7 @@ public:
static void setBadRequest();
static void setAlternativeResponse();
static void setAlternativeResponse(const UString& body);
static void setAlternativeResponse(UString& body);
static void setAlternativeRedirect(const char* fmt, ...);
static void setAlternativeInclude(const UString& tmpl, uint32_t estimated_size, bool bprocess,
const char* title_txt, const char* ssi_head, const char* body_style, ...);

View File

@ -66,6 +66,9 @@ public:
// GZIP method
static bool isGzip(const char* s) { return (*(int16_t*)s == U_MULTICHAR_CONSTANT16('\x1F','\x8B')); }
static bool isGzip(const UString& s) { return isGzip(s.data()); }
static UString deflate(const char* s, uint32_t n, int type); // .gz compress
static UString gunzip(const char* s, uint32_t n, uint32_t sz_orig); // .gz uncompress

View File

@ -271,7 +271,7 @@ public:
NETWORK_AUTHENTICATION_REQUIRED = 0x008
};
static void setResponse(const UString* content_type, const UString* body);
static void setResponse(const UString* content_type, UString* pbody);
static void setRedirectResponse(int mode, const UString& ext, const char* ptr_location, uint32_t len_location);
// get HTTP response message

View File

@ -1016,14 +1016,16 @@ uint32_t u_strftime2(char* restrict s, uint32_t maxsize, const char* restrict fo
#ifdef DEBUG
{
char dbg[4096];
uint32_t result = u_strftime1(s, maxsize, format);
/*
char dbg[4096];
if (strftime(dbg, maxsize, format, &u_strftime_tm) &&
strcmp(s,dbg))
{
U_WARNING("DIFFERENT: u_strftime2() = \"%s\" strftime() = \"%s\" format = \"%s\"", s, dbg, format);
}
*/
return result;
}

View File

@ -228,7 +228,7 @@ __pure uint32_t UVector<UString>::find(const char* s, uint32_t n)
__pure uint32_t UVector<UString>::findRange(const char* s, uint32_t n, uint32_t start, uint32_t _end)
{
U_TRACE(0, "UVector<UString>::findRange(%.*S,%u,%u,%u)", n, s, n, start, _end)
U_TRACE(0+256, "UVector<UString>::findRange(%.*S,%u,%u,%u)", n, s, n, start, _end)
U_CHECK_MEMORY

View File

@ -188,7 +188,7 @@ void UError::stackDump()
FILE* f = fdopen(fd, "w");
(void) fwrite(U_CONSTANT_TO_PARAM("=== STACK TRACE ===\n"), 1, f);
(void) fwrite(buffer, u__snprintf(buffer, sizeof(buffer), "%9D: %N (pid %P) === STACK TRACE ===\n", 0), 1, f);
# ifdef HAVE_DLFCN_H
Dl_info dlinf;

View File

@ -610,9 +610,9 @@ void ULog::log(int _fd, const char* fmt, ...)
(void) U_SYSCALL(writev, "%d,%p,%d", _fd, iov_vec, 5);
}
void ULog::log(const struct iovec* iov, const char* name, const char* type, int ncount, const char* pipeline, const char* format, ...)
void ULog::log(const struct iovec* iov, const char* name, const char* type, int ncount, const char* msg, uint32_t msg_len, const char* format, ...)
{
U_TRACE(0, "ULog::log(%p,%S,%S,%d,%S,%S)", iov, name, type, ncount, pipeline, format)
U_TRACE(0, "ULog::log(%p,%S,%S,%d,%.*S,%u,%S)", iov, name, type, ncount, msg_len, msg, msg_len, format)
U_INTERNAL_ASSERT_MAJOR(ncount, 0)
@ -674,7 +674,7 @@ void ULog::log(const struct iovec* iov, const char* name, const char* type, int
ptr = buffer1;
}
len = u__snprintf(buffer2, sizeof(buffer2), "%ssend %s (%u bytes) %s%.*S", name, type, ncount, pipeline, sz, ptr);
len = u__snprintf(buffer2, sizeof(buffer2), "%ssend %s (%u bytes) %.*s%.*S", name, type, ncount, msg_len, msg, sz, ptr);
va_list argp;
va_start(argp, format);

View File

@ -511,8 +511,8 @@ resend:
if (log)
{
ULog::log(iov, name, "request", ncount, "", " to %.*s", U_STRING_TO_TRACE(host_port));
ULog::log("%serror on reading data from %.*S%R", name, U_STRING_TO_TRACE(host_port), 0); // 0 is necessary...
ULog::log(iov, name, "request", ncount, "", 0, " to %.*s", U_STRING_TO_TRACE(host_port));
ULog::log("%serror on reading data from %.*S%R", name, U_STRING_TO_TRACE(host_port), 0); // 0 is necessary
}
U_RETURN(false);
@ -520,8 +520,8 @@ resend:
if (log)
{
ULog::log(iov, name, "request", ncount, "", " to %.*s", U_STRING_TO_TRACE(host_port));
if (response) ULog::logResponse(response, name, " from %.*s", U_STRING_TO_TRACE(host_port));
ULog::log(iov, name, "request", ncount, "", 0, " to %.*s", U_STRING_TO_TRACE(host_port));
if (response) ULog::logResponse(response, name, " from %.*s", U_STRING_TO_TRACE(host_port));
}
reset();
@ -552,6 +552,7 @@ bool UClient_Base::readResponse(uint32_t count)
U_RETURN(false);
}
bool UClient_Base::readHTTPResponse()
{
U_TRACE(0, "UClient_Base::readHTTPResponse()")
@ -587,31 +588,6 @@ bool UClient_Base::readHTTPResponse()
U_RETURN(false);
}
bool UClient_Base::readRPCResponse()
{
U_TRACE(0, "UClient_Base::readRPCResponse()")
// NB: we force for U_SUBSTR_INC_REF case (string can be referenced more)...
buffer.setEmptyForce();
response.setEmptyForce();
uint32_t rstart = 0;
if (URPC::readTokenString(socket, 0, buffer, rstart, response))
{
// NB: we force for U_SUBSTR_INC_REF case (string can be referenced more)...
buffer.size_adjust_force(U_TOKEN_NM);
}
U_INTERNAL_DUMP("buffer = %.*S response = %.*S)", U_STRING_TO_TRACE(buffer), U_STRING_TO_TRACE(response))
if (buffer) U_RETURN(true);
U_RETURN(false);
}
// DEBUG
#if defined(U_STDCPP_ENABLE) && defined(DEBUG)

View File

@ -11,6 +11,7 @@
//
// ============================================================================
#include <ulib/net/rpc/rpc_client.h>
#include <ulib/utility/socket_ext.h>
#include <ulib/net/client/client_rdb.h>
@ -47,7 +48,7 @@ bool URDBClient_Base::readResponse()
response.setBuffer(U_CAPACITY);
if (this->UClient_Base::readRPCResponse())
if (URPCClient_Base::readResponse(socket, buffer, response))
{
nResponseCode = strtol(buffer.data(), 0, 10);
@ -77,10 +78,13 @@ bool URDBClient_Base::processRequest(const char* token)
UStringExt::buildTokenVector(token, *URPC::rpc_info, request);
bool result = this->UClient_Base::sendRequest(request, false) &&
this->readResponse();
if (sendRequest(request, false) &&
readResponse())
{
U_RETURN(true);
}
U_RETURN(result);
U_RETURN(false);
}
bool URDBClient_Base::closeReorganize()

View File

@ -394,7 +394,7 @@ bool UHttpClient_Base::createAuthorizationHeader()
// MD5(method : uri)
a2.snprintf("%.*s:%.*s", u_http_method_list[method_num].len, u_http_method_list[method_num].name, U_STRING_TO_TRACE(UClient_Base::uri));
a2.snprintf("%.*s:%.*s", U_HTTP_METHOD_NUM_TO_TRACE(method_num), U_STRING_TO_TRACE(UClient_Base::uri));
UServices::generateDigest(U_HASH_MD5, 0, a2, ha2, false);
@ -619,9 +619,7 @@ int UHttpClient_Base::sendRequestAsync(const UString& _url, bool bqueue, const c
{
// we need to compose the request to the HTTP server...
method_num = 0; // GET
composeRequest();
composeRequest("application/x-www-form-urlencoded");
UClient_Base::adjustTimeOut();
@ -689,9 +687,9 @@ next:
// We do not process Location headers when accompanying a 200 OK response.
//=============================================================================
void UHttpClient_Base::parseRequest()
void UHttpClient_Base::parseRequest(uint32_t n)
{
U_TRACE(0, "UHttpClient_Base::parseRequest()")
U_TRACE(0, "UHttpClient_Base::parseRequest(%u)", n)
U_INTERNAL_DUMP("last_request = %.*S", U_STRING_TO_TRACE(last_request))
@ -703,7 +701,7 @@ void UHttpClient_Base::parseRequest()
const char* ptr = last_request.data();
UClient_Base::iovcnt = 3;
UClient_Base::iovcnt = n;
UClient_Base::iov[0].iov_base = (caddr_t)ptr;
UClient_Base::iov[0].iov_len = startHeader;
@ -728,10 +726,12 @@ UString UHttpClient_Base::wrapRequest(UString* req, const UString& host_port, ui
tmp.snprintf("%.*s %.*s HTTP/1.1\r\n"
"Host: %.*s\r\n"
# ifdef USE_LIBZ
"Accept-Encoding: gzip\r\n"
# endif
"User-Agent: " PACKAGE_NAME "/" PACKAGE_VERSION "\r\n"
"%s",
u_http_method_list[method_num].len, u_http_method_list[method_num].name,
uri_len, _uri,
U_HTTP_METHOD_NUM_TO_TRACE(method_num), uri_len, _uri,
U_STRING_TO_TRACE(host_port),
extension);
@ -752,15 +752,46 @@ UString UHttpClient_Base::wrapRequest(UString* req, const UString& host_port, ui
U_RETURN_STRING(tmp);
}
void UHttpClient_Base::composeRequest()
void UHttpClient_Base::composeRequest(const char* content_type)
{
U_TRACE(0, "UHttpClient_Base::composeRequest()")
U_TRACE(0, "UHttpClient_Base::composeRequest(%S)", content_type)
U_INTERNAL_ASSERT(UClient_Base::uri)
last_request = wrapRequest(0, UClient_Base::host_port, method_num, U_STRING_TO_PARAM(UClient_Base::uri), "\r\n");
U_INTERNAL_DUMP("method_num = %u", method_num)
parseRequest();
if (method_num == 0) // GET
{
last_request = wrapRequest(0, UClient_Base::host_port, method_num, U_STRING_TO_PARAM(UClient_Base::uri), "\r\n");
parseRequest(3);
}
else
{
U_INTERNAL_ASSERT_EQUALS(method_num, 2) // POST
uint32_t sz = body.size();
U_INTERNAL_ASSERT_MAJOR(sz, 0)
UClient_Base::iov[3].iov_base = (caddr_t)body.data();
UClient_Base::iov[3].iov_len = sz;
(void) last_request.reserve(UClient_Base::uri.size() + UClient_Base::server.size() + 300U);
last_request.snprintf("POST %.*s HTTP/1.1\r\n"
"Host: %.*s:%u\r\n"
"User-Agent: ULib/1.0\r\n"
"Content-Length: %d\r\n"
"Content-Type: %s\r\n"
"\r\n",
U_STRING_TO_TRACE(UClient_Base::uri),
U_STRING_TO_TRACE(UClient_Base::server), UClient_Base::port,
sz,
content_type);
parseRequest(4);
}
}
bool UHttpClient_Base::sendRequestEngine()
@ -906,34 +937,13 @@ bool UHttpClient_Base::sendPost(const UString& _url, const UString& _body, const
U_RETURN(false);
}
uint32_t sz = _body.size();
body = _body;
method_num = 2; // POST
UClient_Base::iov[3].iov_base = (caddr_t)_body.data();
UClient_Base::iov[3].iov_len = sz;
U_INTERNAL_ASSERT(UClient_Base::uri)
(void) last_request.reserve(UClient_Base::uri.size() + UClient_Base::server.size() + 300U);
last_request.snprintf("POST %.*s HTTP/1.1\r\n"
"Host: %.*s:%u\r\n"
"User-Agent: ULib/1.0\r\n"
"Content-Length: %d\r\n"
"Content-Type: %s\r\n"
"\r\n",
U_STRING_TO_TRACE(UClient_Base::uri),
U_STRING_TO_TRACE(UClient_Base::server), UClient_Base::port,
sz,
content_type);
parseRequest();
UClient_Base::iovcnt = 4;
composeRequest(content_type);
// send post request to server and get response
method_num = 2; // POST
if (sendRequest()) U_RETURN(true);
U_RETURN(false);
@ -950,6 +960,8 @@ bool UHttpClient_Base::upload(const UString& _url, UFile& file, const char* file
U_RETURN(false);
}
method_num = 2; // POST
UString content = file.getContent();
if (content.empty()) U_RETURN(false);
@ -998,14 +1010,10 @@ bool UHttpClient_Base::upload(const UString& _url, UFile& file, const char* file
U_STRING_TO_TRACE(UClient_Base::server), UClient_Base::port,
_body.size() + sz + UClient_Base::iov[5].iov_len);
parseRequest();
UClient_Base::iovcnt = 6;
parseRequest(6);
// send upload request to server and get response
method_num = 2; // POST
if (sendRequest()) U_RETURN(true);
U_RETURN(false);

View File

@ -11,8 +11,7 @@
//
// ============================================================================
#include <ulib/net/rpc/rpc.h>
#include <ulib/net/server/client_image.h>
#include <ulib/net/rpc/rpc_client.h>
// -----------------------------------------------------------------------------------------------------------------------
// Very simple RPC-like layer

View File

@ -953,6 +953,8 @@ start:
if (U_ClientImage_state == U_PLUGIN_HANDLER_AGAIN &&
U_ClientImage_parallelization != 1) // 1 => child of parallelization
{
U_INTERNAL_ASSERT(socket->isOpen())
U_RETURN(U_NOTIFIER_OK); // NOT BLOCKING...
}
@ -1011,6 +1013,9 @@ dmiss:
// TODO
}
U_INTERNAL_ASSERT(socket->isOpen())
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, 1) // 1 => child of parallelization
U_RETURN(U_NOTIFIER_OK);
}
@ -1076,7 +1081,21 @@ dmiss:
U_INTERNAL_ASSERT(socket->isOpen())
if (U_ClientImage_data_missing) goto dmiss;
if (U_ClientImage_data_missing)
{
if (U_ClientImage_parallelization == 1)
{
if (UNotifier::waitForRead(socket->iSockDesc, U_TIMEOUT_MS) != 1 ||
USocketExt::read(socket, *rbuffer, U_SINGLE_READ, 0) == false)
{
goto death;
}
goto loop;
}
goto dmiss;
}
if (LIKELY(size_request))
{
@ -1293,22 +1312,27 @@ error:
if (U_ClientImage_close)
{
end: if (U_ClientImage_parallelization == 1) UServer_Base::endNewChild(); // 1 => child of parallelization
end: if (U_ClientImage_parallelization == 1) goto death; // 1 => child of parallelization
U_RETURN(U_NOTIFIER_DELETE);
}
// NB: maybe we have some more request to services on the same connection...
if (U_ClientImage_parallelization == 1 &&
UNotifier::waitForRead(socket->iSockDesc, U_TIMEOUT_MS) == 1)
if (U_ClientImage_parallelization == 1)
{
goto start;
U_INTERNAL_ASSERT_EQUALS(count, 0) // NB: we must not have pending write...
U_INTERNAL_ASSERT_DIFFERS(socket->iSockDesc, -1)
if (UNotifier::waitForRead(socket->iSockDesc, U_TIMEOUT_MS) == 1) goto start;
death:
UServer_Base::endNewChild(); // no return;
}
last_event = u_now->tv_sec;
U_INTERNAL_ASSERT(socket->isOpen())
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, 1) // 1 => child of parallelization
U_RETURN(U_NOTIFIER_OK);
}
@ -1317,13 +1341,16 @@ bool UClientImage_Base::writeResponse()
{
U_TRACE(0, "UClientImage_Base::writeResponse()")
U_INTERNAL_DUMP("U_ClientImage_pipeline = %b U_ClientImage_close = %b nrequest = %u", U_ClientImage_pipeline, U_ClientImage_close, nrequest)
U_INTERNAL_ASSERT(*wbuffer)
U_INTERNAL_ASSERT(socket->isOpen())
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, 2) // 2 => parent of parallelization
int iBytesWrite;
uint32_t sz1 = wbuffer->size(),
sz2 = (U_http_method_type == HTTP_HEAD ? 0 : body->size());
uint32_t sz1 = wbuffer->size(),
sz2 = (U_http_method_type == HTTP_HEAD ? 0 : body->size()),
msg_len = (U_ClientImage_pipeline ? U_CONSTANT_SIZE("[pipeline] ") : 0);
iov_vec[2].iov_len = sz1;
iov_vec[2].iov_base = (caddr_t) wbuffer->data();
@ -1332,8 +1359,6 @@ bool UClientImage_Base::writeResponse()
ncount = sz1 + sz2;
U_INTERNAL_DUMP("U_ClientImage_pipeline = %b U_ClientImage_close = %b nrequest = %u", U_ClientImage_pipeline, U_ClientImage_close, nrequest)
if (LIKELY(response_len)) // HTTP/1.1 200 OK\r\n
{
ncount += (iov_vec[0].iov_len = response_len) +
@ -1361,22 +1386,44 @@ bool UClientImage_Base::writeResponse()
if (LIKELY(iBytesWrite == (int)ncount))
{
# ifdef U_LOG_ENABLE
if (logbuf)
{
ULog::log(iov_vec, UServer_Base::mod_name[0], "response", ncount,
(U_ClientImage_pipeline ? "[pipeline] " : ""), " to %.*s", U_STRING_TO_TRACE(*logbuf));
}
if (logbuf) ULog::log(iov_vec, UServer_Base::mod_name[0], "response", ncount, "[pipeline] ", msg_len, " to %.*s", U_STRING_TO_TRACE(*logbuf));
# endif
U_RETURN(true);
}
loop:
if (iBytesWrite > 0)
{
U_SRV_LOG_WITH_ADDR("sent partial response (%u bytes of %u: sock_fd %d)%.*s to",
iBytesWrite, ncount, socket->iSockDesc, (U_ClientImage_pipeline ? U_CONSTANT_SIZE(" [pipeline]") : 0), " [pipeline]");
U_SRV_LOG_WITH_ADDR("sent partial response (%u bytes of %u: sock_fd %d)%.*s to", iBytesWrite, ncount, socket->iSockDesc, msg_len, " [pipeline]");
ncount -= iBytesWrite;
if (U_ClientImage_parallelization != 1 && // 1 => child of parallelization
UServer_Base::startParallelization())
{
// parent
U_ClientImage_state = U_PLUGIN_HANDLER_ERROR;
U_RETURN(false);
}
if (U_ClientImage_parallelization == 1) // 1 => child of parallelization
{
if (UNotifier::waitForWrite(socket->iSockDesc, U_TIMEOUT_MS) != 1) U_RETURN(false);
iBytesWrite = USocketExt::writev(socket, iov_vec, 4, ncount, UServer_Base::timeoutMS);
if (LIKELY(iBytesWrite == (int)ncount))
{
U_SRV_LOG_WITH_ADDR("sending partial response completed (%u bytes of %u: sock_fd %d)%.*s to", iBytesWrite, ncount, socket->iSockDesc, msg_len, " [pipeline]");
U_RETURN(false);
}
goto loop;
}
}
U_RETURN(false);
@ -1388,7 +1435,8 @@ int UClientImage_Base::handlerResponse()
if (writeResponse()) U_RETURN(U_NOTIFIER_OK);
if (socket->isOpen())
if (socket->isOpen() &&
U_ClientImage_parallelization == 0) // 1/2 => child/parent of parallelization
{
# ifndef U_CLIENT_RESPONSE_PARTIAL_WRITE_SUPPORT
resetPipelineAndClose();

View File

@ -471,7 +471,7 @@ int UFCGIPlugIn::handlerRequest()
U_INTERNAL_DUMP("pos = %u response.size() = %u", pos, connection->response.size())
if ((connection->response.size() - pos) < FCGI_HEADER_LEN &&
connection->readResponse() == false)
connection->readResponse(U_SINGLE_READ) == false)
{
break;
}

View File

@ -70,11 +70,11 @@ UIptAccount* UNoCatPlugIn::ipt;
UModNoCatPeer* UNoCatPlugIn::peer;
UModNoCatPeer* UNoCatPlugIn::peers_preallocate;
UVector<Url*>* UNoCatPlugIn::vauth_url;
UVector<Url*>* UNoCatPlugIn::vinfo_url;
UVector<UString>* UNoCatPlugIn::openlist;
UVector<UString>* UNoCatPlugIn::vauth;
UVector<UString>* UNoCatPlugIn::vauth_ip;
UVector<UString>* UNoCatPlugIn::openlist;
UVector<UString>* UNoCatPlugIn::varp_cache;
UVector<UString>* UNoCatPlugIn::vinfo_data;
UVector<UString>* UNoCatPlugIn::vLoginValidate;
UVector<UString>* UNoCatPlugIn::vInternalDevice;
UVector<UString>* UNoCatPlugIn::vLocalNetworkLabel;
@ -88,51 +88,51 @@ const UString* UNoCatPlugIn::str_allowed_members_default;
//const UString* UNoCatPlugIn::str_IPHONE_SUCCESS;
#define U_NOCAT_STATUS \
"<html>\n" \
"<head>\n" \
"<meta http-equiv=\"Cache Control\" content=\"max-age=0\">\n" \
"<title>Access Point: %s</title>" \
"</head>\n" \
"<body bgcolor=\"#FFFFFF\" text=\"#000000\">\n" \
"<h1>Access Point: %s</h1>\n" \
"<hr noshade=\"1\"/>\n" \
"<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\">\n" \
"<tr><td>Current Time</td><td>%5D</td></tr>\n" \
"<tr><td>Gateway Up Since</td><td>%#5D</td></tr>\n" \
"<tr><td>GatewayVersion</td><td>" ULIB_VERSION "</td></tr>\n" \
"<tr><td>ExternalDevice</td><td>%.*s</td></tr>\n" \
"<tr><td>InternalDevice</td><td>%.*s</td></tr>\n" \
"<tr><td>LocalNetwork</td><td>%.*s</td></tr>\n" \
"<tr><td>GatewayPort</td><td>%u</td></tr>\n" \
"<tr><td>AuthServiceAddr</td><td>%.*s</td></tr>\n" \
"%s" \
"</table>\n" \
"<html>\n" \
"<head>\n" \
"<meta http-equiv=\"Cache Control\" content=\"max-age=0\">\n" \
"<title>Access Point: %s</title>" \
"</head>\n" \
"<body bgcolor=\"#FFFFFF\" text=\"#000000\">\n" \
"<h1>Access Point: %s</h1>\n" \
"<hr noshade=\"1\"/>\n" \
"<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\">\n" \
"<tr><td>Users</td><td>%u</td></tr>\n" \
"<tr><td>Users Connected</td><td>%u</td></tr>\n" \
"<tr><td></td><td></td></tr>\n" \
"<tr><td align=\"center\"><h2>Current Users</h2></td>\n" \
"<table border=\"1\" cellpadding=\"5\">\n" \
"<tr><th>User UID</th>\n" \
"<th>IP address</th>\n" \
"<th>Connection time</th>\n" \
"<th>Elapsed connection time</th>\n" \
"<th>Left connection time</th>\n" \
"<th>Consumed traffic</th>\n" \
"<th>Left traffic</th>\n" \
"<th>MAC address</th>\n" \
"<th>Status</th></tr>\n" \
"%.*s" \
"</table></td></tr>\n" \
"</table>\n" \
"<hr noshade=\"1\"/>\n" \
"<img src=%s width=\"112\" height=\"35\">\n" \
"<p style=\"text-align:right\">Powered by ULib</p>\n" \
"</body>\n" \
"</html>"
"<tr><td>Current Time</td><td>%5D</td></tr>\n" \
"<tr><td>Gateway Up Since</td><td>%#5D</td></tr>\n" \
"<tr><td>GatewayVersion</td><td>" ULIB_VERSION "</td></tr>\n" \
"<tr><td>ExternalDevice</td><td>%.*s</td></tr>\n" \
"<tr><td>InternalDevice</td><td>%.*s</td></tr>\n" \
"<tr><td>LocalNetwork</td><td>%.*s</td></tr>\n" \
"<tr><td>GatewayPort</td><td>%u</td></tr>\n" \
"<tr><td>AuthServiceAddr</td><td>%.*s</td></tr>\n" \
"%s" \
"</table>\n" \
"<hr noshade=\"1\"/>\n" \
"<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\">\n" \
"<tr><td>Users</td><td>%u</td></tr>\n" \
"<tr><td>Users Connected</td><td>%u</td></tr>\n" \
"<tr><td></td><td></td></tr>\n" \
"<tr><td align=\"center\"><h2>Current Users</h2></td>\n" \
"<table border=\"1\" cellpadding=\"5\">\n" \
"<tr><th>User UID</th>\n" \
"<th>IP address</th>\n" \
"<th>Connection time</th>\n" \
"<th>Elapsed connection time</th>\n" \
"<th>Left connection time</th>\n" \
"<th>Consumed traffic</th>\n" \
"<th>Left traffic</th>\n" \
"<th>MAC address</th>\n" \
"<th>Status</th></tr>\n" \
"%.*s" \
"</table></td></tr>\n" \
"</table>\n" \
"<hr noshade=\"1\"/>\n" \
"<img src=%s width=\"112\" height=\"35\">\n" \
"<p style=\"text-align:right\">Powered by ULib</p>\n" \
"</body>\n" \
"</html>"
// define method VIRTUAL of class UEventTime
// define method VIRTUAL of class UEventTime
int UModNoCatPeer::handlerTime()
{
@ -213,8 +213,8 @@ UNoCatPlugIn::UNoCatPlugIn()
vauth = U_NEW(UVector<UString>(4U));
vauth_ip = U_NEW(UVector<UString>(4U));
vauth_url = U_NEW(UVector<Url*>(4U));
vinfo_url = U_NEW(UVector<Url*>(4U));
varp_cache = U_NEW(UVector<UString>);
vinfo_data = U_NEW(UVector<UString>(4U));
vLoginValidate = U_NEW(UVector<UString>);
vInternalDevice = U_NEW(UVector<UString>(64U));
vLocalNetworkMask = U_NEW(UVector<UIPAllow*>);
@ -260,7 +260,7 @@ UNoCatPlugIn::~UNoCatPlugIn()
delete vauth;
delete vauth_ip;
delete vauth_url;
delete vinfo_url;
delete vinfo_data;
delete vLoginValidate;
delete vInternalDevice;
delete vLocalNetworkMask;
@ -524,7 +524,7 @@ UString UNoCatPlugIn::getUrlForSendMsgToPortal(uint32_t index_AUTH, const char*
{
U_TRACE(0, "UNoCatPlugIn::getUrlForSendMsgToPortal(%u,%.*S,%u)", index_AUTH, msg_len, msg, msg_len)
Url* auth = (*vinfo_url)[index_AUTH];
Url* auth = (*vauth_url)[index_AUTH];
UString auth_host = auth->getHost(),
auth_service = auth->getService(),
url(200U + auth_host.size() + auth_service.size() + msg_len);
@ -565,45 +565,17 @@ void UNoCatPlugIn::uploadFileToPortal(UFile& file)
if (result) (void) file._unlink();
}
void UNoCatPlugIn::sendMsgToPortal(uint32_t index_AUTH, const UString& msg, UString* poutput, bool basync)
void UNoCatPlugIn::sendMsgToPortal(uint32_t index_AUTH, const UString& msg, UString* poutput)
{
U_TRACE(0, "UNoCatPlugIn::sendMsgToPortal(%u,%.*S,%p,%b)", index_AUTH, U_STRING_TO_TRACE(msg), poutput, basync)
UString url = getUrlForSendMsgToPortal(index_AUTH, U_STRING_TO_PARAM(msg));
if (basync)
{
U_INTERNAL_ASSERT_EQUALS(poutput, 0)
U_INTERNAL_ASSERT_EQUALS(UClient_Base::queue_dir, 0)
# ifdef U_LOG_ENABLE
if (UServer_Base::isLog())
{
char log_msg[4096];
uint32_t sz = msg.size();
// NB: we need this because we have a message with many url encoded char...
UString str = UStringExt::substitute(msg.data(), U_min(sz,200), '%', U_CONSTANT_TO_PARAM("%%"));
(void) u__snprintf(log_msg, sizeof(log_msg),
"[nocat] Sent info %%s (%u bytes) after %%d attempts to AUTH(%u): %.*S",
sz, index_AUTH, U_STRING_TO_TRACE(str));
(void) client->sendRequestAsync(url, false, log_msg);
}
else
# endif
(void) client->sendRequestAsync(url);
return;
}
U_TRACE(0, "UNoCatPlugIn::sendMsgToPortal(%u,%.*S,%p)", index_AUTH, U_STRING_TO_TRACE(msg), poutput)
#ifdef U_LOG_ENABLE
const char* result = "FAILED";
const char* result = "FAILED";
#endif
bool bqueue = false, we_need_response = (poutput != 0);
UString url = getUrlForSendMsgToPortal(index_AUTH, U_STRING_TO_PARAM(msg));
loop:
if (we_need_response == false) UClient_Base::queue_dir = UString::str_CLIENT_QUEUE_DIR;
@ -884,7 +856,7 @@ bool UNoCatPlugIn::checkFirewall()
msg.snprintf("/error_ap?ap=%.*s@%.*s&public=%.*s:%u",
U_STRING_TO_TRACE(*label), U_STRING_TO_TRACE(*hostname), U_STRING_TO_TRACE(*UServer_Base::IP_address), UServer_Base::port);
sendMsgToPortal(msg);
sendMsgToAllPortal(msg);
}
}
@ -899,8 +871,6 @@ void UNoCatPlugIn::checkSystem()
{
U_TRACE(1, "UNoCatPlugIn::checkSystem()")
UString info;
Url* info_url;
uint32_t i, n;
long check_interval;
@ -1003,28 +973,7 @@ result:
paddrmask = 0;
}
for (i = 0, n = vinfo_url->size(); i < n; ++i)
{
info_url = (*vinfo_url)[i];
if (info_url->isQuery())
{
info = info_url->getPathAndQuery();
U_INTERNAL_ASSERT(info)
// NB: we can't try to send immediately the info data on users to portal because the worst we have a hole
// of 10 seconds and the portal can have need to ask us something (to logout some user, the list of peer permitted, ...)
sendMsgToPortal(i, info, 0, true);
# ifdef DEBUG
info.clear(); // NB: to avoid DEAD OF SOURCE STRING WITH CHILD ALIVE...
# endif
*info_url = *((*vauth_url)[i]);
}
}
for (i = 0, n = vauth_url->size(); i < n; ++i) sendInfoData(i);
// check if there are some log file to upload
@ -1269,12 +1218,14 @@ bool UNoCatPlugIn::checkAuthMessage(const UString& msg)
{
U_SRV_LOG("WARNING: tampered token from peer: IP %.*s MAC %.*s", U_STRING_TO_TRACE(peer->ip), U_STRING_TO_TRACE(peer->mac));
/* ---------------------------------------------------------------------------------------------------------------------
// NB: tutto il traffico viene rediretto sulla 80 (CAPTIVE PORTAL) e quindi windows update, antivrus, etc...
// questo introduce la possibilita' che durante la fase di autorizzazione il token generato per il ticket autorizzativo
// non corrisponda piu' a quello inviato dal portale per l'autorizzazione...
// ---------------------------------------------------------------------------------------------------------------------
*/
/**
* --------------------------------------------------------------------------------------------------------------------
* NB: tutto il traffico viene rediretto sulla 80 (CAPTIVE PORTAL) e quindi windows update, antivrus, etc...
* questo introduce la possibilita' che durante la fase di autorizzazione il token generato per il ticket autorizzativo
* non corrisponda piu' a quello inviato dal portale per l'autorizzazione...
* ---------------------------------------------------------------------------------------------------------------------
*/
peer->token.snprintf("%u", u_random(u_now->tv_usec));
goto end;
@ -1561,12 +1512,14 @@ void UNoCatPlugIn::setNewPeer()
setFireWallCommand(peer->fw, *fw_cmd, peer->mac, peer->ip);
/* ---------------------------------------------------------------------------------------------------------------------
// NB: tutto il traffico viene rediretto sulla 80 (CAPTIVE PORTAL) e quindi windows update, antivrus, etc...
// questo introduce la possibilita' che durante la fase di autorizzazione il token generato per il ticket autorizzativo
// non corrisponda piu' a quello inviato dal portale per l'autorizzazione...
// ---------------------------------------------------------------------------------------------------------------------
*/
/**
* --------------------------------------------------------------------------------------------------------------------
* NB: tutto il traffico viene rediretto sulla 80 (CAPTIVE PORTAL) e quindi windows update, antivrus, etc...
* questo introduce la possibilita' che durante la fase di autorizzazione il token generato per il ticket autorizzativo
* non corrisponda piu' a quello inviato dal portale per l'autorizzazione...
* ---------------------------------------------------------------------------------------------------------------------
*/
peer->token.snprintf("%u", u_random(u_now->tv_usec));
peers->insert(peer->ip, peer);
@ -1628,62 +1581,74 @@ void UNoCatPlugIn::addPeerInfo(time_t logout)
U_TRACE(0, "UNoCatPlugIn::addPeerInfo(%T)", logout)
U_INTERNAL_ASSERT_POINTER(peer)
U_INTERNAL_ASSERT(peer->user)
U_INTERNAL_ASSERT(u_now->tv_sec >= peer->ctime)
char* ptr;
char buffer[64];
UString info = (*vinfo_data)[U_peer_index_AUTH];
uint32_t sz = info.size();
U_INTERNAL_DUMP("U_peer_index_AUTH = %u info = %.*S", U_peer_index_AUTH, U_STRING_TO_TRACE(info))
// -----------------------------------------------------------------------------------------------------------------------------------------
// $1 -> mac
// $2 -> ip
// $3 -> gateway
// $4 -> ap
// $5 -> uid
// $4 -> ap (with localization => '@')
// $5 -> => UID <=
// $6 -> logout
// $7 -> connected
// $8 -> traffic
// -----------------------------------------------------------------------------------------------------------------------------------------
// /info?Mac=98%3A0c%3A82%3A76%3A3b%3A39&ip=172.16.1.8&gateway=172.16.1.254%3A5280&ap=ap%4010.8.0.1&User=1212&logout=1&connected=3&traffic=0
// -----------------------------------------------------------------------------------------------------------------------------------------
Url* info_url = (*vinfo_url)[U_peer_index_AUTH];
info.reserve(sz + 200);
info_url->setPath(U_CONSTANT_TO_PARAM("/info"));
info.snprintf_add("%sMac=%.*s&ip=%.*s&", (sz ? "&" : ""),
u_url_encode((const unsigned char*)U_STRING_TO_PARAM(peer->mac), (unsigned char*)buffer), buffer, U_STRING_TO_TRACE(peer->ip));
U_INTERNAL_DUMP("U_peer_index_AUTH = %u info_url = %p", U_peer_index_AUTH, info_url)
info.snprintf_add("gateway=%.*s&ap=%.*s%%40%.*s&User=",
u_url_encode((const unsigned char*)U_STRING_TO_PARAM(peer->gateway), (unsigned char*)buffer), buffer,
U_STRING_TO_TRACE(peer->label), U_STRING_TO_TRACE(*UServer_Base::IP_address));
U_INTERNAL_ASSERT(peer->user)
info.snprintf_add("%.*s&logout=", u_url_encode((const unsigned char*)U_STRING_TO_PARAM(peer->user), (unsigned char*)buffer), buffer);
UString buffer(U_CAPACITY);
buffer.snprintf("%.*s@%.*s", U_STRING_TO_TRACE(peer->label), U_STRING_TO_TRACE(*UServer_Base::IP_address));
info_url->addQuery(U_CONSTANT_TO_PARAM("Mac"), U_STRING_TO_PARAM(peer->mac));
info_url->addQuery(U_CONSTANT_TO_PARAM("ip"), U_STRING_TO_PARAM(peer->ip));
info_url->addQuery(U_CONSTANT_TO_PARAM("gateway"), U_STRING_TO_PARAM(peer->gateway));
info_url->addQuery(U_CONSTANT_TO_PARAM("ap"), U_STRING_TO_PARAM(buffer));
info_url->addQuery(U_CONSTANT_TO_PARAM("User"), U_STRING_TO_PARAM(peer->user));
ptr = (char*) info.end();
// NB: 0 => mean NOT logout (only info)
// -1 => disconnected (logout implicito)
bool logout_implicito = (logout == -1);
if (logout_implicito) logout = u_now->tv_sec;
buffer.setFromNumber32(logout);
if (logout_implicito) (void) buffer.insert(0, '-');
info_url->addQuery(U_CONSTANT_TO_PARAM("logout"), U_STRING_TO_PARAM(buffer));
U_INTERNAL_ASSERT(u_now->tv_sec >= peer->ctime)
buffer.setFromNumber32(u_now->tv_sec - peer->ctime);
peer->ctime = u_now->tv_sec;
info_url->addQuery(U_CONSTANT_TO_PARAM("connected"), U_STRING_TO_PARAM(buffer));
if (peer->ctraffic == 0) info_url->addQuery(U_CONSTANT_TO_PARAM("traffic"), U_CONSTANT_TO_PARAM("0"));
else
if (logout == -1)
{
buffer.snprintf("%u", peer->ctraffic);
peer->ctraffic = peer->time_no_traffic = 0;
info_url->addQuery(U_CONSTANT_TO_PARAM("traffic"), U_STRING_TO_PARAM(buffer));
*ptr++ = '-';
logout = u_now->tv_sec;
}
ptr += u_num2str32(ptr, logout);
u__memcpy(ptr, "&connected=",
U_CONSTANT_SIZE("&connected="), __PRETTY_FUNCTION__);
ptr += U_CONSTANT_SIZE("&connected=");
ptr += u_num2str32(ptr, u_now->tv_sec - peer->ctime);
u__memcpy(ptr, "&traffic=",
U_CONSTANT_SIZE("&traffic="), __PRETTY_FUNCTION__);
ptr += U_CONSTANT_SIZE("&traffic=");
ptr += u_num2str32(ptr, peer->ctraffic);
info.size_adjust(ptr);
U_INTERNAL_DUMP("info(%u) = %.*S", info.size(), U_STRING_TO_TRACE(info))
vinfo_data->replace(U_peer_index_AUTH, info);
peer->ctime = u_now->tv_sec;
if (peer->ctraffic) peer->ctraffic = peer->time_no_traffic = 0;
}
bool UModNoCatPeer::checkPeerInfo(bool btraffic)
@ -1856,36 +1821,60 @@ __pure bool UNoCatPlugIn::getPeer(uint32_t n)
U_RETURN(false);
}
void UNoCatPlugIn::sendInfoData(uint32_t index_AUTH)
{
U_TRACE(0, "UNoCatPlugIn::sendInfoData(%u)", index_AUTH)
UString info = (*vinfo_data)[index_AUTH];
if (info)
{
U_INTERNAL_ASSERT_EQUALS(UClient_Base::queue_dir, 0)
// NB: we can't try to send immediately the info data on users to portal because the worst we have a hole
// of 10 seconds and the portal can have need to ask us something (to logout some user, the list of peer permitted, ...)
char buffer[4096];
const char* log_msg = 0;
uint32_t sz = info.size();
UString body = info, url = getUrlForSendMsgToPortal(index_AUTH, U_CONSTANT_TO_PARAM("/info"));
# ifdef USE_LIBZ
if (sz > U_MIN_SIZE_FOR_DEFLATE) body = UStringExt::deflate(info, 1);
# endif
# ifdef U_LOG_ENABLE
if (UServer_Base::isLog())
{
UString str = UStringExt::substitute(info.data(), U_min(sz,200), '%', U_CONSTANT_TO_PARAM("%%")); // NB: we need this because we have a message with url encoded char...
(void) u__snprintf(buffer, sizeof(buffer),
"[nocat] Sent info %%s (%u bytes) after %%d attempts to AUTH(%u): %.*S",
sz, index_AUTH, U_STRING_TO_TRACE(str));
log_msg = buffer;
}
# endif
(void) client->sendPOSTRequestAsync(body, url, true, log_msg);
vinfo_data->getStringRep(index_AUTH)->size_adjust(0U);
}
}
void UNoCatPlugIn::notifyAuthOfUsersInfo(uint32_t index_AUTH)
{
U_TRACE(0, "UNoCatPlugIn::notifyAuthOfUsersInfo(%u)", index_AUTH)
Url* info_url = (*vinfo_url)[index_AUTH];
sendInfoData(index_AUTH);
U_INTERNAL_DUMP("index_AUTH = %u info_url = %p", index_AUTH, info_url)
// NB: if there is arping pending AUTH must recall us after ~15sec for completion...
// NB: if there are some data to transmit we need redirect...
u_http_info.nResponseCode = (isPingAsyncPending() ? HTTP_NO_CONTENT : HTTP_NOT_MODIFIED);
if (info_url->isQuery())
{
// NB: we need to send a body for portal discrimination...
UClientImage_Base::setCloseConnection();
UHTTP::setRedirectResponse(0, UString::getStringNull(), U_URL_TO_PARAM(*info_url));
// NB: we assume that the redirect always have success...
*info_url = *((*vauth_url)[index_AUTH]);
}
else
{
// NB: if there is arping pending AUTH must recall us after ~15sec for completion...
u_http_info.nResponseCode = (isPingAsyncPending() ? HTTP_NO_CONTENT : HTTP_NOT_MODIFIED);
UClientImage_Base::setCloseConnection();
UHTTP::setResponse(0, 0);
}
UHTTP::setResponse(0, 0);
}
void UNoCatPlugIn::setHTTPResponse(const UString& content)
@ -2152,13 +2141,13 @@ int UNoCatPlugIn::handlerInit()
Url* url;
UIPAddress addr;
UString auth_ip, ip;
UString auth_ip, ip, info(U_CAPACITY);
// NB: get IP address of AUTH hosts...
for (uint32_t i = 0, n = vauth->size(); i < n; ++i)
{
ip = (*vauth)[i];
ip = (*vauth)[i];
url = U_NEW(Url(ip));
vauth_url->push(url);
@ -2178,12 +2167,11 @@ int UNoCatPlugIn::handlerInit()
vauth_ip->push(auth_ip);
}
url = U_NEW(Url(ip));
vinfo_url->push(url);
vinfo_data->push(info);
}
U_ASSERT_EQUALS(vauth->size(), vauth_ip->size())
U_ASSERT_EQUALS(vauth->size(), vauth_ip->size())
U_ASSERT_EQUALS(vauth->size(), vinfo_data->size())
*hostname = USocketExt::getNodeName();
@ -2278,7 +2266,7 @@ bool UNoCatPlugIn::preallocatePeersFault()
U_STRING_TO_TRACE(*label), U_STRING_TO_TRACE(*hostname),
U_STRING_TO_TRACE(*UServer_Base::IP_address), UServer_Base::port, _vsz, _rss);
sendMsgToPortal(0, msg, 0, false);
sendMsgToPortal(0, msg, 0);
U_INTERNAL_ASSERT_EQUALS(peers_preallocate, 0)
@ -2357,9 +2345,9 @@ int UNoCatPlugIn::handlerFork()
U_STRING_TO_TRACE(*label), U_STRING_TO_TRACE(*hostname),
U_STRING_TO_TRACE(*UServer_Base::IP_address), UServer_Base::port, UServer_Base::pid);
for (i = 0, n = (*vinfo_url).size(); i < n; ++i)
for (i = 0, n = vauth_url->size(); i < n; ++i)
{
sendMsgToPortal(i, msg, &output, false);
sendMsgToPortal(i, msg, &output);
(void) allowed_web_hosts.append(output);
}
@ -2606,10 +2594,7 @@ int UNoCatPlugIn::handlerRequest()
{
next: getARPCache();
if (U_peer_status != UModNoCatPeer::PEER_PERMIT)
{
setStatusContent(UString::getStringNull()); // NB: peer == 0 -> request from AUTH to get status access point...
}
if (U_peer_status != UModNoCatPeer::PEER_PERMIT) setStatusContent(UString::getStringNull()); // NB: peer == 0 -> request from AUTH to get status access point...
else
{
(void) peer->checkPeerInfo(true);
@ -2931,7 +2916,6 @@ const char* UNoCatPlugIn::dump(bool _reset) const
<< "fw (UCommand " << (void*)fw << ")\n"
<< "ipt (UIptAccount " << (void*)ipt << ")\n"
<< "vauth_url (UVector<Url*> " << (void*)vauth_url << ")\n"
<< "vinfo_url (UVector<Url*> " << (void*)vinfo_url << ")\n"
<< "vauth (UVector<UString> " << (void*)vauth << ")\n"
<< "vauth_ip (UVector<UString> " << (void*)vauth_ip << ")\n"
<< "vInternalDevice (UVector<UString> " << (void*)vInternalDevice << ")\n"

View File

@ -145,10 +145,10 @@ int UProxyPlugIn::handlerRequest()
// --------------------------------------------------------------------------------------------------------------------
// A WebSocket is a long-lived connection, lasting hours or days. If each WebSocket proxy holds the original thread,
// won't that consume all of the workers very quickly ? It looks as if my server, with 16 workers, will be unable to
// won't that consume all of the workers very quickly? It looks as if my server, with 16 workers, will be unable to
// handle either the 17th WebSocket proxy or any other HTTP request. That's not really practical in a production system.
// A WebSocket server could potentially handle hundreds or even thousands of simultaneous connections, which would mean
// the same number of proxies in server
// the same number of proxies in server...
// --------------------------------------------------------------------------------------------------------------------
if (UHTTP::service->isWebSocket())
@ -212,18 +212,6 @@ int UProxyPlugIn::handlerRequest()
if (body.size() > U_MIN_SIZE_FOR_DEFLATE &&
UHttpClient_Base::u_http_info_save.flag[11]) // U_http_is_accept_gzip
{
UString header(U_CAPACITY);
char* ptr1 = header.data();
uint32_t sz1 = U_CONSTANT_SIZE("Content-Encoding: gzip\r\n");
u__memcpy(ptr1, content_type.data(), sz, __PRETTY_FUNCTION__);
u__memcpy(ptr1+sz, "Content-Encoding: gzip\r\n", sz1, __PRETTY_FUNCTION__);
header.size_adjust(sz + sz1);
content_type = header;
body = UStringExt::deflate(body, 1);
}
# endif

View File

@ -136,7 +136,7 @@ void USSIPlugIn::setAlternativeResponse()
UHTTP::setResponse(0, 0);
}
void USSIPlugIn::setAlternativeResponse(const UString& _body)
void USSIPlugIn::setAlternativeResponse(UString& _body)
{
U_TRACE(0, "USSIPlugIn::setAlternativeResponse(%.*S)", U_STRING_TO_TRACE(_body))

View File

@ -1881,6 +1881,7 @@ int UServer_Base::handlerRead() // This method is called to accept a new connect
loop:
U_INTERNAL_ASSERT_MINOR(pClientIndex, eClientImage)
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, 1) // 1 => child of parallelization
U_INTERNAL_DUMP("----------------------------------------", 0)
U_INTERNAL_DUMP("vClientImage[%d].last_event = %#3D", (pClientIndex - vClientImage),
@ -1930,6 +1931,7 @@ try_next:
try_accept:
U_INTERNAL_ASSERT(csocket->isClosed())
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, 1) // 1 => child of parallelization
if (socket->acceptClient(csocket) == false)
{
@ -2196,6 +2198,9 @@ retry:
if (UServer_Base::max_depth < UNotifier::num_connection) UServer_Base::max_depth = UNotifier::num_connection;
#endif
U_INTERNAL_ASSERT(csocket->isOpen())
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, 1) // 1 => child of parallelization
UNotifier::insert((UEventFd*)pClientIndex);
if (UNLIKELY(++pClientIndex >= eClientImage))
@ -2832,6 +2837,10 @@ bool UServer_Base::startParallelization()
U_INTERNAL_DUMP("U_ClientImage_pipeline = %b U_ClientImage_parallelization = %d U_CNT_PARALLELIZATION = %d max_num_process_parallelization = %d",
U_ClientImage_pipeline, U_ClientImage_parallelization, U_CNT_PARALLELIZATION, max_num_process_parallelization)
#ifdef USE_LIBSSL
// if (bssl == false)
#endif
{
if (U_ClientImage_pipeline == false &&
U_ClientImage_parallelization == false &&
U_CNT_PARALLELIZATION < max_num_process_parallelization) // NB: thread approach => (max_num_process_parallelization == 0)
@ -2857,6 +2866,7 @@ bool UServer_Base::startParallelization()
U_ASSERT(isParallelizationChild())
}
}
U_INTERNAL_DUMP("U_ClientImage_close = %b", U_ClientImage_close)

View File

@ -51,17 +51,17 @@ void ULock::lock(time_t timeout)
{
if (spinlock)
{
uint32_t cnt = 100;
// uint32_t cnt = 100;
do {
// do {
if (spinLockAcquire(spinlock))
{
locked = -1;
return;
}
}
while (cnt--);
// }
// while (cnt--);
}
if (sem &&

View File

@ -1425,9 +1425,7 @@ UString UStringExt::gunzip(const char* ptr, uint32_t sz, uint32_t space) // .gz
if (space == 0)
{
// check magic byte
if (*(int16_t*)ptr == U_MULTICHAR_CONSTANT16('\x1F','\x8B'))
if (isGzip(ptr)) // check magic byte
{
uint32_t* psize_original = (uint32_t*)(ptr + sz - 4); // read original size
@ -1770,7 +1768,7 @@ static inline bool isExtendableOnLeft(char c)
UString UStringExt::minifyCssJs(const char* s, uint32_t n)
{
U_TRACE(0, "UStringExt::minifyCssJs(%.*S,%u)", n, s, n)
U_TRACE(0+256, "UStringExt::minifyCssJs(%.*S,%u)", n, s, n)
U_INTERNAL_ASSERT_MAJOR_MSG(n, 0, "elaborazione su stringa vuota: inserire if empty()...")

View File

@ -2185,7 +2185,7 @@ bool UHTTP::readBody(USocket* sk, UString* pbuffer, UString& body)
* be much larger than the examples here. The size-line parameters are rarely used, but you should at
* least ignore them correctly. Footers are also rare, but might be appropriate for things like checksums
* or digital signatures
*/
*/
count = pbuffer->find(U_CRLF2, u_http_info.endHeader, U_CONSTANT_SIZE(U_CRLF2));
@ -2224,7 +2224,7 @@ bool UHTTP::readBody(USocket* sk, UString* pbuffer, UString& body)
chunkSize = strtol(inp, 0, 16);
// U_INTERNAL_DUMP("chunkSize = %u inp[0] = %C", chunkSize, inp[0])
// U_INTERNAL_DUMP("chunkSize = %u inp[0] = %C", chunkSize, inp[0])
// The last chunk is followed by zero or more trailers, followed by a blank line
@ -5313,7 +5313,7 @@ UString UHTTP::getHeaderForResponse(const UString& ext)
U_RETURN_STRING(result);
}
void UHTTP::setResponse(const UString* content_type, const UString* pbody)
void UHTTP::setResponse(const UString* content_type, UString* pbody)
{
U_TRACE(0, "UHTTP::setResponse(%p,%p)", content_type, pbody)
@ -5348,7 +5348,35 @@ void UHTTP::setResponse(const UString* content_type, const UString* pbody)
ptr += U_CONSTANT_SIZE("Content-Length: ");
if (pbody == 0) *ptr++ = '0';
else ptr += u_num2str32(ptr, pbody->size());
else
{
sz = pbody->size();
# ifdef USE_LIBZ
if (UStringExt::isGzip(*pbody))
{
if (U_http_is_accept_gzip == false)
{
*pbody = UStringExt::gunzip(*pbody);
sz = pbody->size();
}
ptr += u_num2str32(ptr, sz);
if (U_http_is_accept_gzip)
{
*(int64_t*) ptr = U_MULTICHAR_CONSTANT64('\r','\n','C','o','n','t','e','n');
*(int64_t*)(ptr+8) = U_MULTICHAR_CONSTANT64( 't', '-','E','n','c','o','d','i');
*(int64_t*)(ptr+16) = U_MULTICHAR_CONSTANT64( 'n', 'g',':',' ','g','z','i','p');
ptr += U_CONSTANT_SIZE("\r\nContent-Encoding: gzip");
}
}
else
# endif
ptr += u_num2str32(ptr, sz);
}
*(int32_t*)ptr = U_MULTICHAR_CONSTANT32('\r','\n','\r','\n');
ptr += U_CONSTANT_SIZE(U_CRLF2);

View File

@ -482,4 +482,4 @@ TIMEOUT() {
fi
}
# grep -v 'Not a GIF file' err/* | grep --colour -i -E -e 'ERROR|ABORT|ASSERT|SIGSEGV|OVERLAP|genericRead|handler|epoll_ctl'
# grep -v 'Not a GIF file' err/* | grep --colour -i -E -e 'ERROR|ABORT|ASSERT|SIGSEGV|OVERLAP|genericRead|handler|epoll_ctl' | grep -v SQLITE_ABORT

View File

@ -1 +1 @@
AFF6
B0BC

View File

@ -16,9 +16,9 @@
# . $FWROOT/ULib/install.sh (cwd=$FWROOT//installs)
# --------------------------------------------------------------------------------------------------------
export ULIB_VERSION=1.4.2
export ULIB_ROOT=$IROOT/ULib
export ULIB_DOCUMENT_ROOT=${ULIB_ROOT}/ULIB_DOCUMENT_ROOT
ULIB_VERSION=1.4.2
ULIB_ROOT=$IROOT/ULib
ULIB_DOCUMENT_ROOT=${ULIB_ROOT}/ULIB_DOCUMENT_ROOT
# Check if ULib is already installed
ULIB_INSTALLED_FILE="${IROOT}/ULib-${ULIB_VERSION}.installed"

View File

@ -5,7 +5,7 @@ export ORM_DRIVER="mysql"
export ORM_OPTION="host=${DBHOST} user=benchmarkdbuser password=benchmarkdbpass character-set=utf8 dbname=hello_world"
# 1. Change ULib Server configuration
sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g" $ULIB_ROOT/benchmark.cfg
sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g" $IROOT/ULib/benchmark.cfg
# 2. Start ULib Server (userver_tcp)
$ULIB_ROOT/bin/userver_tcp -c $ULIB_ROOT/benchmark.cfg &
$IROOT/ULib/bin/userver_tcp -c $IROOT/ULib/benchmark.cfg &

View File

@ -5,7 +5,7 @@ export ORM_DRIVER="pgsql"
export ORM_OPTION="host=${DBHOST} user=benchmarkdbuser password=benchmarkdbpass dbname=hello_world client_encoding=UTF8"
# 1. Change ULib Server configuration
sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g" $ULIB_ROOT/benchmark.cfg
sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g" $IROOT/ULib/benchmark.cfg
# 2. Start ULib Server (userver_tcp)
$ULIB_ROOT/bin/userver_tcp -c $ULIB_ROOT/benchmark.cfg &
$IROOT/ULib/bin/userver_tcp -c $IROOT/ULib/benchmark.cfg &

View File

@ -5,7 +5,7 @@ export ORM_DRIVER="sqlite"
export ORM_OPTION="host=${DBHOST} user=benchmarkdbuser password=benchmarkdbpass character-set=utf8 dbname=${ULIB_ROOT}/db/%.*s"
# 1. Change ULib Server configuration
sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g" $ULIB_ROOT/benchmark.cfg
sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g" ${IROOT}/ULib/benchmark.cfg
# 2. Start ULib Server (userver_tcp)
$ULIB_ROOT/bin/userver_tcp -c $ULIB_ROOT/benchmark.cfg &
${IROOT}/ULib/bin/userver_tcp -c ${IROOT}/ULib/benchmark.cfg &

View File

@ -43,5 +43,4 @@ const char* hello_str = json_object_to_json_string(hello);
USP_PUTS_STRING(hello_str);
json_object_put(hello);
#endif
U_ClientImage_request_nocache = true;
-->

View File

@ -24,8 +24,6 @@ int main(int argc, char* argv[])
captcha(im, l);
makegif(im, gif);
U_ClientImage_request_nocache = true;
set_reply_capacity(1024 + GIF_SIZE * 3);
(void) u__snprintf(get_reply(), get_reply_capacity(), "<img src=\"data:img/gif;base64,%.*s\">", u_base64_encode(gif, GIF_SIZE, encoded), encoded);

View File

@ -1,6 +1,6 @@
GET /test HTTP/1.1
User-Agent: curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1
Host: 0.0.0.0=5000
Host: 0.0.0.0:5000
Accept: */*
GET /favicon.ico HTTP/1.1
@ -16,9 +16,6 @@ Connection: keep-alive
GET /dumbfuck HTTP/1.0
aaaaaaaaaaaaa:++++++++++
GET /forums/1/topics/2375?page=1#posts-17408 HTTP/1.1
Host: 0.0.0.0=5000
GET /get_no_headers_no_body/world HTTP/1.0
GET /get_one_header_no_body HTTP/1.0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -38,6 +38,7 @@ userver {
DOCUMENT_ROOT benchmark/docroot
PLUGIN_DIR ../../../../src/ulib/net/server/plugin/.libs
ORM_DRIVER_DIR ../../../../src/ulib/orm/driver/.libs
PREFORK_CHILD 2
}
http {
ALIAS [ / /index.php ]

View File

@ -201,6 +201,8 @@ c
c
EOF
killall userver_ssl 2>/dev/null
# webserver_ssl0
creat_config 0
start_test

Binary file not shown.

View File

@ -1,13 +1,15 @@
POST /soap HTTP/1.1
Host: localhost
Accept-Encoding: gzip
User-Agent: ULib/1.4.2
Content-Type: application/soap+xml; charset="utf-8"
Content-Length: 350
<?xml version='1.0' ?><env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><env:Header></env:Header><env:Body><ns:add env:encodingStyle="http://www.w3.org/2003/05/soap-encoding" xmlns:ns="ns"><a xsi:type="xsd:int">10</a><b xsi:type="xsd:int">20</b></ns:add></env:Body></env:Envelope>POST /soap HTTP/1.1
Host: localhost
Accept-Encoding: gzip
User-Agent: ULib/1.4.2
Content-Type: application/soap+xml; charset="utf-8"
Content-Length: 345
<?xml version='1.0' ?><env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><env:Header></env:Header><env:Body><ns:reverse env:encodingStyle="http://www.w3.org/2003/05/soap-encoding" xmlns:ns="ns"><str xsi:type="xsd:string">0123456789</str></ns:reverse></env:Body></env:Envelope>
<?xml version='1.0' ?><env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><env:Header></env:Header><env:Body><ns:reverse env:encodingStyle="http://www.w3.org/2003/05/soap-encoding" xmlns:ns="ns"><str xsi:type="xsd:string">0123456789</str></ns:reverse></env:Body></env:Envelope>