f
This commit is contained in:
1 parent
ffb1fc00f3
commit
b120d441d5
2 files changed
+13
-2
No files matched your search
@@ -83,6 +83,17 @@ class config{
|
|||||||
//["minecraft", 848]
|
//["minecraft", 848]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
//
|
||||||
|
// HMAC SIGNATURES
|
||||||
|
//
|
||||||
|
// If null, no signatures are added to proxy URLs and resolver targets.
|
||||||
|
// If a hex string, will be used as the secret and signatures will be appended.
|
||||||
|
// Generate one in a PHP session like this: echo bin2hex(random_bytes(32));
|
||||||
|
const HMAC_SECRET = null;
|
||||||
|
|
||||||
|
// Time the tokens remain valid, in minutes
|
||||||
|
const HMAC_TTL = 720;
|
||||||
|
|
||||||
// If this regex expression matches on the user agent, it blocks the request
|
// If this regex expression matches on the user agent, it blocks the request
|
||||||
// Not useful at all against a targetted attack
|
// Not useful at all against a targetted attack
|
||||||
const HEADER_REGEX = '/bot|wget|curl|python-requests|scrapy|go-http-client|ruby|yahoo|spider|qwant|meta/i';
|
const HEADER_REGEX = '/bot|wget|curl|python-requests|scrapy|go-http-client|ruby|yahoo|spider|qwant|meta/i';
|
||||||
|
|||||||
+2
-2
@@ -347,7 +347,7 @@ class backend{
|
|||||||
|
|
||||||
$header = pack("CN", $purpose, intdiv(time(), 60));
|
$header = pack("CN", $purpose, intdiv(time(), 60));
|
||||||
|
|
||||||
$hash = hash_hmac("sha256", $header . $payload, config::HMAC_SECRET, true);
|
$hash = hash_hmac("sha256", $header . $payload, hex2bin(config::HMAC_SECRET), true);
|
||||||
|
|
||||||
return rtrim(strtr(base64_encode(
|
return rtrim(strtr(base64_encode(
|
||||||
$header . $hash
|
$header . $hash
|
||||||
@@ -403,7 +403,7 @@ class backend{
|
|||||||
|
|
||||||
// check hmac
|
// check hmac
|
||||||
$r_header = pack("CN", $expected_purpose, $timestamp);
|
$r_header = pack("CN", $expected_purpose, $timestamp);
|
||||||
$r_hash = hash_hmac("sha256", $r_header . $payload, config::HMAC_SECRET, true);
|
$r_hash = hash_hmac("sha256", $r_header . $payload, hex2bin(config::HMAC_SECRET), true);
|
||||||
|
|
||||||
if(!hash_equals($signature, $r_hash)){
|
if(!hash_equals($signature, $r_hash)){
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user