Browse Source

feat: add `/version` request

master
Dnomd343 2 years ago
parent
commit
7f4bde1dec
  1. 2
      kms.php
  2. 12
      src/Route.php

2
kms.php

@ -30,6 +30,7 @@ $VLMCSD = array( // vlmcsd process
); );
function load_nginx_config(int $kms_port, int $http_port): void { function load_nginx_config(int $kms_port, int $http_port): void {
global $VERSION;
$nginx_config = "server { $nginx_config = "server {
listen $http_port; listen $http_port;
listen [::]:$http_port ipv6only=on; listen [::]:$http_port ipv6only=on;
@ -51,6 +52,7 @@ function load_nginx_config(int $kms_port, int $http_port): void {
} }
fastcgi_param KMS_PORT $kms_port; fastcgi_param KMS_PORT $kms_port;
fastcgi_param KMS_CLI \$cli_mode; fastcgi_param KMS_CLI \$cli_mode;
fastcgi_param KMS_VER $VERSION;
fastcgi_param SCRIPT_FILENAME /kms-server/src/Route.php; fastcgi_param SCRIPT_FILENAME /kms-server/src/Route.php;
}\n}\n"; }\n}\n";
logging::debug("Nginx configure ->\n" . $nginx_config); logging::debug("Nginx configure ->\n" . $nginx_config);

12
src/Route.php

@ -19,6 +19,18 @@ if ($url == '/json') { // show keys in json format
return; // skip following process return; // skip following process
} }
if ($url == '/version') { // show version info
if ($isCli) { // cli mode
echo "\033[33mkms-server\033[0m => \033[36m" . getenv('KMS_VER') . "\033[0m\n";
} else {
mimeJson();
echo json_encode(array(
'version' => getenv('KMS_VER')
));
}
return; // skip following process
}
$isGbk = false; // utf-8 or gbk $isGbk = false; // utf-8 or gbk
$isJson = false; // json output $isJson = false; // json output
if ($url == '/win/gbk' or $url == '/win-server/gbk') { if ($url == '/win/gbk' or $url == '/win-server/gbk') {

Loading…
Cancel
Save