Browse Source

Merge branch 'dev'

master
Dnomd343 2 years ago
parent
commit
32a4eee710
  1. 26
      kms.php
  2. 12
      src/Route.php

26
kms.php

@ -29,7 +29,21 @@ $VLMCSD = array( // vlmcsd process
'pidFile' => '/run/vlmcsd.pid', 'pidFile' => '/run/vlmcsd.pid',
); );
$HELP_MSG = "
kms-server ($VERSION)
Project: https://github.com/dnomd343/kms-server.git
--debug Enable debug mode
--kms-port Specify kms listen port
--http-port Specify http listen port
--disable-http Disable http service
--version Show version info
--help Show help message
\n";
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;
@ -44,6 +58,7 @@ function load_nginx_config(int $kms_port, int $http_port): void {
} }
location / { location / {
set \$cli_mode false;
include fastcgi_params; include fastcgi_params;
fastcgi_pass unix:/run/php-fpm.sock; fastcgi_pass unix:/run/php-fpm.sock;
if (\$http_user_agent ~* (curl|wget)) { if (\$http_user_agent ~* (curl|wget)) {
@ -51,6 +66,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);
@ -169,6 +185,16 @@ pcntl_signal(SIGQUIT, function() { // receive SIGQUIT signal
exit; exit;
}); });
if (in_array('-v', $argv) || in_array('--version', $argv)) {
echo "\033[33mkms-server\033[0m => \033[36m$VERSION\033[0m\n"; // show version info
exit;
}
if (in_array('-h', $argv) || in_array('--help', $argv)) {
echo $HELP_MSG; // show help message
exit;
}
logging::info('Loading kms-server (' . $VERSION . ')'); logging::info('Loading kms-server (' . $VERSION . ')');
load_params(); load_params();
load_vlmcsd_command($KMS_PORT); load_vlmcsd_command($KMS_PORT);

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