Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanocasazza committed Jan 2, 2019
1 parent a642027 commit 65517dc
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 41 deletions.
29 changes: 10 additions & 19 deletions examples/WiAuth/v2/wi_auth_declaration2.h
Original file line number Diff line number Diff line change
Expand Up @@ -972,33 +972,24 @@ static void GET_acceptTermsOfConditions()
{
U_TRACE_NO_PARAM(5, "::GET_acceptTermsOfConditions()")

// $1 -> ap (with localization => '@')
// $2 -> mac
// $1 -> mac

if (UHTTP::processForm() == 2*2)
if (UHTTP::processForm() == 2)
{
ap->clear();
mac->clear();
UHTTP::getFormValue(*mac, U_CONSTANT_TO_PARAM("mac"), 0, 1, 2);

UHTTP::getFormValue(*ap, U_CONSTANT_TO_PARAM("ap"), 0, 1, 4);

if (setAccessPoint())
if (mac->isMacAddr())
{
UHTTP::getFormValue(*mac, U_CONSTANT_TO_PARAM("mac"), 0, 3, 4);

if (mac->isMacAddr())
{
char buffer[16];
char buffer[16];

u_getXMAC(mac->data(), buffer);
u_getXMAC(mac->data(), buffer);

(void) mac->replace(buffer, 12);
}
(void) mac->replace(buffer, 12);
}

U_ASSERT(mac->isXMacAddr())
U_ASSERT(mac->isXMacAddr())

(void) rc->hmset(U_CONSTANT_TO_PARAM("DEVICE:id:%v ExpirePrivacy %u"), mac->rep, u_now->tv_sec + duration_privacy_policy);
}
(void) rc->hmset(U_CONSTANT_TO_PARAM("DEVICE:id:%v ExpirePrivacy %u"), mac->rep, u_now->tv_sec + duration_privacy_policy);
}
}

