handler: fix valid for taking ms
This commit is contained in:
@@ -83,6 +83,6 @@
|
|||||||
"traffic_log_file": "./traffic.csv"
|
"traffic_log_file": "./traffic.csv"
|
||||||
},
|
},
|
||||||
|
|
||||||
// how long the token (solved challenge) should be valid for before showing a new challenge, in minutes
|
// how long the token (solved challenge) should be valid for before showing a new challenge, in seconds
|
||||||
"token_valid_for": 60 // 1 hour
|
"token_valid_for": 3600 // 1 hour
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ class CConfig {
|
|||||||
bool trace_logging = false;
|
bool trace_logging = false;
|
||||||
std::vector<SConfigRule> rules = {};
|
std::vector<SConfigRule> rules = {};
|
||||||
int default_challenge_difficulty = 4;
|
int default_challenge_difficulty = 4;
|
||||||
int token_valid_for = 60;
|
int token_valid_for = 3600;
|
||||||
bool async_proxy = true;
|
bool async_proxy = true;
|
||||||
std::vector<SProxyRule> proxy_rules;
|
std::vector<SProxyRule> proxy_rules;
|
||||||
|
|
||||||
|
|||||||
@@ -215,13 +215,13 @@ void CServerHandler::onRequest(const Pistache::Http::Request& req, Pistache::Htt
|
|||||||
if (TOKEN.valid()) {
|
if (TOKEN.valid()) {
|
||||||
const auto AGE = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() -
|
const auto AGE = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() -
|
||||||
std::chrono::duration_cast<std::chrono::milliseconds>(TOKEN.issued().time_since_epoch()).count();
|
std::chrono::duration_cast<std::chrono::milliseconds>(TOKEN.issued().time_since_epoch()).count();
|
||||||
if (AGE <= g_pConfig->m_config.token_valid_for && TOKEN.fingerprint() == NRequestUtils::fingerprintForRequest(req)) {
|
if (AGE <= g_pConfig->m_config.token_valid_for * 1000 && TOKEN.fingerprint() == NRequestUtils::fingerprintForRequest(req)) {
|
||||||
Debug::log(LOG, " | Action: PASS (token)");
|
Debug::log(LOG, " | Action: PASS (token)");
|
||||||
g_pTrafficLogger->logTraffic(req, "PASS (token)");
|
g_pTrafficLogger->logTraffic(req, "PASS (token)");
|
||||||
proxyPass(req, response);
|
proxyPass(req, response);
|
||||||
return;
|
return;
|
||||||
} else { // token has been used from a different IP or is expired. Nuke it.
|
} else { // token has been used from a different IP or is expired. Nuke it.
|
||||||
if (AGE > g_pConfig->m_config.token_valid_for)
|
if (AGE > g_pConfig->m_config.token_valid_for * 1000)
|
||||||
Debug::log(LOG, " | Action: CHALLENGE (token expired)");
|
Debug::log(LOG, " | Action: CHALLENGE (token expired)");
|
||||||
else
|
else
|
||||||
Debug::log(LOG, " | Action: CHALLENGE (token fingerprint mismatch)");
|
Debug::log(LOG, " | Action: CHALLENGE (token fingerprint mismatch)");
|
||||||
|
|||||||
Reference in New Issue
Block a user