mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
Merge branch 'master' into share-files
This commit is contained in:
@@ -21,3 +21,4 @@ ENV password=password
|
||||
ENV exposeConfigPath=/src/config/expose.php
|
||||
|
||||
CMD sed -i "s|username|${username}|g" ${exposeConfigPath} && sed -i "s|password|${password}|g" ${exposeConfigPath} && php expose serve ${domain} --port ${port} --validateAuthTokens
|
||||
ENTRYPOINT ["/src/expose"]
|
||||
|
||||
@@ -45,13 +45,13 @@ class Client
|
||||
$sharedUrl = $this->prepareSharedUrl($sharedUrl);
|
||||
|
||||
foreach ($subdomains as $subdomain) {
|
||||
$this->connectToServer($sharedUrl, $subdomain, config('expose.auth_token'));
|
||||
$this->connectToServer($sharedUrl, $subdomain, $this->configuration->auth());
|
||||
}
|
||||
}
|
||||
|
||||
public function sharePort(int $port)
|
||||
{
|
||||
$this->connectToServerAndShareTcp($port, config('expose.auth_token'));
|
||||
$this->connectToServerAndShareTcp($port, $this->configuration->auth());
|
||||
}
|
||||
|
||||
protected function prepareSharedUrl(string $sharedUrl): string
|
||||
|
||||
@@ -74,7 +74,6 @@ class HttpClient
|
||||
protected function createConnector(): Connector
|
||||
{
|
||||
return new Connector($this->loop, [
|
||||
'dns' => '127.0.0.1',
|
||||
'tls' => [
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
|
||||
@@ -10,7 +10,7 @@ use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
|
||||
class ShareCommand extends Command
|
||||
{
|
||||
protected $signature = 'share {host} {--subdomain=} {--auth=}';
|
||||
protected $signature = 'share {host} {--subdomain=} {--auth=} {--server-host=} {--server-port=}';
|
||||
|
||||
protected $description = 'Share a local url with a remote expose server';
|
||||
|
||||
@@ -27,11 +27,15 @@ class ShareCommand extends Command
|
||||
{
|
||||
$this->configureConnectionLogger();
|
||||
|
||||
$serverHost = $this->option('server-host') ?? config('expose.host', 'localhost');
|
||||
$serverPort = $this->option('server-port') ?? config('expose.port', 8080);
|
||||
$auth = $this->option('auth') ?? config('expose.auth_token', '');
|
||||
|
||||
(new Factory())
|
||||
->setLoop(app(LoopInterface::class))
|
||||
->setHost(config('expose.host', 'localhost'))
|
||||
->setPort(config('expose.port', 8080))
|
||||
->setAuth($this->option('auth'))
|
||||
->setHost($serverHost)
|
||||
->setPort($serverPort)
|
||||
->setAuth($auth)
|
||||
->createClient()
|
||||
->share($this->argument('host'), explode(',', $this->option('subdomain')))
|
||||
->createHttpServer()
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App\Commands;
|
||||
|
||||
class ShareCurrentWorkingDirectoryCommand extends ShareCommand
|
||||
{
|
||||
protected $signature = 'share-cwd {host?} {--subdomain=} {--auth=}';
|
||||
protected $signature = 'share-cwd {host?} {--subdomain=} {--auth=} {--server-host=} {--server-port=}';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
@@ -59,14 +59,19 @@ class ShareCurrentWorkingDirectoryCommand extends ShareCommand
|
||||
return str_replace('.', '-', basename($projectPath));
|
||||
}
|
||||
|
||||
protected function prepareSharedHost($host): string
|
||||
protected function detectProtocol($host): string
|
||||
{
|
||||
$certificateFile = ($_SERVER['HOME'] ?? $_SERVER['USERPROFILE']).DIRECTORY_SEPARATOR.'.config'.DIRECTORY_SEPARATOR.'valet'.DIRECTORY_SEPARATOR.'Certificates'.DIRECTORY_SEPARATOR.$host.'.crt';
|
||||
|
||||
if (file_exists($certificateFile)) {
|
||||
return 'https://'.$host;
|
||||
return 'https://';
|
||||
}
|
||||
|
||||
return $host;
|
||||
return config('expose.default_https', false) ? 'https://' : 'http://';
|
||||
}
|
||||
|
||||
protected function prepareSharedHost($host): string
|
||||
{
|
||||
return $this->detectProtocol($host).$host;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,11 +27,13 @@ class SharePortCommand extends Command
|
||||
{
|
||||
$this->configureConnectionLogger();
|
||||
|
||||
$auth = $this->option('auth') ?? config('expose.auth_token', '');
|
||||
|
||||
(new Factory())
|
||||
->setLoop(app(LoopInterface::class))
|
||||
->setHost(config('expose.host', 'localhost'))
|
||||
->setPort(config('expose.port', 8080))
|
||||
->setAuth($this->option('auth'))
|
||||
->setAuth($auth)
|
||||
->createClient()
|
||||
->sharePort($this->argument('port'))
|
||||
->createHttpServer()
|
||||
|
||||
@@ -37,6 +37,14 @@ class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
$builtInConfig = config('expose');
|
||||
|
||||
$keyServerVariable = 'EXPOSE_CONFIG_FILE';
|
||||
if (array_key_exists($keyServerVariable, $_SERVER) && is_string($_SERVER[$keyServerVariable]) && file_exists($_SERVER[$keyServerVariable])) {
|
||||
$localConfig = require $_SERVER[$keyServerVariable];
|
||||
config()->set('expose', array_merge($builtInConfig, $localConfig));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$localConfigFile = getcwd().DIRECTORY_SEPARATOR.'.expose.php';
|
||||
|
||||
if (file_exists($localConfigFile)) {
|
||||
|
||||
BIN
builds/expose
BIN
builds/expose
Binary file not shown.
@@ -16,35 +16,35 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.3.0",
|
||||
"php": "^7.3.0 || ^8.0",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"cboden/ratchet": "^0.4.2",
|
||||
"clue/block-react": "^1.3",
|
||||
"cboden/ratchet": "^0.4.3",
|
||||
"clue/block-react": "^1.4",
|
||||
"clue/buzz-react": "^2.7",
|
||||
"clue/reactphp-sqlite": "dev-modular-worker-for-phar-support",
|
||||
"guzzlehttp/guzzle": "^6.5",
|
||||
"guzzlehttp/psr7": "dev-master as 1.6.1",
|
||||
"illuminate/http": "5.8.* || ^6.0 || ^7.0",
|
||||
"illuminate/pipeline": "^7.6",
|
||||
"illuminate/validation": "^7.7",
|
||||
"laminas/laminas-http": "^2.11",
|
||||
"laravel-zero/framework": "^7.0",
|
||||
"mockery/mockery": "^1.3",
|
||||
"namshi/cuzzle": "^2.0",
|
||||
"nikic/php-parser": "^4.4",
|
||||
"nyholm/psr7": "^1.2",
|
||||
"phpunit/phpunit": "^8.5",
|
||||
"ratchet/pawl": "^0.3.4",
|
||||
"react/http": "^0.8.6",
|
||||
"guzzlehttp/guzzle": "^7.2",
|
||||
"guzzlehttp/psr7": "^1.7",
|
||||
"illuminate/http": "5.8.* || ^6.0 || ^7.0 || ^8.0",
|
||||
"illuminate/pipeline": "^7.6 || ^8.0",
|
||||
"illuminate/validation": "^7.7 || ^8.0",
|
||||
"laminas/laminas-http": "^2.13",
|
||||
"laravel-zero/framework": "^8.2",
|
||||
"mockery/mockery": "^1.4.2",
|
||||
"octoper/cuzzle": "^3.1",
|
||||
"nikic/php-parser": "^v4.10",
|
||||
"nyholm/psr7": "^1.3",
|
||||
"phpunit/phpunit": "^9.4.3",
|
||||
"ratchet/pawl": "^0.3.5",
|
||||
"react/http": "^1.1.0",
|
||||
"react/socket": "^1.6",
|
||||
"react/stream": "^1.1.1",
|
||||
"riverline/multipart-parser": "^2.0",
|
||||
"symfony/expression-language": "^5.0",
|
||||
"symfony/http-kernel": "^4.0 || ^5.0",
|
||||
"symfony/expression-language": "^5.2",
|
||||
"symfony/http-kernel": "^4.0 || ^5.2",
|
||||
"symfony/psr-http-message-bridge": "^2.0",
|
||||
"twig/twig": "^3.0"
|
||||
"twig/twig": "^3.1"
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
|
||||
7893
composer.lock
generated
7893
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -26,7 +26,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'version' => '1.3.0',
|
||||
'version' => '1.4.2',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -55,6 +55,18 @@ return [
|
||||
*/
|
||||
'default_tld' => 'test',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default HTTPS
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Whether to use HTTPS as a default when sharing your local sites. Expose
|
||||
| will try to look up the protocol if you are using Laravel Valet
|
||||
| automatically. Otherwise you can specify it here manually.
|
||||
|
|
||||
*/
|
||||
'default_https' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Maximum Logged Requests
|
||||
|
||||
@@ -3,7 +3,7 @@ services:
|
||||
expose:
|
||||
image: beyondcodegmbh/expose-server:latest
|
||||
ports:
|
||||
- 127.0.0.1:8080:${PORT}
|
||||
- 8080:${PORT}
|
||||
environment:
|
||||
port: ${PORT}
|
||||
domain: ${DOMAIN}
|
||||
|
||||
@@ -17,6 +17,12 @@ The configuration file will be written to your home directory inside a `.expose`
|
||||
|
||||
`~/.expose/config.php`
|
||||
|
||||
You can also provide a custom location of the config file by providing the full path as a server variable.
|
||||
|
||||
```bash
|
||||
EXPOSE_CONFIG_FILE="~/my-custom-config.php" expose share
|
||||
```
|
||||
|
||||
And the default content of the configuration file is this:
|
||||
|
||||
```php
|
||||
|
||||
@@ -392,7 +392,7 @@ class TunnelTest extends TestCase
|
||||
|
||||
protected function createTestHttpServer()
|
||||
{
|
||||
$server = new Server(function (ServerRequestInterface $request) {
|
||||
$server = new Server($this->loop, function (ServerRequestInterface $request) {
|
||||
return new Response(200, ['Content-Type' => 'text/plain'], 'Hello World!');
|
||||
});
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class LoggedRequestTest extends TestCase
|
||||
/** @test */
|
||||
public function it_retrieves_the_request_id()
|
||||
{
|
||||
$rawRequest = str(new Request(200, '/expose', [
|
||||
$rawRequest = str(new Request('GET', '/expose', [
|
||||
'X-Expose-Request-ID' => 'example-request',
|
||||
]));
|
||||
$parsedRequest = LaminasRequest::fromString($rawRequest);
|
||||
@@ -25,7 +25,7 @@ class LoggedRequestTest extends TestCase
|
||||
/** @test */
|
||||
public function it_retrieves_the_request_for_chrome_extensions()
|
||||
{
|
||||
$rawRequest = str(new Request(200, '/expose', [
|
||||
$rawRequest = str(new Request('GET', '/expose', [
|
||||
'Origin' => 'chrome-extension://expose',
|
||||
'X-Expose-Request-ID' => 'example-request',
|
||||
]));
|
||||
@@ -43,7 +43,7 @@ class LoggedRequestTest extends TestCase
|
||||
'project' => 'expose',
|
||||
];
|
||||
|
||||
$rawRequest = str(new Request(200, '/expose', [
|
||||
$rawRequest = str(new Request('GET', '/expose', [
|
||||
'Content-Type' => 'application/json',
|
||||
], json_encode($postData)));
|
||||
$parsedRequest = LaminasRequest::fromString($rawRequest);
|
||||
@@ -65,7 +65,7 @@ class LoggedRequestTest extends TestCase
|
||||
/** @test */
|
||||
public function it_returns_the_raw_request()
|
||||
{
|
||||
$rawRequest = str(new Request(200, '/expose', [
|
||||
$rawRequest = str(new Request('GET', '/expose', [
|
||||
'X-Expose-Request-ID' => 'example-request',
|
||||
]));
|
||||
$parsedRequest = LaminasRequest::fromString($rawRequest);
|
||||
@@ -77,7 +77,7 @@ class LoggedRequestTest extends TestCase
|
||||
/** @test */
|
||||
public function it_returns_the_parsed_request()
|
||||
{
|
||||
$rawRequest = str(new Request(200, '/expose', [
|
||||
$rawRequest = str(new Request('GET', '/expose', [
|
||||
'X-Expose-Request-ID' => 'example-request',
|
||||
]));
|
||||
$parsedRequest = LaminasRequest::fromString($rawRequest);
|
||||
|
||||
@@ -24,7 +24,7 @@ class RequestLoggerTest extends TestCase
|
||||
$cliLogger = m::mock(CliRequestLogger::class);
|
||||
$cliLogger->shouldReceive('logRequest')->once();
|
||||
|
||||
$requestString = str(new Request(200, '/example'));
|
||||
$requestString = str(new Request('GET', '/example'));
|
||||
$parsedRequest = LaminasRequest::fromString($requestString);
|
||||
|
||||
$logger = new RequestLogger($browser, $cliLogger);
|
||||
@@ -42,7 +42,7 @@ class RequestLoggerTest extends TestCase
|
||||
$cliLogger = m::mock(CliRequestLogger::class);
|
||||
$cliLogger->shouldReceive('logRequest')->once();
|
||||
|
||||
$requestString = str(new Request(200, '/example'));
|
||||
$requestString = str(new Request('GET', '/example'));
|
||||
$parsedRequest = LaminasRequest::fromString($requestString);
|
||||
|
||||
$logger = new RequestLogger($browser, $cliLogger);
|
||||
@@ -64,7 +64,7 @@ class RequestLoggerTest extends TestCase
|
||||
$cliLogger->shouldReceive('logRequest')
|
||||
->twice();
|
||||
|
||||
$requestString = str(new Request(200, '/example'));
|
||||
$requestString = str(new Request('GET', '/example'));
|
||||
$parsedRequest = LaminasRequest::fromString($requestString);
|
||||
|
||||
$logger = new RequestLogger($browser, $cliLogger);
|
||||
@@ -89,7 +89,7 @@ class RequestLoggerTest extends TestCase
|
||||
$cliLogger = m::mock(CliRequestLogger::class);
|
||||
$cliLogger->shouldReceive('logRequest')->once();
|
||||
|
||||
$requestString = str(new Request(200, '/example'));
|
||||
$requestString = str(new Request('GET', '/example'));
|
||||
$parsedRequest = LaminasRequest::fromString($requestString);
|
||||
|
||||
$logger = new RequestLogger($browser, $cliLogger);
|
||||
@@ -107,7 +107,7 @@ class RequestLoggerTest extends TestCase
|
||||
$cliLogger = m::mock(CliRequestLogger::class);
|
||||
$cliLogger->shouldReceive('logRequest');
|
||||
|
||||
$requestString = str(new Request(200, '/example'));
|
||||
$requestString = str(new Request('GET', '/example'));
|
||||
$parsedRequest = LaminasRequest::fromString($requestString);
|
||||
|
||||
$logger = new RequestLogger($browser, $cliLogger);
|
||||
|
||||
Reference in New Issue
Block a user