[fix] AloneTcpClient & Forward

This commit is contained in:
Lkeme 2021-08-07 10:23:19 +08:00
parent 88448fb482
commit d4d678ce12
3 changed files with 41 additions and 30 deletions

51
composer.lock generated
View File

@ -80,16 +80,16 @@
}, },
{ {
"name": "amphp/amp", "name": "amphp/amp",
"version": "v2.5.2", "version": "v2.6.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/amphp/amp.git", "url": "https://github.com/amphp/amp.git",
"reference": "efca2b32a7580087adb8aabbff6be1dc1bb924a9" "reference": "caa95edeb1ca1bf7532e9118ede4a3c3126408cc"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/amphp/amp/zipball/efca2b32a7580087adb8aabbff6be1dc1bb924a9", "url": "https://api.github.com/repos/amphp/amp/zipball/caa95edeb1ca1bf7532e9118ede4a3c3126408cc",
"reference": "efca2b32a7580087adb8aabbff6be1dc1bb924a9", "reference": "caa95edeb1ca1bf7532e9118ede4a3c3126408cc",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -99,14 +99,14 @@
] ]
}, },
"require": { "require": {
"php": ">=7" "php": ">=7.1"
}, },
"require-dev": { "require-dev": {
"amphp/php-cs-fixer-config": "dev-master", "amphp/php-cs-fixer-config": "dev-master",
"amphp/phpunit-util": "^1", "amphp/phpunit-util": "^1",
"ext-json": "*", "ext-json": "*",
"jetbrains/phpstorm-stubs": "^2019.3", "jetbrains/phpstorm-stubs": "^2019.3",
"phpunit/phpunit": "^6.0.9 | ^7", "phpunit/phpunit": "^7 | ^8 | ^9",
"psalm/phar": "^3.11@dev", "psalm/phar": "^3.11@dev",
"react/promise": "^2" "react/promise": "^2"
}, },
@ -163,7 +163,7 @@
"support": { "support": {
"irc": "irc://irc.freenode.org/amphp", "irc": "irc://irc.freenode.org/amphp",
"issues": "https://github.com/amphp/amp/issues", "issues": "https://github.com/amphp/amp/issues",
"source": "https://github.com/amphp/amp/tree/v2.5.2" "source": "https://github.com/amphp/amp/tree/v2.6.0"
}, },
"funding": [ "funding": [
{ {
@ -171,7 +171,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2021-01-10T17:06:37+00:00" "time": "2021-07-16T20:06:06+00:00"
}, },
{ {
"name": "bramus/ansi-php", "name": "bramus/ansi-php",
@ -741,16 +741,16 @@
}, },
{ {
"name": "laminas/laminas-servicemanager", "name": "laminas/laminas-servicemanager",
"version": "3.6.4", "version": "3.7.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laminas/laminas-servicemanager.git", "url": "https://github.com/laminas/laminas-servicemanager.git",
"reference": "b1445e1a7077c21b0fad0974a1b7a11b9dbe0828" "reference": "2b0aee477fdbd3191af7c302b93dbc5fda0626f4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/b1445e1a7077c21b0fad0974a1b7a11b9dbe0828", "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/2b0aee477fdbd3191af7c302b93dbc5fda0626f4",
"reference": "b1445e1a7077c21b0fad0974a1b7a11b9dbe0828", "reference": "2b0aee477fdbd3191af7c302b93dbc5fda0626f4",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -779,14 +779,16 @@
}, },
"require-dev": { "require-dev": {
"composer/package-versions-deprecated": "^1.0", "composer/package-versions-deprecated": "^1.0",
"laminas/laminas-coding-standard": "~1.0.0", "laminas/laminas-coding-standard": "~2.2.0",
"laminas/laminas-container-config-test": "^0.3", "laminas/laminas-container-config-test": "^0.3",
"laminas/laminas-dependency-plugin": "^2.1", "laminas/laminas-dependency-plugin": "^2.1.2",
"mikey179/vfsstream": "^1.6.8", "mikey179/vfsstream": "^1.6.8",
"ocramius/proxy-manager": "^2.2.3", "ocramius/proxy-manager": "^2.2.3",
"phpbench/phpbench": "^1.0.0-alpha3", "phpbench/phpbench": "^1.0.4",
"phpspec/prophecy-phpunit": "^2.0", "phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.4" "phpunit/phpunit": "^9.4",
"psalm/plugin-phpunit": "^0.16.1",
"vimeo/psalm": "^4.8"
}, },
"suggest": { "suggest": {
"ocramius/proxy-manager": "ProxyManager ^2.1.1 to handle lazy initialization of services" "ocramius/proxy-manager": "ProxyManager ^2.1.1 to handle lazy initialization of services"
@ -830,20 +832,20 @@
"type": "community_bridge" "type": "community_bridge"
} }
], ],
"time": "2021-02-03T08:44:41+00:00" "time": "2021-07-24T19:33:07+00:00"
}, },
{ {
"name": "laminas/laminas-stdlib", "name": "laminas/laminas-stdlib",
"version": "3.4.0", "version": "3.5.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laminas/laminas-stdlib.git", "url": "https://github.com/laminas/laminas-stdlib.git",
"reference": "e89c2268c9cad25099f562f7f015c28c5dd383c9" "reference": "c8ac6a76a133e682acfabc821d4a2ec646934b12"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/e89c2268c9cad25099f562f7f015c28c5dd383c9", "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/c8ac6a76a133e682acfabc821d4a2ec646934b12",
"reference": "e89c2268c9cad25099f562f7f015c28c5dd383c9", "reference": "c8ac6a76a133e682acfabc821d4a2ec646934b12",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -853,11 +855,10 @@
] ]
}, },
"require": { "require": {
"laminas/laminas-zendframework-bridge": "^1.0",
"php": "^7.3 || ^8.0" "php": "^7.3 || ^8.0"
}, },
"replace": { "conflict": {
"zendframework/zend-stdlib": "^3.2.1" "zendframework/zend-stdlib": "*"
}, },
"require-dev": { "require-dev": {
"laminas/laminas-coding-standard": "~2.3.0", "laminas/laminas-coding-standard": "~2.3.0",
@ -896,7 +897,7 @@
"type": "community_bridge" "type": "community_bridge"
} }
], ],
"time": "2021-06-28T21:37:31+00:00" "time": "2021-08-03T13:40:40+00:00"
}, },
{ {
"name": "laminas/laminas-text", "name": "laminas/laminas-text",

View File

@ -61,10 +61,10 @@ class AloneTcpClient
/** /**
* @use 数据封装 * @use 数据封装
* @param $value * @param $value
* @param $fmt * @param string $fmt
* @return string * @return string
*/ */
private static function packMsg($value, $fmt = "N"): string private static function packMsg($value, string $fmt = "N"): string
{ {
$head = pack($fmt, strlen($value)); $head = pack($fmt, strlen($value));
return $head . $value; return $head . $value;
@ -75,11 +75,11 @@ class AloneTcpClient
* @param $value * @param $value
* @param string $fmt * @param string $fmt
* @return array|false * @return array|false
* @throws \Exception
*/ */
private static function unPackMsg($value, $fmt = "N") private static function unPackMsg($value, string $fmt = "N")
{ {
$data = unpack($fmt, $value); return unpack($fmt, $value);
return $data[1];
} }
/** /**
@ -126,6 +126,12 @@ class AloneTcpClient
throw new Exception("Connection failure"); throw new Exception("Connection failure");
} }
if ($length == 4) $data = self::unPackMsg($data); if ($length == 4) $data = self::unPackMsg($data);
// 防止解包异常
if (!$data) {
throw new Exception("Connection failure");
} else {
$data = $data[1];
}
break; break;
} }
} catch (Exception $exception) { } catch (Exception $exception) {

View File

@ -211,6 +211,10 @@ class Forward
$did = $dynamic['desc']['dynamic_id']; $did = $dynamic['desc']['dynamic_id'];
$card = json_decode($dynamic['card'], true); $card = json_decode($dynamic['card'], true);
foreach ($msg_list as $msg) { foreach ($msg_list as $msg) {
// 异常情况 跳过
if (!isset($card['item']['content']) || !$msg) {
continue;
}
if (strpos($card['item']['content'], $msg) !== false) { if (strpos($card['item']['content'], $msg) !== false) {
Log::info("[删除所有动态] 删除动态 {$did}"); Log::info("[删除所有动态] 删除动态 {$did}");
Dynamic::removeDynamic($did); Dynamic::removeDynamic($did);