mirror of
https://github.com/simonmicro/Pritunl-Fake-API.git
synced 2025-12-06 02:56:59 -05:00
Compare commits
2 Commits
3f7fa53eb3
...
a76ad96f96
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a76ad96f96 | ||
|
|
34ff12f64f |
@ -4,18 +4,27 @@
|
||||
// Config
|
||||
$minVersionNumber = 1003235044068;
|
||||
$minVersionName = '1.32.3504.68';
|
||||
$minVersionIgnored = false; // use this to ignore the min version check - used for the public endpoint to avoid breaking too many clients at once
|
||||
$licenseCosts = 42; // insert here any price you want - "0" is a special value, which also breaks the UI ;)
|
||||
|
||||
header('Access-Control-Allow-Origin: *'); //Allow access from everywhere...
|
||||
$code = 200; // Assuming everything is fine for now
|
||||
|
||||
// Check if a ".ignoreMinVersion" file exists
|
||||
if(!$minVersionIgnored && file_exists('.ignoreMinVersion')) {
|
||||
$minVersionIgnored = true; // If so, we ignore the min version check
|
||||
}
|
||||
|
||||
// Parse body (if possible)
|
||||
$body = json_decode(file_get_contents('php://input'));
|
||||
$clientVersion = isset($body->version) ? $body->version : null;
|
||||
|
||||
// Fake API
|
||||
$result = null;
|
||||
if(isset($_GET['path'])) {
|
||||
if (version_compare(PHP_VERSION, '8.0.0', '<')) {
|
||||
$result = array('error_msg' => 'This API only supports PHP 8 or higher.');
|
||||
$code = 500;
|
||||
} else if(isset($_GET['path'])) {
|
||||
$path = trim($_GET['path'], ' /');
|
||||
$pathParts = explode('/', $_GET['path']);
|
||||
if(count($pathParts) > 0 && $pathParts[0] == 'healthz') {
|
||||
@ -37,7 +46,7 @@ if(isset($_GET['path'])) {
|
||||
} else if(count($pathParts) > 0 && $pathParts[0] == 'ykwyhd') {
|
||||
// The "you-know-what-you-have-done" endpoint -> used as dummy url target
|
||||
$result = array('detail' => 'You know what you have done.');
|
||||
} else if($clientVersion != null && $clientVersion < $minVersionNumber) {
|
||||
} else if(!$minVersionIgnored && $clientVersion != null && $clientVersion < $minVersionNumber) {
|
||||
// Check if the instance is too old for us (for now following operators)
|
||||
$result = array('error_msg' => 'This API supports v' . $minVersionName . ' (' . $minVersionNumber . ') or higher.');
|
||||
$code = 473;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user