1
0
mirror of https://github.com/danog/tonProxy.git synced 2024-11-26 12:04:49 +01:00
This commit is contained in:
Daniil Gentili 2019-12-22 12:13:53 +01:00
parent 5f5ced71ff
commit e0a50c8c51
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 13 additions and 12 deletions

View File

@ -5,9 +5,9 @@
"type": "project",
"require": {
"amphp/websocket-server": "dev-master as v2.0.0-rc1",
"amphp/http-server-static-content": "dev-master",
"amphp/http-server-router": "dev-master",
"amphp/log": "dev-master"
"amphp/http-server-static-content": "^1",
"amphp/http-server-router": "^1",
"amphp/log": "^1"
},
"authors": [
{

View File

@ -24,10 +24,8 @@ use function Amp\Socket\connect;
require __DIR__.'/vendor/autoload.php';
$ip = '127.0.0.1'; // Connect to local TON validator
$ip = 'ton.daniil.it';
$port = 9999;
$ip = '67.207.74.182';
$port = 4924;
$logHandler = new StreamHandler(getStdout());
$logHandler->setFormatter(new ConsoleFormatter);
@ -35,7 +33,7 @@ $logger = new Logger('server');
$logger->pushHandler($logHandler);
$websocket = new Websocket(new class($ip, $port, $logger) implements ClientHandler {
class TONHandler implements ClientHandler {
/**
* TON validator URI.
*
@ -171,15 +169,18 @@ $websocket = new Websocket(new class($ip, $port, $logger) implements ClientHandl
$socket->close();
}
}
});
}
$sockets = [
Socket\listen('127.0.0.1:80'),
Socket\listen('[::1]:80'),
Socket\listen('0.0.0.0:80'),
Socket\listen('[::]:80'),
];
$router = new Router;
$router->addRoute('GET', '/ton', $websocket);
$router->addRoute('GET', '/testnet', new Websocket(new TONHandler($ip, $port, $logger)));
$router->addRoute('GET', '/testnetDebug', new Websocket(new TONHandler('127.0.0.1', 9999, $logger)));
$router->setFallback(
new CallableRequestHandler(
function () {