Skip to content

Commit

Permalink
Merge pull request #4 from plesk/task-ayuzhakov-eliminate-flash-policy
Browse files Browse the repository at this point in the history
Eliminate Flash policy
  • Loading branch information
rybalov authored Jul 27, 2023
2 parents ed8590a + 684a3d8 commit 81864c3
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 410 deletions.
28 changes: 1 addition & 27 deletions src/Ratchet/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
use React\EventLoop\LoopInterface;
use React\EventLoop\Factory as LoopFactory;
use React\Socket\Server as Reactor;
use React\Socket\SecureServer as SecureReactor;
use Ratchet\Http\HttpServerInterface;
use Ratchet\Http\OriginCheck;
use Ratchet\Wamp\WampServerInterface;
use Ratchet\Server\IoServer;
use Ratchet\Server\FlashPolicy;
use Ratchet\Http\HttpServer;
use Ratchet\Http\Router;
use Ratchet\WebSocket\MessageComponentInterface as WsMessageComponentInterface;
Expand All @@ -32,11 +30,6 @@ class App
*/
public $routes;

/**
* @var \Ratchet\Server\IoServer
*/
public $flashServer;

/**
* @var \Ratchet\Server\IoServer
*/
Expand All @@ -61,7 +54,7 @@ class App

/**
* @param string $httpHost HTTP hostname clients intend to connect to. MUST match JS `new WebSocket('ws://$httpHost');`
* @param int $port Port to listen on. If 80, assuming production, Flash on 843 otherwise expecting Flash to be proxied through 8843
* @param int $port Port to listen on.
* @param string $address IP address to bind to. Default is localhost/proxy only. '0.0.0.0' for any machine.
* @param LoopInterface $loop Specific React\EventLoop to bind the application to. null will create one for you.
* @param array $context
Expand All @@ -83,18 +76,6 @@ public function __construct($httpHost = 'localhost', $port = 8080, $address = '1

$this->routes = new RouteCollection();
$this->_server = new IoServer(new HttpServer(new Router(new UrlMatcher($this->routes, new RequestContext()))), $socket, $loop);

$policy = new FlashPolicy();
$policy->addAllowedAccess($httpHost, 80);
$policy->addAllowedAccess($httpHost, $port);

if (80 == $port) {
$flashUri = '0.0.0.0:843';
} else {
$flashUri = 8843;
}
$flashSock = new Reactor($flashUri, $loop);
$this->flashServer = new IoServer($policy, $flashSock);
}

/**
Expand Down Expand Up @@ -131,13 +112,6 @@ public function route($path, ComponentInterface $controller, array $allowedOrigi
$decorated = new OriginCheck($decorated, $allowedOrigins);
}

//allow origins in flash policy server
if (empty($this->flashServer) === false) {
foreach ($allowedOrigins as $allowedOrgin) {
$this->flashServer->app->addAllowedAccess($allowedOrgin, $this->port);
}
}

$this->routes->add('rr-' . ++$this->_routeCounter, new Route($path, array('_controller' => $decorated), array('Origin' => $this->httpHost), array(), $httpHost, array(), array('GET')));

return $decorated;
Expand Down
213 changes: 0 additions & 213 deletions src/Ratchet/Server/FlashPolicy.php

This file was deleted.

Loading

0 comments on commit 81864c3

Please sign in to comment.