mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
fix
This commit is contained in:
parent
a4cc7dde84
commit
9c8b17c297
|
@ -88,7 +88,7 @@ userver application server is since 10th round in the [TechEmpower's web framewo
|
|||
|
||||
## Contributing
|
||||
|
||||
1. Fork it ( https://github.com/stefanocasazza/ULib/fork )
|
||||
1. Fork it ( http://github.com/<my-github-username>/ULib/fork )
|
||||
2. Create your feature branch (`git checkout -b my-new-feature`)
|
||||
3. Commit your changes (`git commit -am 'Add some feature'`)
|
||||
4. Push to the branch (`git push origin my-new-feature`)
|
||||
|
|
|
@ -23,6 +23,7 @@ extern U_EXPORT void runDynamicPage_wi_auth2(int param);
|
|||
U_http_info.endHeader = 0;
|
||||
|
||||
static UHTTP::service_info GET_table[] = { // NB: the table must be ordered alphabetically for binary search...
|
||||
GET_ENTRY(clean),
|
||||
GET_ENTRY(get_config),
|
||||
GET_ENTRY(start_ap),
|
||||
GET_ENTRY(welcome)
|
||||
|
|
|
@ -6,6 +6,7 @@ static void usp_init_wi_auth2();
|
|||
-->
|
||||
<!--#code
|
||||
static UHTTP::service_info GET_table[] = { // NB: the table must be ordered alphabetically for binary search...
|
||||
GET_ENTRY(clean),
|
||||
GET_ENTRY(get_config),
|
||||
GET_ENTRY(start_ap),
|
||||
GET_ENTRY(welcome)
|
||||
|
|
|
@ -27,14 +27,13 @@ static UHTTP::UFileCacheData* welcome_html;
|
|||
static void* peer;
|
||||
static UPing* sockp;
|
||||
static bool ap_consume;
|
||||
static UEventTime* wclean;
|
||||
static UString* policySessionId;
|
||||
static uint8_t policySessionNotify;
|
||||
static uint64_t counter, device_counter;
|
||||
static uint32_t addr, created, lastUpdate, lastReset;
|
||||
|
||||
#define U_TEST
|
||||
#define U_CLEAN_INTERVAL (60 * 60) // 1h
|
||||
#define U_CLEAN_INTERVAL (60U * 60U) // 1h
|
||||
#define U_MAX_TIME_NO_TRAFFIC (15 * 60) // 15m
|
||||
|
||||
#ifdef U_TEST
|
||||
|
@ -54,81 +53,6 @@ enum UPolicy {
|
|||
};
|
||||
*/
|
||||
|
||||
class WiAuthClean : public UEventTime {
|
||||
public:
|
||||
|
||||
WiAuthClean() : UEventTime(U_CLEAN_INTERVAL, 0L)
|
||||
{
|
||||
U_TRACE_REGISTER_OBJECT(0, WiAuthClean, "", U_NULLPTR)
|
||||
}
|
||||
|
||||
virtual ~WiAuthClean() U_DECL_FINAL
|
||||
{
|
||||
U_TRACE_UNREGISTER_OBJECT(0, WiAuthClean)
|
||||
}
|
||||
|
||||
// define method VIRTUAL of class UEventTime
|
||||
|
||||
virtual int handlerTime() U_DECL_FINAL
|
||||
{
|
||||
U_TRACE_NO_PARAM(0, "WiAuthClean::handlerTime()")
|
||||
|
||||
pid_t pid = UServer_Base::startNewChild();
|
||||
|
||||
if (pid > 0) U_RETURN(0); // parent
|
||||
|
||||
// child
|
||||
|
||||
uint8_t status;
|
||||
UString url(100U);
|
||||
|
||||
/*
|
||||
for (uint32_t i = 0, n = vcaptive->size(); i < n; ++i)
|
||||
{
|
||||
url.snprintf(U_CONSTANT_TO_PARAM("http://%v:5280/ping"), vcaptive->at(i).rep);
|
||||
|
||||
// NB: we need PREFORK_CHILD > 2
|
||||
|
||||
if (client->connectServer(url) &&
|
||||
client->sendRequest())
|
||||
{
|
||||
status = 1;
|
||||
|
||||
client->UClient_Base::close();
|
||||
}
|
||||
else
|
||||
{
|
||||
status = 0; // NB: nodog not respond
|
||||
|
||||
if (sockp)
|
||||
{
|
||||
UIPAddress laddr;
|
||||
|
||||
if (client->remoteIPAddress(laddr) &&
|
||||
sockp->ping(laddr))
|
||||
{
|
||||
status = 2; // NB: nodog not respond but pingable => unreachable...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
client->reset();
|
||||
}
|
||||
*/
|
||||
|
||||
if (pid == 0) UServer_Base::endNewChild();
|
||||
|
||||
U_RETURN(0);
|
||||
}
|
||||
|
||||
#if defined(DEBUG) && defined(U_STDCPP_ENABLE)
|
||||
const char* dump(bool _reset) const { return UEventTime::dump(_reset); }
|
||||
#endif
|
||||
|
||||
private:
|
||||
U_DISALLOW_COPY_AND_ASSIGN(WiAuthClean)
|
||||
};
|
||||
|
||||
static void usp_init_wi_auth2()
|
||||
{
|
||||
U_TRACE_NO_PARAM(5, "::usp_init_wi_auth2()")
|
||||
|
@ -313,10 +237,6 @@ loop:
|
|||
delete sockp;
|
||||
sockp = U_NULLPTR;
|
||||
}
|
||||
|
||||
U_NEW(WiAuthClean, wclean, WiAuthClean);
|
||||
|
||||
UTimer::insert(wclean);
|
||||
}
|
||||
|
||||
static void usp_end_wi_auth2()
|
||||
|
@ -340,7 +260,6 @@ static void usp_end_wi_auth2()
|
|||
|
||||
delete rc;
|
||||
delete client;
|
||||
delete wclean;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -500,6 +419,7 @@ static void setSessionPolicy()
|
|||
policySessionNotify = 0; // notify
|
||||
|
||||
(void) rc->hmset(U_CONSTANT_TO_PARAM("DEVICE:id:%v id %v pId DAILY pNotify 0 pCounter 0 lastAccess %u pLastReset %u"), mac->rep, mac->rep, u_now->tv_sec, u_now->tv_sec);
|
||||
(void) rc->zadd(U_CONSTANT_TO_PARAM("DEVICE:bylastAccess %u id:%v"), u_now->tv_sec, mac->rep);
|
||||
}
|
||||
|
||||
U_INTERNAL_DUMP("policySessionId = %V policySessionNotify = %u", policySessionId->rep, policySessionNotify)
|
||||
|
@ -704,6 +624,126 @@ static bool getDataFromPOST(bool bpeer)
|
|||
U_RETURN(false);
|
||||
}
|
||||
|
||||
static void lostSession(bool bclean)
|
||||
{
|
||||
U_TRACE(5, "::lostSession(%b)", bclean)
|
||||
|
||||
if (getSession())
|
||||
{
|
||||
if (bclean)
|
||||
{
|
||||
*ap_label = rc->getString(7);
|
||||
|
||||
(void) rc->hmget(U_CONSTANT_TO_PARAM("CAPTIVE:id:%u ip name"), rc->getULong(6));
|
||||
|
||||
*ap_address = rc->getString(0);
|
||||
*ap_hostname = rc->getString(1);
|
||||
}
|
||||
|
||||
*mac = rc->getString(8);
|
||||
*ip = rc->getString(9);
|
||||
|
||||
U_INTERNAL_ASSERT(u_isIPv4Addr(U_STRING_TO_PARAM(*ip)))
|
||||
|
||||
writeSessionToLOG(U_CONSTANT_TO_PARAM("DENY_LOST"));
|
||||
|
||||
deleteSession();
|
||||
}
|
||||
}
|
||||
|
||||
static void GET_clean()
|
||||
{
|
||||
U_TRACE_NO_PARAM(5, "::GET_clean()")
|
||||
|
||||
if (UServer_Base::isLocalHost() == false) UHTTP::setBadRequest();
|
||||
else
|
||||
{
|
||||
uint32_t i, n, last_update = u_now->tv_sec - U_CLEAN_INTERVAL;
|
||||
|
||||
(void) rc->zrangebyscore(U_CONSTANT_TO_PARAM("SESSION:byLastUpdate 0 %u"), last_update);
|
||||
|
||||
if ((n = rc->vitem.size()))
|
||||
{
|
||||
UVector<UString> vec(n);
|
||||
|
||||
vec.copy(rc->vitem);
|
||||
|
||||
for (i = 0; i < n; ++i)
|
||||
{
|
||||
*key_session = vec[i];
|
||||
|
||||
lostSession(true);
|
||||
}
|
||||
}
|
||||
|
||||
(void) rc->zrangebyscore(U_CONSTANT_TO_PARAM("CAPTIVE:byLastUpdate 0 %u"), last_update);
|
||||
|
||||
if ((n = rc->vitem.size()))
|
||||
{
|
||||
uint8_t status;
|
||||
UString url(100U);
|
||||
|
||||
for (i = 0; i < n; ++i)
|
||||
{
|
||||
*ap_address = rc->vitem[i];
|
||||
|
||||
(void) UIPAddress::getBinaryForm(ap_address->c_str(), addr, true);
|
||||
|
||||
url.snprintf(U_CONSTANT_TO_PARAM("http://%v:5280/ping"), ap_address->rep);
|
||||
|
||||
// NB: we need PREFORK_CHILD > 2
|
||||
|
||||
if (client->connectServer(url) &&
|
||||
client->sendRequest())
|
||||
{
|
||||
status = '3';
|
||||
|
||||
client->UClient_Base::close();
|
||||
}
|
||||
else
|
||||
{
|
||||
status = '0'; // NB: nodog not respond
|
||||
|
||||
if (sockp)
|
||||
{
|
||||
UIPAddress laddr;
|
||||
|
||||
if (client->remoteIPAddress(laddr) &&
|
||||
sockp->ping(laddr))
|
||||
{
|
||||
status = '2'; // NB: nodog not respond but pingable => unreachable...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
client->reset();
|
||||
|
||||
(void) rc->hmset(U_CONSTANT_TO_PARAM("CAPTIVE:id:%u status %c"), addr, status);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
(void) rc->zrangebyscore(U_CONSTANT_TO_PARAM("DEVICE:bylastAccess 0 %u"), u_now->tv_sec - U_CLEAN_INTERVAL);
|
||||
|
||||
if ((n = rc->vitem.size()))
|
||||
{
|
||||
UString x;
|
||||
UVector<UString> vec(n);
|
||||
|
||||
vec.copy(rc->vitem);
|
||||
|
||||
for (i = 0; i < n; ++i)
|
||||
{
|
||||
x = vec[i];
|
||||
|
||||
(void) rc->del(U_CONSTANT_TO_PARAM("DEVICE:%v"), x.rep);
|
||||
(void) rc->zrem(U_CONSTANT_TO_PARAM("DEVICE:bylastAccess %v"), x.rep);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
static void GET_get_config()
|
||||
{
|
||||
U_TRACE_NO_PARAM(5, "::GET_get_config()")
|
||||
|
@ -879,6 +919,7 @@ static void GET_start_ap()
|
|||
U_LOGGER("%v %s", getApInfo().rep, pid.strtol() == -1 ? "started" : "*** NODOG CRASHED ***");
|
||||
|
||||
(void) rc->hmset(U_CONSTANT_TO_PARAM("CAPTIVE:id:%u name %v status 1 uptime %v since %u lastUpdate %u"), addr, ap_hostname->rep, uptime.rep, u_now->tv_sec, u_now->tv_sec);
|
||||
(void) rc->zadd(U_CONSTANT_TO_PARAM("CAPTIVE:byLastUpdate %u %v"), u_now->tv_sec, ap_address->rep);
|
||||
|
||||
x.snprintf(U_CONSTANT_TO_PARAM("%u"), addr);
|
||||
|
||||
|
@ -909,20 +950,7 @@ static void GET_start_ap()
|
|||
|
||||
key_session->snprintf(U_CONSTANT_TO_PARAM("%v%v;%v"), x.rep, ap_label->rep, vec[i].rep);
|
||||
|
||||
if (getSession())
|
||||
{
|
||||
U_ASSERT_EQUALS(addr, rc->getULong(6))
|
||||
U_ASSERT_EQUALS(*ap_label, rc->getString(7))
|
||||
|
||||
*mac = rc->getString(8);
|
||||
*ip = rc->getString(9);
|
||||
|
||||
U_INTERNAL_ASSERT(u_isIPv4Addr(U_STRING_TO_PARAM(*ip)))
|
||||
|
||||
writeSessionToLOG(U_CONSTANT_TO_PARAM("DENY_LOST"));
|
||||
|
||||
deleteSession();
|
||||
}
|
||||
lostSession(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1114,6 +1142,7 @@ static void POST_info()
|
|||
uint32_t _ctime, ctraffic, time_no_traffic, ctime_no_traffic, op_len, midnigth = u_getLocalTime() / U_ONE_DAY_IN_SECOND;
|
||||
|
||||
(void) rc->hmset(U_CONSTANT_TO_PARAM("CAPTIVE:id:%u status 1 lastUpdate %u"), addr, u_now->tv_sec);
|
||||
(void) rc->zadd(U_CONSTANT_TO_PARAM("CAPTIVE:byLastUpdate %u %v"), u_now->tv_sec, ap_address->rep);
|
||||
|
||||
for (int32_t i = 1, n = (int32_t) vec.GetSize(); i < n; i += 6)
|
||||
{
|
||||
|
@ -1190,17 +1219,20 @@ del_login: vec_logout.push_back(*ip);
|
|||
|
||||
if (ctraffic)
|
||||
{
|
||||
(void) rc->hmset(U_CONSTANT_TO_PARAM("SESSION:%v counter %llu lastUpdate %u"), key_session->rep, counter+ctraffic, u_now->tv_sec);
|
||||
counter += ctraffic;
|
||||
|
||||
if (ap_consume &&
|
||||
policySessionId->equal(U_CONSTANT_TO_PARAM("DAILY")) &&
|
||||
rc->hincrby(U_CONSTANT_TO_PARAM("DEVICE:id:%v pCounter %llu"), mac->rep, ctraffic) >= U_MAX_TRAFFIC_DAILY)
|
||||
rc->hincrby(U_CONSTANT_TO_PARAM("DEVICE:id:%v pCounter %u"), mac->rep, ctraffic) >= U_MAX_TRAFFIC_DAILY)
|
||||
{
|
||||
op = "DENY_POLICY";
|
||||
op_len = U_CONSTANT_SIZE("DENY_POLICY");
|
||||
|
||||
goto del_sess;
|
||||
}
|
||||
|
||||
(void) rc->hmset(U_CONSTANT_TO_PARAM("SESSION:%v counter %llu lastUpdate %u"), key_session->rep, counter, u_now->tv_sec);
|
||||
(void) rc->zadd(U_CONSTANT_TO_PARAM("SESSION:byLastUpdate %u %v"), u_now->tv_sec, key_session->rep);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ typedef struct ustring { struct ustringrep* rep; } ustring;
|
|||
/* Internal buffer */
|
||||
|
||||
extern U_EXPORT char* u_buffer;
|
||||
extern U_EXPORT char* u_err_buffer;
|
||||
extern U_EXPORT char u_err_buffer[256];
|
||||
extern U_EXPORT uint32_t u_buffer_len; /* assert that u_buffer is busy if u_buffer_len != 0 */
|
||||
|
||||
/* Startup */
|
||||
|
|
|
@ -269,8 +269,18 @@ public:
|
|||
U_RETURN(false);
|
||||
}
|
||||
|
||||
static bool isLocalHost(uint32_t i)
|
||||
{
|
||||
U_TRACE(0, "UIPAddress::isLocalHost(%#X)", i)
|
||||
|
||||
if ((i & htonl(0xFF000000)) == htonl(0x7F000000)) U_RETURN(true); /* If it is 0.0.0.0 or starts with 127.0.0.1 then it is probably localhost */
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
bool isPrivate() __pure;
|
||||
bool isWildCard() __pure;
|
||||
bool isLocalHost() __pure;
|
||||
|
||||
static UString toString(uint8_t* paddr);
|
||||
static UString toString(in_addr_t addr) { return toString((uint8_t*)&addr); }
|
||||
|
|
|
@ -632,6 +632,8 @@ public:
|
|||
#define U_CLIENT_ADDRESS_TO_PARAM UServer_Base::client_address, UServer_Base::client_address_len
|
||||
#define U_CLIENT_ADDRESS_TO_TRACE UServer_Base::client_address_len, UServer_Base::client_address
|
||||
|
||||
static bool isLocalHost() { return csocket->cRemoteAddress.isLocalHost(); }
|
||||
|
||||
static void setClientAddress() { setClientAddress(csocket, client_address, client_address_len); }
|
||||
|
||||
static UString getIPAddress() { return *IP_address; }
|
||||
|
|
|
@ -136,7 +136,7 @@ const char* restrict u_name_function;
|
|||
/* Internal buffer */
|
||||
|
||||
char* u_buffer;
|
||||
char* u_err_buffer;
|
||||
char u_err_buffer[256];
|
||||
uint32_t u_buffer_len; /* signal that is busy if != 0 */
|
||||
|
||||
/* Time services */
|
||||
|
@ -2301,6 +2301,8 @@ case_R: /* extension: print msg - u_getSysError() */
|
|||
|
||||
u_getSysError((uint32_t*)&len);
|
||||
|
||||
U_INTERNAL_ASSERT_MINOR(len, sizeof(u_err_buffer))
|
||||
|
||||
(void) memcpy(bp, u_err_buffer, len);
|
||||
|
||||
bp += len;
|
||||
|
@ -2451,6 +2453,8 @@ number: /* uint32_t conversions */
|
|||
case_Y: /* extension: print u_getSysSignal(signo) */
|
||||
u_getSysSignal(VA_ARG(int), (uint32_t*)&len);
|
||||
|
||||
U_INTERNAL_ASSERT_MINOR(len, sizeof(u_err_buffer))
|
||||
|
||||
(void) memcpy(bp, u_err_buffer, len);
|
||||
|
||||
bp += len;
|
||||
|
@ -2588,6 +2592,8 @@ case_q: /* field length modifier: quad. This is a synonym for ll */
|
|||
case_r: /* extension: print u_getExitStatus(exit_value) */
|
||||
u_getExitStatus(VA_ARG(int), (uint32_t*)&len);
|
||||
|
||||
U_INTERNAL_ASSERT_MINOR(len, sizeof(u_err_buffer))
|
||||
|
||||
(void) memcpy(bp, u_err_buffer, len);
|
||||
|
||||
bp += len;
|
||||
|
|
|
@ -502,9 +502,7 @@ void u_getSysError(uint32_t* restrict len)
|
|||
}
|
||||
}
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(u_err_buffer)
|
||||
|
||||
*len = snprintf(u_err_buffer, 256, "%s (%d, %s)", name, errno, msg);
|
||||
*len = snprintf(u_err_buffer, U_CONSTANT_SIZE(u_err_buffer), "%s (%d, %s)", name, errno, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -719,9 +717,7 @@ void u_getSysSignal(int signo, uint32_t* restrict len)
|
|||
}
|
||||
}
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(u_err_buffer)
|
||||
|
||||
*len = snprintf(u_err_buffer, 256, "%s (%d, %s)", name, signo, msg);
|
||||
*len = snprintf(u_err_buffer, U_CONSTANT_SIZE(u_err_buffer), "%s (%d, %s)", name, signo, msg);
|
||||
}
|
||||
|
||||
#undef U_SIG_ENTRY
|
||||
|
@ -831,7 +827,5 @@ void u_getExitStatus(int exitno, uint32_t* restrict len)
|
|||
}
|
||||
}
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(u_err_buffer)
|
||||
|
||||
*len = snprintf(u_err_buffer, 256, "%s (%d, %s)", name, exitno, msg);
|
||||
*len = snprintf(u_err_buffer, U_CONSTANT_SIZE(u_err_buffer), "%s (%d, %s)", name, exitno, msg);
|
||||
}
|
||||
|
|
|
@ -198,8 +198,6 @@ void ULib::init(char** argv, const char* mempool)
|
|||
|
||||
if (ptr < u_buffer) u_buffer = (char*)ptr;
|
||||
|
||||
if (u_err_buffer == U_NULLPTR) u_err_buffer = (char*) UMemoryPool::pop(U_SIZE_TO_STACK_INDEX(256));
|
||||
|
||||
U_INTERNAL_DUMP("ptr = %p u_buffer = %p diff = %ld", ptr, u_buffer, ptr - u_buffer)
|
||||
|
||||
# ifdef DEBUG
|
||||
|
@ -208,15 +206,13 @@ void ULib::init(char** argv, const char* mempool)
|
|||
#else
|
||||
u_buffer = (char*) U_SYSCALL(malloc, "%u", U_BUFFER_SIZE);
|
||||
|
||||
if (u_err_buffer == U_NULLPTR) u_err_buffer = (char*) U_SYSCALL(malloc, "%u", 256);
|
||||
|
||||
# ifdef DEBUG
|
||||
UMemoryError::pbuffer = (char*) U_SYSCALL(malloc, "%u", U_MAX_SIZE_PREALLOCATE);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
UFlatBuffer::setStack((uint8_t*)u_err_buffer, 256);
|
||||
UFlatBuffer::setBuffer((uint8_t*)u_buffer, U_BUFFER_SIZE);
|
||||
UFlatBuffer::setStack((uint8_t*)u_err_buffer, U_CONSTANT_SIZE(u_err_buffer));
|
||||
|
||||
#if defined(U_STATIC_ONLY)
|
||||
if (UStringRep::string_rep_null == U_NULLPTR)
|
||||
|
|
|
@ -302,15 +302,6 @@ void UMemoryPool::allocateMemoryBlocks(const char* ptr)
|
|||
#if defined(U_LINUX) && defined(MAP_HUGE_2MB)
|
||||
if (UFile::rlimit_memfree == U_2M)
|
||||
{
|
||||
# ifdef DEBUG
|
||||
if (u_err_buffer == U_NULLPTR)
|
||||
{
|
||||
static char buffer[256];
|
||||
|
||||
u_err_buffer = buffer;
|
||||
}
|
||||
# endif
|
||||
|
||||
// cat /proc/meminfo | grep Huge
|
||||
|
||||
UFile::nr_hugepages = UFile::setSysParam("/proc/sys/vm/nr_hugepages", 64);
|
||||
|
|
|
@ -575,7 +575,11 @@ void ULog::log(int lfd, const char* fmt, uint32_t fmt_size, ...)
|
|||
|
||||
va_end(argp);
|
||||
|
||||
if (lfd == UServer_Base::log->getFd()) UServer_Base::log->write(buffer, len);
|
||||
if (UServer_Base::isLog() &&
|
||||
lfd == UServer_Base::log->getFd())
|
||||
{
|
||||
UServer_Base::log->write(buffer, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
U_INTERNAL_ASSERT_EQUALS(iov_vec[0].iov_len, 17)
|
||||
|
@ -671,7 +675,7 @@ void ULog::log(const struct iovec* iov, const char* type, int ncount, const char
|
|||
}
|
||||
|
||||
len = (UServer_Base::mod_name[0][0] ? u__snprintf(buffer2, U_CONSTANT_SIZE(buffer2), U_CONSTANT_TO_PARAM("%s"), UServer_Base::mod_name) : 0);
|
||||
len += u__snprintf(buffer2+len, U_CONSTANT_SIZE(buffer2)-len, U_CONSTANT_TO_PARAM("send %s (%u bytes) %.*s%#.*S"), type, ncount, msg_len, msg, (sz <= (uint32_t)ncount ? sz : ncount), ptr);
|
||||
len += u__snprintf(buffer2+len, U_CONSTANT_SIZE(buffer2)-len, U_CONSTANT_TO_PARAM("send %s (%u bytes) %.*s%#.*S"),type,ncount,msg_len,msg,(sz <= (uint32_t)ncount ? sz : ncount),ptr);
|
||||
|
||||
va_list argp;
|
||||
va_start(argp, fmt_size);
|
||||
|
|
|
@ -571,14 +571,12 @@ __pure bool UIPAddress::isPrivate()
|
|||
|
||||
U_RETURN(false);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
U_INTERNAL_ASSERT_EQUALS(iAddressType, AF_INET)
|
||||
U_INTERNAL_ASSERT_EQUALS(iAddressLength, sizeof(in_addr))
|
||||
|
||||
if (isPrivate(htonl(pcAddress.i))) U_RETURN(true);
|
||||
}
|
||||
U_INTERNAL_ASSERT_EQUALS(iAddressType, AF_INET)
|
||||
U_INTERNAL_ASSERT_EQUALS(iAddressLength, sizeof(in_addr))
|
||||
|
||||
if (isPrivate(htonl(pcAddress.i))) U_RETURN(true);
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
@ -598,18 +596,37 @@ __pure bool UIPAddress::isWildCard()
|
|||
|
||||
U_RETURN(false);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(iAddressType, AF_INET)
|
||||
U_INTERNAL_ASSERT_EQUALS(iAddressLength, sizeof(in_addr))
|
||||
|
||||
U_DUMP("htonl(pcAddress.i) = %#X %V", htonl(pcAddress.i), UIPAddress::toString(getInAddr()).rep)
|
||||
|
||||
if (pcAddress.i == 0x00000000) U_RETURN(true);
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
__pure bool UIPAddress::isLocalHost()
|
||||
{
|
||||
U_TRACE_NO_PARAM(0, "UIPAddress::isLocalHost()")
|
||||
|
||||
U_CHECK_MEMORY
|
||||
|
||||
#ifdef ENABLE_IPV6
|
||||
if (iAddressType == AF_INET6)
|
||||
{
|
||||
U_INTERNAL_ASSERT_EQUALS(iAddressType, AF_INET)
|
||||
U_INTERNAL_ASSERT_EQUALS(iAddressLength, sizeof(in_addr))
|
||||
|
||||
U_DUMP("htonl(pcAddress.i) = %#X %V", htonl(pcAddress.i), UIPAddress::toString(getInAddr()).rep)
|
||||
|
||||
if (htonl(pcAddress.i) == 0x00000000) U_RETURN(true);
|
||||
// TODO
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(iAddressType, AF_INET)
|
||||
U_INTERNAL_ASSERT_EQUALS(iAddressLength, sizeof(in_addr))
|
||||
|
||||
if (isLocalHost(pcAddress.i)) U_RETURN(true);
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
#include <ulib/base/hash.h>
|
||||
|
||||
#ifndef HAVE_ARCH64
|
||||
# define U_FLAT_BUFFERS_SPACE_STACK 1024U
|
||||
# define U_FLAT_BUFFERS_SPACE_BUFFER 1024U
|
||||
# define U_FLAT_BUFFERS_SPACE_STACK 512U
|
||||
# define U_FLAT_BUFFERS_SPACE_BUFFER (8U * 1024U)
|
||||
#endif
|
||||
|
||||
#include <ulib/date.h>
|
||||
|
@ -525,11 +525,11 @@ U_NO_EXPORT void UNoDogPlugIn::erasePeer()
|
|||
|
||||
U_INTERNAL_ASSERT_POINTER(peer)
|
||||
|
||||
printPeers(U_CONSTANT_TO_PARAM("before erase"));
|
||||
// printPeers(U_CONSTANT_TO_PARAM("before erase"));
|
||||
|
||||
delete peers->erase(peer->ip);
|
||||
|
||||
printPeers(U_CONSTANT_TO_PARAM("after erase"));
|
||||
// printPeers(U_CONSTANT_TO_PARAM("after erase"));
|
||||
|
||||
U_ASSERT_EQUALS(peers->at(peer->ip), U_NULLPTR)
|
||||
}
|
||||
|
@ -993,10 +993,12 @@ int UNoDogPlugIn::handlerRequest()
|
|||
|
||||
U_http_info.nResponseCode = HTTP_NO_CONTENT;
|
||||
|
||||
(void) UServer_Base::csocket->shutdown(SHUT_RD);
|
||||
|
||||
U_INTERNAL_DUMP("UServer_Base::client_address = %.*S", U_CLIENT_ADDRESS_TO_TRACE)
|
||||
|
||||
U_SRV_LOG("Start REQUEST phase of plugin nodog: %.*S client_address = %.*S", U_HTTP_URI_TO_TRACE, U_CLIENT_ADDRESS_TO_TRACE);
|
||||
|
||||
(void) UServer_Base::csocket->shutdown(SHUT_RD);
|
||||
|
||||
if (UServer_Base::auth_ip->equal(U_CLIENT_ADDRESS_TO_PARAM))
|
||||
{
|
||||
// ------------------------------------------
|
||||
|
@ -1138,6 +1140,8 @@ bad: UHTTP::setBadRequest();
|
|||
goto end;
|
||||
}
|
||||
|
||||
U_SRV_LOG("Start REQUEST_FROM_USER phase of plugin nodog: %.*S", U_HTTP_URI_TO_TRACE);
|
||||
|
||||
printPeers(U_CONSTANT_TO_PARAM("user request"));
|
||||
|
||||
if (peers->empty() == false &&
|
||||
|
|
|
@ -388,10 +388,6 @@ void UInterrupt::getSignalInfo(int signo, siginfo_t* info)
|
|||
CYAN, (double)rss / (1024.0 * 1024.0), YELLOW);
|
||||
}
|
||||
# endif
|
||||
|
||||
#if defined(DEBUG) && defined(U_SERVER_CAPTIVE_PORTAL) && !defined(ENABLE_THREAD)
|
||||
UError::stackDump();
|
||||
#endif
|
||||
}
|
||||
|
||||
__noreturn RETSIGTYPE UInterrupt::handlerInterruptWithInfo(int signo, siginfo_t* info, void* context)
|
||||
|
|
|
@ -35,14 +35,11 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
int n_cmp;
|
||||
unsigned len;
|
||||
char l_err_buffer[256];
|
||||
|
||||
u_init_ulib(argv);
|
||||
u_init_ulib_hostname();
|
||||
u_init_ulib_username();
|
||||
|
||||
u_err_buffer = l_err_buffer;
|
||||
|
||||
#ifdef __MINGW32__
|
||||
n_cmp = 8;
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue
Block a user