From 5051bf243471d06bc785b03ef5a3c2c9ad35c20f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=99=E5=AD=A6=E6=9D=B0?= Date: Fri, 25 Jan 2019 19:01:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=85=A8=E8=AE=A4=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Middleware/Security.php | 8 +++++++- src/Providers/BaseServiceProvider.php | 14 +++++++++++++- src/Providers/LumenServerServiceProvider.php | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Middleware/Security.php b/src/Middleware/Security.php index 5007b02..308efb3 100644 --- a/src/Middleware/Security.php +++ b/src/Middleware/Security.php @@ -45,9 +45,15 @@ class Security } if (Str::startsWith($ip, [ - '127.0.0.', + '127.0.0.1', + //局域网 '192.168.', + //vpc '10.0.', + //pod network + '172.20.', + //北京办公区 + '172.16.' ])) { return true; } diff --git a/src/Providers/BaseServiceProvider.php b/src/Providers/BaseServiceProvider.php index f662a43..ea088c7 100644 --- a/src/Providers/BaseServiceProvider.php +++ b/src/Providers/BaseServiceProvider.php @@ -3,14 +3,26 @@ namespace JsonRpc\Providers; +use Illuminate\Http\Request; use Illuminate\Support\ServiceProvider; -use JsonRpc\Exception\RpcServerException; use Monolog\Handler\StreamHandler; use Monolog\Logger; class BaseServiceProvider extends ServiceProvider { + public function boot(){ + Request::setTrustedProxies([ + //pod network + '172.20.0.0/16', + //vpc + '10.0.2.0/16', + //local + '127.0.0.1', + //北京办公区 + '172.16.100.0/16' + ], Request::HEADER_X_FORWARDED_ALL); + } protected function setupConfig() { diff --git a/src/Providers/LumenServerServiceProvider.php b/src/Providers/LumenServerServiceProvider.php index 5290194..a6625a5 100644 --- a/src/Providers/LumenServerServiceProvider.php +++ b/src/Providers/LumenServerServiceProvider.php @@ -25,6 +25,7 @@ class LumenServerServiceProvider extends BaseServiceProvider public function boot() { + parent::boot(); $this->app->middleware(TunnelMiddleware::class); $this->app->routeMiddleware(['rpc.security' => Security::class]); $this->app->router->group([