Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanocasazza committed Feb 3, 2017
1 parent dfbb912 commit 8ab852b
Show file tree
Hide file tree
Showing 31 changed files with 412 additions and 275 deletions.
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -36621,4 +36621,5 @@ fi
echo
echo "You are now ready to build ULib"
echo "Enter the following command: ${T_MD}make && make install${T_ME}"
echo "After on some environment you must run also the following command: ${T_MD}sudo ldconfig${T_ME}"
echo "***"
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2762,4 +2762,5 @@ fi
echo
echo "You are now ready to build ULib"
echo "Enter the following command: ${T_MD}make && make install${T_ME}"
echo "After on some environment you must run also the following command: ${T_MD}sudo ldconfig${T_ME}"
echo "***"
2 changes: 1 addition & 1 deletion include/ulib/container/hash_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ template <> class U_EXPORT UHashMap<UString> : public UHashMap<UStringRep*> {
UHashMap<UStringRep*>::insertAfterFind(_key, str.rep);
}

uint32_t getSpaceToDump() const;
uint32_t getSpaceToDump() const __pure;

// OPERATOR

Expand Down
2 changes: 1 addition & 1 deletion include/ulib/container/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ template <> class U_EXPORT UVector<UString> : public UVector<UStringRep*> {

uint32_t getSpaceToDump() const
{
U_TRACE_NO_PARAM(0, "UVector<UString>::getSpaceToDump()")
U_TRACE_NO_PARAM(0+256, "UVector<UString>::getSpaceToDump()")

U_CHECK_MEMORY

Expand Down
97 changes: 58 additions & 39 deletions include/ulib/examples/wi_auth_declaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -3761,23 +3761,38 @@ static void usp_init_wi_auth()
U_NEW(UHashMap<UString>, table, UHashMap<UString>);
U_NEW(UHashMap<UString>, table1, UHashMap<UVectorUString>);

U_NEW(UString, telefono, UString);
U_NEW(UString, fmt_auth_cmd, UString);
U_NEW(UString, redirect_default, UString);

U_NEW(UString, url_banner_ap, UString);
U_NEW(UString, url_banner_comune, UString);

U_NEW(UString, help_url, UString);
U_NEW(UString, login_url, UString);
U_NEW(UString, wallet_url, UString);
U_NEW(UString, password_url, UString);
U_NEW(UString, registrazione_url, UString);

U_NEW(UString, des3_key, UString);

if (UFileConfig::loadProperties(*table, content))
{
U_NEW(UString, telefono, UString((*table)["TELEFONO"]));
U_NEW(UString, fmt_auth_cmd, UString((*table)["FMT_AUTH_CMD"]));
U_NEW(UString, redirect_default, UString((*table)["REDIRECT_DEFAULT"]));
*telefono = (*table)["TELEFONO"];
*fmt_auth_cmd = (*table)["FMT_AUTH_CMD"];
*redirect_default = (*table)["REDIRECT_DEFAULT"];

U_NEW(UString, url_banner_ap, UString(UStringExt::expandPath((*table)["URL_BANNER_AP"], environment)));
U_NEW(UString, url_banner_comune, UString(UStringExt::expandPath((*table)["URL_BANNER_COMUNE"], environment)));
*url_banner_ap = UStringExt::expandPath((*table)["URL_BANNER_AP"], environment);
*url_banner_comune = UStringExt::expandPath((*table)["URL_BANNER_COMUNE"], environment);

U_NEW(UString, help_url, UString(UStringExt::expandEnvironmentVar((*table)["HELP_URL"], environment)));
U_NEW(UString, login_url, UString(UStringExt::expandEnvironmentVar((*table)["LOGIN_URL"], environment)));
U_NEW(UString, wallet_url, UString(UStringExt::expandEnvironmentVar((*table)["WALLET_URL"], environment)));
U_NEW(UString, password_url, UString(UStringExt::expandEnvironmentVar((*table)["PASSWORD_URL"], environment)));
U_NEW(UString, registrazione_url, UString(UStringExt::expandEnvironmentVar((*table)["REGISTRAZIONE_URL"], environment)));
*help_url = UStringExt::expandEnvironmentVar((*table)["HELP_URL"], environment);
*login_url = UStringExt::expandEnvironmentVar((*table)["LOGIN_URL"], environment);
*wallet_url = UStringExt::expandEnvironmentVar((*table)["WALLET_URL"], environment);
*password_url = UStringExt::expandEnvironmentVar((*table)["PASSWORD_URL"], environment);
*registrazione_url = UStringExt::expandEnvironmentVar((*table)["REGISTRAZIONE_URL"], environment);

# ifdef USE_LIBSSL
U_NEW(UString, des3_key, UString((*table)["DES3_KEY"]));
*des3_key = (*table)["DES3_KEY"];

UDES3::setPassword(des3_key->c_str());
# endif
Expand Down Expand Up @@ -5719,49 +5734,53 @@ static void GET_login() // MAIN PAGE (se il portatile non mostra la login page c
// GET /login?mac=00%3A14%3AA5%3A6E%3A9C%3ACB&ip=192.168.226.2&redirect=http%3A%2F%2Fgoogle&gateway=192.168.226.1%3A5280&timeout=0&token=x&ap=lab2
// -----------------------------------------------------------------------------------------------------------------------------------------------

if (checkLoginRequest(0, 14, 2, true, false) == false)
{
checkForRedirect();

return;
}

if (checkTimeRequest() == false) return;

auth_domain->clear();

bool login_validate = false;

if (checkLoginRequest(0, 14, 2, true, false))
if (WiAuthNodog::checkMAC() ||
getCookie1())
{
if (checkTimeRequest() == false) return;
*uid = *mac;

auth_domain->clear();
login_validate = true;

if (WiAuthNodog::checkMAC() ||
getCookie1())
{
*uid = *mac;

login_validate = true;
if (auth_domain->empty()) *auth_domain = *mac_auth;
}
#ifdef USE_LIBSSL
else if (UServer_Base::bssl)
{
X509* x509 = ((USSLSocket*)UServer_Base::csocket)->getPeerCertificate();

if (auth_domain->empty()) *auth_domain = *mac_auth;
}
# ifdef USE_LIBSSL
else if (UServer_Base::bssl)
if (x509)
{
X509* x509 = ((USSLSocket*)UServer_Base::csocket)->getPeerCertificate();
long serial = UCertificate::getSerialNumber(x509);
UString issuer = UCertificate::getIssuer(x509);

if (x509)
if (askToLDAP(0,0,0,"ldapsearch -LLL -b %v %v (&(objectClass=waUser)(&(waIssuer=%v)(waSerial=%ld)(waActive=TRUE)))",
wiauth_user_basedn->rep, ldap_user_param->rep, issuer.rep, serial) == 1)
{
long serial = UCertificate::getSerialNumber(x509);
UString issuer = UCertificate::getIssuer(x509);

if (askToLDAP(0,0,0,"ldapsearch -LLL -b %v %v (&(objectClass=waUser)(&(waIssuer=%v)(waSerial=%ld)(waActive=TRUE)))",
wiauth_user_basedn->rep, ldap_user_param->rep, issuer.rep, serial) == 1)
{
*uid = (*table)["waUid"];
*uid = (*table)["waUid"];

table->clear();
table->clear();

*policy = *policy_flat;
*auth_domain = *cert_auth;
*policy = *policy_flat;
*auth_domain = *cert_auth;

login_validate = true;
}
login_validate = true;
}
}
# endif
}
#endif

if (*redirect)
{
Expand Down
1 change: 0 additions & 1 deletion include/ulib/internal/chttp.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ extern U_EXPORT uclientimage_info u_clientimage_info;
#define U_PARALLELIZATION_PARENT 2

#define U_http_info u_clientimage_info.http_info
#define U_clientimage_flag u_clientimage_info.flag
#define U_http_method_list u_clientimage_info.http_method_list
#define U_http_method_type u_clientimage_info.http_info.method_type

Expand Down
12 changes: 6 additions & 6 deletions include/ulib/json/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -1551,21 +1551,21 @@ template <class T> class U_EXPORT UJsonTypeHandler<UVector<T*> > : public UJsonT

U_ASSERT(((uvector*)pval)->empty())

UValue* element = json.toNode();
UValue* pelement = json.toNode();

while (element)
while (pelement)
{
T* pitem;

U_NEW(T, pitem, T);

U_DUMP("element = %p element->next = %p element->type = (%d,%S)", element, element->next, element->getTag(), UValue::getDataTypeDescription(element->getTag()))
U_DUMP("pelement = %p pelement->next = %p pelement->type = (%d,%S)", pelement, pelement->next, pelement->getTag(), UValue::getDataTypeDescription(pelement->getTag()))

element->fromJSON(UJsonTypeHandler<T>(*pitem));
UJsonTypeHandler<T>(*pitem).fromJSON(*pelement);

((uvector*)pval)->push_back(pitem);
((UVector<void*>*)pval)->push_back(pitem);

element = element->next;
pelement = pelement->next;
}
}
};
Expand Down
6 changes: 3 additions & 3 deletions include/ulib/net/server/client_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class U_EXPORT UClientImage_Base : public UEventFd {
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::setRequestToCache()")

# if !defined(U_CACHE_REQUEST_DISABLE) || defined(U_SERVER_CHECK_TIME_BETWEEN_REQUEST)
# if !defined(U_CACHE_REQUEST_DISABLE) || (defined(U_SERVER_CHECK_TIME_BETWEEN_REQUEST) && defined(U_HTTP2_DISABLE))
U_INTERNAL_ASSERT_MAJOR(U_http_info.startHeader, 2)
U_INTERNAL_ASSERT_MAJOR(UClientImage_Base::size_request, 0)
U_INTERNAL_ASSERT_RANGE(1,UClientImage_Base::uri_offset,64)
Expand All @@ -310,7 +310,7 @@ class U_EXPORT UClientImage_Base : public UEventFd {

U_INTERNAL_DUMP("U_ClientImage_request_is_cached = %b", U_ClientImage_request_is_cached)

# if !defined(U_CACHE_REQUEST_DISABLE) || defined(U_SERVER_CHECK_TIME_BETWEEN_REQUEST)
# if !defined(U_CACHE_REQUEST_DISABLE) || (defined(U_SERVER_CHECK_TIME_BETWEEN_REQUEST) && defined(U_HTTP2_DISABLE))
U_INTERNAL_ASSERT(U_ClientImage_request_is_cached)

uint32_t sz = request->size();
Expand Down Expand Up @@ -468,7 +468,7 @@ class U_EXPORT UClientImage_Base : public UEventFd {
static uint32_t ncount, nrequest, resto, uri_offset;

static void endRequest();
static bool startRequest();
static void startRequest();

static void resetReadBuffer();
static void resetWriteBuffer();
Expand Down
2 changes: 1 addition & 1 deletion include/ulib/net/server/plugin/mod_nocat.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class U_EXPORT UNoCatPlugIn : public UServerPlugIn, UEventTime {
static bool checkPeerStatus(UStringRep* key, void* value);
static bool getPeerListInfo(UStringRep* key, void* value);
static void setHTTPResponse(const UString& content, int mime_index);
static void permit(const UString& UserDownloadRate, const UString& UserUploadRate);
static void permit(UString& UserDownloadRate, UString& UserUploadRate);
static void sendMsgToPortal(uint32_t index_AUTH, const UString& msg, UString* poutput);
static void sendData(uint32_t index_AUTH, const UString& data, const char* service, uint32_t service_len);

Expand Down
29 changes: 28 additions & 1 deletion include/ulib/net/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,34 @@ class U_EXPORT UServer_Base : public UEventFd {
static pid_t startNewChild();

static bool startParallelization( uint32_t nclient = 1); // it can creates a copy of itself, return true if parent...
static bool isParallelizationGoingToStart(uint32_t nclient = 1) __pure;
static bool isParallelizationGoingToStart(uint32_t nclient = 1)
{
U_TRACE(0, "UServer_Base::isParallelizationGoingToStart(%u)", nclient)

U_INTERNAL_ASSERT_POINTER(ptr_shared_data)

U_INTERNAL_DUMP("U_ClientImage_pipeline = %b U_ClientImage_parallelization = %d UNotifier::num_connection - UNotifier::min_connection = %d",
U_ClientImage_pipeline, U_ClientImage_parallelization, UNotifier::num_connection - UNotifier::min_connection)

# ifndef U_SERVER_CAPTIVE_PORTAL
# ifndef U_HTTP2_DISABLE
U_INTERNAL_DUMP("U_http_version = %C", U_http_version)

if (U_http_version != '2')
# endif
{
if (U_ClientImage_parallelization != U_PARALLELIZATION_CHILD &&
(UNotifier::num_connection - UNotifier::min_connection) > nclient)
{
U_INTERNAL_DUMP("U_ClientImage_close = %b", U_ClientImage_close)

U_RETURN(true);
}
}
# endif

U_RETURN(false);
}

// manage log server...

Expand Down
4 changes: 3 additions & 1 deletion include/ulib/utility/http2.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class U_EXPORT UHTTP2 {
// streams
uint32_t max_processed_stream_id;
Stream streams[HTTP2_MAX_CONCURRENT_STREAMS];
bool bnghttp2;
#ifdef DEBUG
UHashMap<UString> dtable;
HpackDynamicTable ddyntbl;
Expand Down Expand Up @@ -244,7 +245,7 @@ class U_EXPORT UHTTP2 {
static Connection* pConnection;
static const Settings settings;
static uint32_t wait_for_continuation;
static bool bcontinue100, bsetting_ack, bsetting_send, bnghttp2;
static bool bcontinue100, bsetting_ack, bsetting_send;

static uint8_t priority_weight; // 0 if not set
static bool priority_exclusive;
Expand Down Expand Up @@ -280,6 +281,7 @@ class U_EXPORT UHTTP2 {
static void sendResetStream();
static void sendWindowUpdate();

static bool eraseHeaders(UStringRep* key, void* elem);
static void handlerDelete(UClientImage_Base* pclient);
static void updateSetting(unsigned char* ptr, uint32_t len);
static void writeData(struct iovec* iov, bool bdata, bool flag);
Expand Down
21 changes: 20 additions & 1 deletion include/ulib/utility/uhttp.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,25 @@ class U_EXPORT UHTTP {
U_RETURN(true);
}

static void startRequest()
{
U_TRACE_NO_PARAM(0, "UHTTP::startRequest()")

# if (defined(U_SERVER_CHECK_TIME_BETWEEN_REQUEST) && defined(U_HTTP2_DISABLE)) || (defined(DEBUG) && !defined(U_LOG_DISABLE))
UClientImage_Base::startRequest();
# endif

// ------------------------------
// U_http_info.uri
// ....
// U_http_info.nResponseCode
// ....
// ------------------------------
U_HTTP_INFO_RESET(0);

u_clientimage_info.flag.u = 0;
}

// UPLOAD

static vPFi on_upload;
Expand Down Expand Up @@ -639,7 +658,7 @@ class U_EXPORT UHTTP {
#ifndef U_LOG_DISABLE
static char iov_buffer[20];
static struct iovec iov_vec[10];
# if !defined(U_CACHE_REQUEST_DISABLE) || defined(U_SERVER_CHECK_TIME_BETWEEN_REQUEST)
# if !defined(U_CACHE_REQUEST_DISABLE) || (defined(U_SERVER_CHECK_TIME_BETWEEN_REQUEST) && defined(U_HTTP2_DISABLE))
static uint32_t request_offset, referer_offset, agent_offset;
# endif

Expand Down
4 changes: 2 additions & 2 deletions src/ulib/container/hash_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,9 @@ uint32_t UHashMap<UString>::loadFromData(const char* ptr, uint32_t sz)
U_RETURN(sz);
}

uint32_t UHashMap<UString>::getSpaceToDump() const
__pure uint32_t UHashMap<UString>::getSpaceToDump() const
{
U_TRACE_NO_PARAM(0, "UHashMap<UString>::getSpaceToDump()")
U_TRACE_NO_PARAM(0+256, "UHashMap<UString>::getSpaceToDump()")

U_CHECK_MEMORY

Expand Down
10 changes: 5 additions & 5 deletions src/ulib/debug/debug_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static void print_info(void)

char* memusage = getenv("UMEMUSAGE");

U_MESSAGE("UMEMUSAGE%W<%W%s%W>%W", YELLOW, (memusage ? GREEN : RED), (memusage ? "on" : "off"), YELLOW, RESET);
U_MESSAGE("MEMUSAGE%W<%W%s%W>%W", YELLOW, (memusage ? GREEN : RED), (memusage ? "on" : "off"), YELLOW, RESET);
}

extern "C" void U_EXPORT u_debug_init(void)
Expand Down Expand Up @@ -269,13 +269,13 @@ __noreturn void U_EXPORT u_debug_exec(const char* pathname, char* const argv[],
(void) write(STDERR_FILENO, buffer, iov[1].iov_len);
(void) write(STDERR_FILENO, iov[2].iov_base, iov[2].iov_len);

for (i = 0; argv[i]; ++i) (void) write(STDERR_FILENO, buffer, u__snprintf(buffer, sizeof(buffer), U_CONSTANT_TO_PARAM("argv[%2u] = %p %S"), i, argv[i], argv[i]));
(void) write(STDERR_FILENO, buffer, u__snprintf(buffer, sizeof(buffer), U_CONSTANT_TO_PARAM("argv[%2u] = %p %S"), i, argv[i], argv[i]));
for (i = 0; argv[i]; ++i) (void) write(STDERR_FILENO, buffer, u__snprintf(buffer, sizeof(buffer), U_CONSTANT_TO_PARAM("argv[%2u] = %p %S\n"), i, argv[i], argv[i]));
(void) write(STDERR_FILENO, buffer, u__snprintf(buffer, sizeof(buffer), U_CONSTANT_TO_PARAM("argv[%2u] = %p %S\n"), i, argv[i], argv[i]));

if (envp)
{
for (i = 0; envp[i]; ++i) (void) write(STDERR_FILENO, buffer, u__snprintf(buffer, sizeof(buffer), U_CONSTANT_TO_PARAM("envp[%2u] = %p %S"), i, envp[i], envp[i]));
(void) write(STDERR_FILENO, buffer, u__snprintf(buffer, sizeof(buffer), U_CONSTANT_TO_PARAM("envp[%2u] = %p %S"), i, envp[i], envp[i]));
for (i = 0; envp[i]; ++i) (void) write(STDERR_FILENO, buffer, u__snprintf(buffer, sizeof(buffer), U_CONSTANT_TO_PARAM("envp[%2u] = %p %S\n"), i, envp[i], envp[i]));
(void) write(STDERR_FILENO, buffer, u__snprintf(buffer, sizeof(buffer), U_CONSTANT_TO_PARAM("envp[%2u] = %p %S\n"), i, envp[i], envp[i]));
}
}
else
Expand Down
Loading

0 comments on commit 8ab852b

Please sign in to comment.