mirror of
https://github.com/ZeroDream-CN/SakuraPanel.git
synced 2025-01-12 01:42:52 +08:00
Fixed node disable not working issues
修复节点禁用不起作用的问题
This commit is contained in:
parent
1399502de8
commit
8a25cedba3
@ -29,6 +29,21 @@ $nm = new NodeManager();
|
||||
// 服务端 API 部分
|
||||
// 先进行 Frps 鉴权
|
||||
if((isset($_GET['apitoken']) && $_GET['apitoken'] == API_TOKEN) || (isset($_GET['action']) && $_GET['action'] == "getconf")) {
|
||||
|
||||
if(isset($_GET['apitoken'])) {
|
||||
// 取得节点 ID
|
||||
$expToken = explode("|", $_GET['apitoken']);
|
||||
if(count($expToken) !== 2 || !preg_match("/^[0-9]{1,5}$/", $expToken[1])) {
|
||||
Utils::sendServerForbidden("Invalid Node ID");
|
||||
} elseif($expToken[0] !== API_TOKEN) {
|
||||
Utils::sendServerForbidden("Invalid API Token");
|
||||
}
|
||||
$switchNode = Intval($expToken[1]);
|
||||
if(!$nm->isNodeAvailable($switchNode)) {
|
||||
Utils::sendServerForbidden("This server is current not available");
|
||||
}
|
||||
}
|
||||
|
||||
switch($_GET['action']) {
|
||||
case "getconf":
|
||||
// 精简了一下,用户名可以不用了
|
||||
@ -63,6 +78,10 @@ if((isset($_GET['apitoken']) && $_GET['apitoken'] == API_TOKEN) || (isset($_GET[
|
||||
$userToken = Database::escape($_GET['user']);
|
||||
$rs = Database::querySingleLine("tokens", ["token" => $userToken]);
|
||||
if($rs) {
|
||||
$userName = Database::escape($rs['username']);
|
||||
if(!$nm->isUserHasPermission($userName, $switchNode)) {
|
||||
Utils::sendServerForbidden("You have no permission to connect this server");
|
||||
}
|
||||
Utils::sendLoginSuccessful("Login successful, welcome!");
|
||||
} else {
|
||||
Utils::sendServerForbidden("Login failed");
|
||||
@ -92,7 +111,8 @@ if((isset($_GET['apitoken']) && $_GET['apitoken'] == API_TOKEN) || (isset($_GET[
|
||||
$rs = Database::querySingleLine("proxies", [
|
||||
"username" => $username,
|
||||
"remote_port" => $remotePort,
|
||||
"proxy_type" => $proxyType
|
||||
"proxy_type" => $proxyType,
|
||||
"node" => $switchNode
|
||||
]);
|
||||
if($rs) {
|
||||
if($rs['status'] !== "0") {
|
||||
@ -116,7 +136,8 @@ if((isset($_GET['apitoken']) && $_GET['apitoken'] == API_TOKEN) || (isset($_GET[
|
||||
$domainSQL = (isset($_GET['domain']) && !empty($_GET['domain'])) ? ["domain" => $domain] : ["subdomain" => $subdomain];
|
||||
$querySQL = [
|
||||
"username" => $username,
|
||||
"proxy_type" => $proxyType
|
||||
"proxy_type" => $proxyType,
|
||||
"node" => $switchNode
|
||||
];
|
||||
$querySQL = Array_merge($querySQL, $domainSQL);
|
||||
$rs = Database::querySingleLine("proxies", $querySQL);
|
||||
|
Loading…
Reference in New Issue
Block a user