From 3401fa4ac406cddf26bf4f94b663ace2e1dba8ed Mon Sep 17 00:00:00 2001
From: zhoudw <zhoudw@infobird.com>
Date: Wed, 16 Mar 2022 11:03:17 +0800
Subject: [PATCH] 获取配置
---
config/config.php | 1 +
.gitignore | 4 +++-
runtime/container/proxy/App_Controller_WebsocketController.proxy.php | 4 +---
app/Controller/WebsocketController.php | 4 +---
runtime/hyperf.pid | 2 +-
index.html | 2 +-
config/autoload/server.php | 1 -
7 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/.gitignore b/.gitignore
index 46e33c3..3647db7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
composer.phar
vendor/
runtime/
-composer.lock
\ No newline at end of file
+composer.lock
+.DS_Store
+logs
\ No newline at end of file
diff --git a/app/Controller/WebsocketController.php b/app/Controller/WebsocketController.php
index 9426e18..5d4f06d 100644
--- a/app/Controller/WebsocketController.php
+++ b/app/Controller/WebsocketController.php
@@ -51,9 +51,7 @@
{
// 第一个参数对应日志的 name, 第二个参数对应 config/autoload/logger.php 内的 key
$this->logger = $loggerFactory->get('log','default');
- //获取 server.php 里的内容
- $this->server_config = $this->config->get('server.servers','');
- $this->allow_ip = $this->server_config[0]['allow_ip'];
+ $this->allow_ip = $this->config->get('allow_ip','');
}
public function onClose($server, int $fd, int $reactorId): void
diff --git a/config/autoload/server.php b/config/autoload/server.php
index 4929ad1..c91b012 100644
--- a/config/autoload/server.php
+++ b/config/autoload/server.php
@@ -23,7 +23,6 @@
'host' => '0.0.0.0',
'port' => 9503,
'sock_type' => SWOOLE_SOCK_TCP,
- 'allow_ip' => env('ALLIW_IP','127.0.0.1:9502'),
'callbacks' => [
SwooleEvent::ON_HAND_SHAKE => [Hyperf\WebSocketServer\Server::class, 'onHandShake'],
SwooleEvent::ON_MESSAGE => [Hyperf\WebSocketServer\Server::class, 'onMessage'],
diff --git a/config/config.php b/config/config.php
index 8e484cc..fcb8aeb 100644
--- a/config/config.php
+++ b/config/config.php
@@ -18,6 +18,7 @@
'node_name' => env('NODE_NAME', 'node_1'),
'file_path'=>ENV("FILE_PATH","../file/"),
'scan_cacheable' => env('SCAN_CACHEABLE', false),
+ 'allow_ip' => env('ALLIW_IP','127.0.0.1:9502'),
StdoutLoggerInterface::class => [
'log_level' => [
LogLevel::ALERT,
diff --git a/index.html b/index.html
index e486880..08ad024 100755
--- a/index.html
+++ b/index.html
@@ -15,7 +15,7 @@
<script>
$(function() {
// 创建socket对象
- var socket = new WebSocket('ws://127.0.0.1:9501');
+ var socket = new WebSocket('ws://127.0.0.1:9503');
// 打开Socket
socket.onopen = function(event) {
diff --git a/runtime/container/proxy/App_Controller_WebsocketController.proxy.php b/runtime/container/proxy/App_Controller_WebsocketController.proxy.php
index 0d761bf..ed79a6f 100644
--- a/runtime/container/proxy/App_Controller_WebsocketController.proxy.php
+++ b/runtime/container/proxy/App_Controller_WebsocketController.proxy.php
@@ -48,9 +48,7 @@
$this->__handlePropertyHandler(__CLASS__);
// 第一个参数对应日志的 name, 第二个参数对应 config/autoload/logger.php 内的 key
$this->logger = $loggerFactory->get('log', 'default');
- //获取 server.php 里的内容
- $this->server_config = $this->config->get('server.servers', '');
- $this->allow_ip = $this->server_config[0]['allow_ip'];
+ $this->allow_ip = $this->config->get('allow_ip', '');
}
public function onClose($server, int $fd, int $reactorId) : void
{
diff --git a/runtime/hyperf.pid b/runtime/hyperf.pid
index a5a5efe..52f6eb9 100644
--- a/runtime/hyperf.pid
+++ b/runtime/hyperf.pid
@@ -1 +1 @@
-22692
\ No newline at end of file
+7277
\ No newline at end of file
--
Gitblit v1.8.0