generated from github/codespaces-blank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelay.php
executable file
·46 lines (32 loc) · 1.36 KB
/
relay.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
use plugins\Start\cache;
include 'plugins/autoloader.php';
var_dump(implode(' ', $argv));
if (!empty($argv[1]))
$GLOBALS['interface']['server']['localPortListener'] = $argv[1];
if (!empty($argv[2]))
$GLOBALS['interface']['server']['remoteAddress'] = $argv[2];
if (!empty($argv[3]))
if ($argv[3] == 'auto-secure') $GLOBALS['interface']['server']['autoGenerateSslCertificate'] = true;
else $GLOBALS['interface']['server']['autoGenerateSslCertificate'] = false;
else $GLOBALS['interface']['server']['autoGenerateSslCertificate'] = false;
if ($GLOBALS['interface']['server']['autoGenerateSslCertificate']) {
$useSsl = true;
}
$newSettings = [];
foreach (cache::global()['interface']['serverSettings'] as $param => $value) $newSettings[$param] = $value;
Co::set(['hook_flags' => SWOOLE_HOOK_ALL]);
Swoole\Coroutine::set(['max_coroutine' => 20000000]);
if (!empty($useSsl)) {
$server = new Swoole\Http\Server('localhost', cache::global()['interface']['server']['localPortListener'], SWOOLE_PROCESS, SWOOLE_SOCK_TCP | SWOOLE_SSL);
} else {
$server = new Swoole\Http\Server(
'localhost',
cache::global()['interface']['server']['localPortListener'],
SWOOLE_BASE
);
}
$server->set($newSettings);
$server->on('Start', '\plugins\Start\handler::init');
$server->on('Request', '\plugins\Request\router::callBack');
$server->start();