Separated the TTL so that invalid sessions can be expired faster than valid sessions (DDOS protection and better error handling)
This commit is contained in:
parent
aaaed4fce9
commit
68240908bc
@ -169,6 +169,11 @@ static bool configure(ptr<conf>& cf)
|
||||
pr->ttl(30000);
|
||||
else
|
||||
pr->ttl(*x_cf);
|
||||
|
||||
if (!(x_cf = pr_cf->find("deadtime")))
|
||||
pr->deadtime(pr->ttl());
|
||||
else
|
||||
pr->deadtime(*x_cf);
|
||||
|
||||
if (!(x_cf = pr_cf->find("timeout")))
|
||||
pr->timeout(500);
|
||||
|
12
src/proxy.cc
12
src/proxy.cc
@ -30,7 +30,7 @@ NDPPD_NS_BEGIN
|
||||
std::list<ptr<proxy> > proxy::_list;
|
||||
|
||||
proxy::proxy() :
|
||||
_router(true), _ttl(30000), _timeout(500), _autowire(false)
|
||||
_router(true), _ttl(30000), _deadtime(3000), _timeout(500), _autowire(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -197,6 +197,16 @@ void proxy::ttl(int val)
|
||||
_ttl = (val >= 0) ? val : 30000;
|
||||
}
|
||||
|
||||
int proxy::deadtime() const
|
||||
{
|
||||
return _deadtime;
|
||||
}
|
||||
|
||||
void proxy::deadtime(int val)
|
||||
{
|
||||
_deadtime = (val >= 0) ? val : 30000;
|
||||
}
|
||||
|
||||
int proxy::timeout() const
|
||||
{
|
||||
return _timeout;
|
||||
|
@ -60,6 +60,10 @@ public:
|
||||
int ttl() const;
|
||||
|
||||
void ttl(int val);
|
||||
|
||||
int deadtime() const;
|
||||
|
||||
void deadtime(int val);
|
||||
|
||||
private:
|
||||
static std::list<ptr<proxy> > _list;
|
||||
@ -76,7 +80,7 @@ private:
|
||||
|
||||
bool _autowire;
|
||||
|
||||
int _ttl, _timeout;
|
||||
int _ttl, _deadtime, _timeout;
|
||||
|
||||
proxy();
|
||||
};
|
||||
|
@ -45,7 +45,7 @@ void session::update_all(int elapsed_time)
|
||||
case session::WAITING:
|
||||
logger::debug() << "session is now invalid";
|
||||
se->_status = session::INVALID;
|
||||
se->_ttl = se->_pr->ttl();
|
||||
se->_ttl = se->_pr->deadtime();
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -81,7 +81,7 @@ ptr<session> session::create(const ptr<proxy>& pr, const address& saddr,
|
||||
|
||||
logger::debug()
|
||||
<< "session::create() pr=" << logger::format("%x", (proxy* )pr) << ", saddr=" << saddr
|
||||
<< ", daddr=" << daddr << ", taddr=" << taddr << ", autowire=" << (_autowire ? "yes" : "no") << " =" << logger::format("%x", (session* )se);
|
||||
<< ", daddr=" << daddr << ", taddr=" << taddr << ", autowire=" << (auto_wire == true ? "yes" : "no") << " =" << logger::format("%x", (session* )se);
|
||||
|
||||
return se;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user