mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-15 22:45:55 +00:00
wip
This commit is contained in:
@@ -8,7 +8,7 @@ use LaravelZero\Framework\Commands\Command;
|
|||||||
|
|
||||||
class ServeCommand extends Command
|
class ServeCommand extends Command
|
||||||
{
|
{
|
||||||
protected $signature = 'serve {host=127.0.0.1}';
|
protected $signature = 'serve {host=0.0.0.0} {hostname=localhost}';
|
||||||
|
|
||||||
protected $description = 'Start the shaft server';
|
protected $description = 'Start the shaft server';
|
||||||
|
|
||||||
@@ -16,6 +16,7 @@ class ServeCommand extends Command
|
|||||||
{
|
{
|
||||||
(new Factory())
|
(new Factory())
|
||||||
->setHost($this->argument('host'))
|
->setHost($this->argument('host'))
|
||||||
|
->setHostname($this->argument('hostname'))
|
||||||
->createServer()
|
->createServer()
|
||||||
->run();
|
->run();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ class ConnectionManager
|
|||||||
{
|
{
|
||||||
/** @var array */
|
/** @var array */
|
||||||
protected $connections = [];
|
protected $connections = [];
|
||||||
protected $host;
|
protected $hostname;
|
||||||
protected $port;
|
protected $port;
|
||||||
|
|
||||||
public function __construct($host, $port)
|
public function __construct($hostname, $port)
|
||||||
{
|
{
|
||||||
$this->host = $host;
|
$this->hostname = $hostname;
|
||||||
$this->port = $port;
|
$this->port = $port;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ class ConnectionManager
|
|||||||
|
|
||||||
public function host()
|
public function host()
|
||||||
{
|
{
|
||||||
return $this->host === '127.0.0.1' ? 'localhost' : $this->host;
|
return $this->hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function port()
|
public function port()
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ class Factory
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
protected $host = '127.0.0.1';
|
protected $host = '127.0.0.1';
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $hostname = 'localhost';
|
||||||
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
protected $port = 8080;
|
protected $port = 8080;
|
||||||
|
|
||||||
@@ -44,11 +47,18 @@ class Factory
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setHostname(string $hostname)
|
||||||
|
{
|
||||||
|
$this->hostname = $hostname;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function createServer()
|
public function createServer()
|
||||||
{
|
{
|
||||||
$socket = new Server("{$this->host}:{$this->port}", $this->loop);
|
$socket = new Server("{$this->host}:{$this->port}", $this->loop);
|
||||||
|
|
||||||
$connectionManager = new ConnectionManager($this->host, $this->port);
|
$connectionManager = new ConnectionManager($this->hostname, $this->port);
|
||||||
|
|
||||||
$app = new Shaft($connectionManager);
|
$app = new Shaft($connectionManager);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user