Expand Down
29 changes: 29 additions & 0 deletions examples/userver/userver.cfg.default
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ http {

# CGI_TIMEOUT 60
# VIRTUAL_HOST yes
# WEBSOCKET_TIMEOUT -1
# DIGEST_AUTHENTICATION yes

# URI_PROTECTED_MASK /RA/admin/cgi-bin/*
Expand Down Expand Up @@ -686,6 +687,34 @@ http {
# CHECK_EXPIRE_INTERVAL 360
# }

# -----------------------------------------------------------------------------------------------------------------------------------
# nodog - plugin parameters
# -----------------------------------------------------------------------------------------------------------------------------------
# FW_CMD shell script to manage the firewall
# FW_ENV environment for shell script to execute
# DECRYPT_KEY DES3 password stuff
# ALLOWED_MEMBERS file with list of allowed MAC/IP pairs or NETWORKS (default: /etc/nodog.allowed)
# LOCAL_NETWORK_LABEL access point localization tag to be used from portal
# CHECK_EXPIRE_INTERVAL Number of seconds to send client info to portal
# -----------------------------------------------------------------------------------------------------------------------------------

# nodog {

# shell script to manage the firewall
# FW_CMD firewall/nodog.fw
# FW_ENV "FW_CONF=/etc/nodog_fw.conf \
# AuthServiceAddr=http://www.auth-firenze.com/login"

# DES3 password stuff
# DECRYPT_KEY PASSWORD

# access point localization tag to be used from portal
# LOCAL_NETWORK_LABEL "radio1 radio2"

# Number of seconds to check if some client has terminate their connection
# CHECK_EXPIRE_INTERVAL 360
# }

# ----------------------------------------------------------------------------------------------------------------------------------------------------
# U S P P A G E S P A R A M E T E R S
# ----------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions include/ulib/base/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@
#include <ulib/internal/config.h>
#include <ulib/base/replace/replace.h>

#ifndef U_PREFIXDIR
#define U_PREFIXDIR "/usr/local"
#endif
#ifndef U_LIBEXECDIR
#define U_LIBEXECDIR "/usr/local/libexec/ulib"
#endif
#ifndef U_SYSCONFDIR
#define U_SYSCONFDIR "/usr/local/etc"
#endif

/*
#ifndef HAVE_CONFIG_H
Expand Down
6 changes: 5 additions & 1 deletion include/ulib/event/event_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include <ulib/event/event_fd.h>

#define U_QUERY_INFO_SZ 1024
#define U_QUERY_INFO_SZ 168

class UServer_Base;
class UClientImage_Base;
Expand All @@ -27,6 +27,10 @@ class U_EXPORT UEventDB : public UEventFd {
// Check for memory error
U_MEMORY_TEST

// Allocator e Deallocator
U_MEMORY_ALLOCATOR
U_MEMORY_DEALLOCATOR

UEventDB();
~UEventDB();

Expand Down
4 changes: 3 additions & 1 deletion src/ulib/event/event_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ UEventDB::UEventDB()
pthis = (void*)U_CHECK_MEMORY_SENTINEL;
#endif

// U_WARNING("UEventDB::UEventDB(): sizeof(UEventDB) = %u sizeof(query_info) = %u", sizeof(UEventDB), sizeof(query_info)); // sizeof(UEventDB) = 4072|4088 sizeof(query_info) = 24
U_DEBUG("UEventDB::UEventDB(): sizeof(UEventDB) = %u sizeof(query_info) = %u", sizeof(UEventDB), sizeof(query_info)); // sizeof(UEventDB) = 4072|4088 sizeof(query_info) = 24
}

UEventDB::~UEventDB()
Expand Down Expand Up @@ -151,9 +151,11 @@ void UEventDB::handlerQuery(vPFpvu handler, uint32_t num_query)

U_INTERNAL_ASSERT_MINOR(num_result, 4096)

#ifndef U_SERVER_CAPTIVE_PORTAL
if (num_query > 20 ||
(num_result >= 2048 ||
num_handler == U_QUERY_INFO_SZ))
#endif
{
U_DEBUG("UEventDB::handlerQuery(%u): num_result(%u), num_handler(%u)", num_query, num_result, num_handler);

Expand Down
10 changes: 6 additions & 4 deletions src/ulib/net/server/plugin/mod_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,9 @@ int UHttpPlugIn::handlerInit()
{
U_TRACE_NO_PARAM(0, "UHttpPlugIn::handlerInit()")

UServer_Base::update_date =
UServer_Base::update_date3 = true;

U_MEMCPY(ULog::date.header1, "HTTP/1.1 200 OK\r\n",
U_CONSTANT_SIZE("HTTP/1.1 200 OK\r\n")); // 17

Expand Down Expand Up @@ -549,13 +552,12 @@ int UHttpPlugIn::handlerRun() // NB: we use this method instead of handlerInit()
#endif
if (UServer_Base::handler_inotify) UHTTP::initDbNotFound();

UServer_Base::update_date =
UServer_Base::update_date3 = true;

#if defined(U_LINUX) && defined(ENABLE_THREAD) && !defined(U_SERVER_CAPTIVE_PORTAL)
#if defined(U_LINUX) && defined(ENABLE_THREAD)
U_INTERNAL_ASSERT_POINTER(UServer_Base::ptr_shared_data)

# if !defined(U_SERVER_CAPTIVE_PORTAL)
UClientImage_Base::callerHandlerCache = UHTTP::handlerCache;
# endif
UClientImage_Base::iov_vec[1].iov_base = (caddr_t)UServer_Base::ptr_shared_data->log_date_shared.header1;
#endif

Expand Down
24 changes: 14 additions & 10 deletions src/ulib/net/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ class UClientThread : public UThread {
U_DISALLOW_COPY_AND_ASSIGN(UClientThread)
};

# if defined(U_LINUX) && !defined(U_SERVER_CAPTIVE_PORTAL)
# ifdef U_LINUX
class UTimeThread : public UThread {
public:

Expand Down Expand Up @@ -1261,15 +1261,19 @@ class UTimeThread : public UThread {

sec = u_now->tv_sec;

# ifndef U_SERVER_CAPTIVE_PORTAL
if (daylight &&
(sec % U_ONE_HOUR_IN_SECOND) == 0)
{
(void) UTimeDate::checkForDaylightSavingTime(sec);
}
# endif

if (UServer_Base::update_date)
{
# ifndef U_SERVER_CAPTIVE_PORTAL
(void) U_SYSCALL(pthread_rwlock_wrlock, "%p", ULog::prwlock);
# endif

if ((sec % U_ONE_HOUR_IN_SECOND) != 0)
{
Expand All @@ -1286,7 +1290,9 @@ class UTimeThread : public UThread {
if (UServer_Base::update_date3) (void) u_strftime2(ULog::ptr_shared_date->date3+6, 29-4, U_CONSTANT_TO_PARAM("%a, %d %b %Y %T"), sec);
}

# ifndef U_SERVER_CAPTIVE_PORTAL
(void) U_SYSCALL(pthread_rwlock_unlock, "%p", ULog::prwlock);
# endif
}
}
}
Expand Down Expand Up @@ -1797,14 +1803,12 @@ UServer_Base::~UServer_Base()
# endif

# if defined(U_LINUX)
# if !defined(U_SERVER_CAPTIVE_PORTAL)
if (u_pthread_time)
{
U_DELETE((UTimeThread*)u_pthread_time)

(void) pthread_rwlock_destroy(ULog::prwlock);
}
# endif

# if defined(USE_LIBSSL) && !defined(OPENSSL_NO_OCSP) && defined(SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB)
if (bssl)
Expand Down Expand Up @@ -2208,7 +2212,7 @@ void UServer_Base::loadConfigParam()
port = _port;
}

U_INTERNAL_DUMP("SOMAXCONN = %d FD_SETSIZE = %d", SOMAXCONN, FD_SETSIZE)
U_INTERNAL_DUMP("SOMAXCONN = %d FD_SETSIZE = %d timeoutMS = %d", SOMAXCONN, FD_SETSIZE, timeoutMS)

set_tcp_keep_alive = pcfg->readBoolean(U_CONSTANT_TO_PARAM("TCP_KEEP_ALIVE"));
set_realtime_priority = pcfg->readBoolean(U_CONSTANT_TO_PARAM("SET_REALTIME_PRIORITY"), false);
Expand Down Expand Up @@ -3036,9 +3040,7 @@ void UServer_Base::suspendThread()
U_TRACE_NO_PARAM(0, "UServer_Base::suspendThread()")

#if defined(U_LINUX) && defined(ENABLE_THREAD)
# if !defined(U_SERVER_CAPTIVE_PORTAL)
if (u_pthread_time) ((UTimeThread*)u_pthread_time)->suspend();
# endif

# if defined(USE_LIBSSL) && !defined(OPENSSL_NO_OCSP) && defined(SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB)
if (pthread_ocsp) pthread_ocsp->suspend();
Expand Down Expand Up @@ -3359,7 +3361,6 @@ void UServer_Base::init()
if (budp == false)
# endif
{
# if !defined(U_SERVER_CAPTIVE_PORTAL)
if (UServer_Base::update_date)
{
U_NEW_WITHOUT_CHECK_MEMORY(UTimeThread, u_pthread_time, UTimeThread);
Expand All @@ -3368,7 +3369,6 @@ void UServer_Base::init()

((UTimeThread*)u_pthread_time)->start(50);
}
# endif
}
#endif

Expand Down Expand Up @@ -3632,9 +3632,7 @@ void UServer_Base::sendSignalToAllChildren(int signo, sighandler_t handler)
#endif

#if defined(U_LINUX) && defined(ENABLE_THREAD)
# if !defined(U_SERVER_CAPTIVE_PORTAL)
if (u_pthread_time) ((UTimeThread*)u_pthread_time)->resume();
# endif

# if defined(USE_LIBSSL) && !defined(OPENSSL_NO_OCSP) && defined(SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB)
if (pthread_ocsp) pthread_ocsp->resume();
Expand Down Expand Up @@ -4483,6 +4481,7 @@ void UServer_Base::runLoop(const char* user)
if (budp == false)
#endif
{
# ifndef U_SERVER_CAPTIVE_PORTAL
if (handler_db1)
{
UNotifier::min_connection++;
Expand All @@ -4498,6 +4497,7 @@ void UServer_Base::runLoop(const char* user)
handler_db2->UEventFd::op_mask |= EPOLLET;
handler_db2->UEventFd::op_mask &= ~EPOLLRDHUP;
}
# endif

if (handler_other)
{
Expand Down Expand Up @@ -4532,7 +4532,9 @@ void UServer_Base::runLoop(const char* user)
handler_db1->pbusy = U_SRV_DB1_BUSY+rkids;
# endif

# ifndef U_SERVER_CAPTIVE_PORTAL
UNotifier::insert(handler_db1, EPOLLEXCLUSIVE | EPOLLROUNDROBIN); // NB: we ask to be notified for response from db
# endif
}

if (handler_db2)
Expand All @@ -4543,7 +4545,9 @@ void UServer_Base::runLoop(const char* user)
handler_db2->pbusy = U_SRV_DB2_BUSY+rkids;
# endif

# ifndef U_SERVER_CAPTIVE_PORTAL
UNotifier::insert(handler_db2, EPOLLEXCLUSIVE | EPOLLROUNDROBIN); // NB: we ask to be notified for response from db
# endif
}

if (handler_other) // NB: we ask to be notified for request from generic system
Expand Down
21 changes: 17 additions & 4 deletions src/ulib/utility/uhttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11743,12 +11743,27 @@ U_NO_EXPORT bool UHTTP::compileUSP(const char* path, uint32_t len)
U_TRACE(0, "UHTTP::compileUSP(%.*S,%u)", len, path, len)

static int fd_stderr;
static UString* usp_compile_path;

UString command(200U);
if (usp_compile_path == U_NULLPTR)
{
struct stat st;

if (U_SYSCALL(stat, "%S,%p", U_PREFIXDIR "/bin/usp_compile.sh", &st) == 0)
{
U_NEW_ULIB_STRING(usp_compile_path, U_STRING_FROM_CONSTANT(U_PREFIXDIR "/bin/usp_compile.sh"));
}
else
{
U_NEW_ULIB_STRING(usp_compile_path, U_STRING_FROM_CONSTANT("usp_compile.sh"));
}
}

UString command(usp_compile_path->size());

// Ex: usp_compile.sh -i /home/user/project/include -o /home/user/project/build <file.usp> so

command.snprintf(U_CONSTANT_TO_PARAM("usp_compile.sh %.*s %s"), len, path, U_LIB_SUFFIX);
command.snprintf(U_CONSTANT_TO_PARAM("%v %.*s %s"), usp_compile_path->rep, len, path, U_LIB_SUFFIX);

UCommand cmd(command);

Expand Down Expand Up @@ -12019,8 +12034,6 @@ loop: while (u__isalpha(*++ptr1)) {}
{
old_sz = sz;

ULog::updateDate3(U_NULLPTR);

U_http_info.nResponseCode = HTTP_OK;

UClientImage_Base::body->clear();
Expand Down
4 changes: 3 additions & 1 deletion src/ulib/utility/websocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,10 @@ int UWebSocket::handleDataFraming(USocket* socket)
int framing_state = U_WS_DATA_FRAMING_START, payload_length_bytes_remaining = 0, mask_index = 0, masking = 0;

loop:
U_INTERNAL_DUMP("timeoutMS = %d", timeoutMS)

if (rbuffer->empty() &&
USocketExt::read(socket, *rbuffer, U_SINGLE_READ, UWebSocket::timeoutMS) == false)
USocketExt::read(socket, *rbuffer, U_SINGLE_READ, timeoutMS) == false)
{
status_code = U_WS_STATUS_CODE_INTERNAL_ERROR;

Expand Down
2 changes: 1 addition & 1 deletion tests/examples/TSA/tsaserial
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0454
0469

0 comments on commit 65517dc

Please sign in to comment.