Configuration fixes, makefile tweaks
* The PHAR now gets tagged with version and buildtime * WebSocket support can now be disabled
This commit is contained in:
		@@ -3,15 +3,25 @@
 | 
			
		||||
 | 
			
		||||
use NoccyLabs\Mercureact\Configuration;
 | 
			
		||||
use NoccyLabs\Mercureact\Daemon;
 | 
			
		||||
use PHPUnit\TextUI\Help;
 | 
			
		||||
 | 
			
		||||
require_once __DIR__."/../vendor/autoload.php";
 | 
			
		||||
file_exists(__DIR__."/../vendor") && require_once __DIR__."/../vendor/autoload.php";
 | 
			
		||||
file_exists(__DIR__."/../../../autoload.php") && require_once __DIR__."/../../../autoload.php";
 | 
			
		||||
 | 
			
		||||
if (file_exists(__DIR__."/../src/meta")) {
 | 
			
		||||
    $meta = require_once(__DIR__."/../src/meta");
 | 
			
		||||
    define("MERCUREACT_VERSION", $meta['version']??'0.0.0');
 | 
			
		||||
    define("MERCUREACT_BUILDTIME", $meta['buildtime']);
 | 
			
		||||
} else {
 | 
			
		||||
    define("MERCUREACT_VERSION", "DEV");
 | 
			
		||||
    define("MERCUREACT_BUILDTIME", null);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$opts = getopt("c:C:h");
 | 
			
		||||
 | 
			
		||||
if (isset($opts['h'])) {
 | 
			
		||||
    $info = "v".MERCUREACT_VERSION.(MERCUREACT_BUILDTIME?("\nBuilt on ".MERCUREACT_BUILDTIME):"");
 | 
			
		||||
    fwrite(STDERR, <<<HELP
 | 
			
		||||
    Mercureact Realtime SSE Daemon
 | 
			
		||||
    Mercureact Realtime SSE Daemon {$info}
 | 
			
		||||
    (c) 2024, NoccyLabs - Distributed under GNU GPL v3 or later.
 | 
			
		||||
 | 
			
		||||
      Options:
 | 
			
		||||
@@ -32,8 +42,9 @@ if (isset($opts['C'])) {
 | 
			
		||||
    }
 | 
			
		||||
    file_put_contents($file, <<<DEFAULTS
 | 
			
		||||
    server:
 | 
			
		||||
      public_url: https://example.com
 | 
			
		||||
      address: 0.0.0.0:9000
 | 
			
		||||
      public_url: https://example.com
 | 
			
		||||
      websockets: false
 | 
			
		||||
      cors:
 | 
			
		||||
        allow_origin: '*'
 | 
			
		||||
        csp: "default-src * 'self' http: 'unsafe-eval' 'unsafe-inline'; connect-src * 'self'"
 | 
			
		||||
@@ -41,9 +52,6 @@ if (isset($opts['C'])) {
 | 
			
		||||
        cert: foo.pem
 | 
			
		||||
        key: foo.key
 | 
			
		||||
 | 
			
		||||
    websocket:
 | 
			
		||||
      enable: true
 | 
			
		||||
 | 
			
		||||
    publish:
 | 
			
		||||
      overwrite_id: false
 | 
			
		||||
      reject_duplicates: true
 | 
			
		||||
@@ -71,4 +79,4 @@ if (isset($opts['c'])) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$daemon = new Daemon($config);
 | 
			
		||||
$daemon->start();
 | 
			
		||||
$daemon->start();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user