Skip to content

Commit 29dc740

Browse files
committed
fix tcp bug
1 parent 68c8e3e commit 29dc740

5 files changed

Lines changed: 77 additions & 18 deletions

File tree

app/Components/Namesilo.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ private function curlRequest($url, $data = [])
106106
{
107107
$ch = curl_init();
108108
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
109-
curl_setopt($ch, CURLOPT_TIMEOUT, 500);
110-
// 为保证第三方服务器与微信服务器之间数据传输的安全性,所有微信接口采用https方式调用,必须使用下面2行代码打开ssl安全校验。
111-
// 如果在部署过程中代码在此处验证失败,请到 http://curl.haxx.se/ca/cacert.pem 下载新的证书判别文件。
109+
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
112110
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
113111
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
114112
curl_setopt($ch, CURLOPT_URL, $url);

app/Console/Commands/AutoCheckNodeStatus.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,17 @@ private function checkNodes()
120120
*/
121121
private function tcpCheck($ip)
122122
{
123-
$url = 'https://ipcheck.need.sh/api_v2.php?ip=' . $ip;
124-
$ret = $this->curlRequest($url);
125-
$ret = json_decode($ret);
126-
if (!$ret || $ret->result != 'success') {
127-
Log::warning("【TCP阻断检测】ipcheck.need.sh的TCP阻断检测接口挂了");
123+
try {
124+
$url = 'https://ipcheck.need.sh/api_v2.php?ip=' . $ip;
125+
$ret = $this->curlRequest($url);
126+
$ret = json_decode($ret);
127+
if (!$ret || $ret->result != 'success') {
128+
Log::warning("【TCP阻断检测】检测" . $ip . "时,接口返回异常");
129+
130+
return false;
131+
}
132+
} catch (\Exception $e) {
133+
Log::warning("【TCP阻断检测】检测" . $ip . "时,接口请求超时");
128134

129135
return false;
130136
}
@@ -206,15 +212,15 @@ private function curlRequest($url, $data = [])
206212

207213
$ch = curl_init();
208214
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
209-
curl_setopt($ch, CURLOPT_TIMEOUT, 500);
215+
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
210216
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
211217
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
212218
curl_setopt($ch, CURLOPT_URL, $url);
213-
curl_setopt($ch, CURLOPT_HTTPHEADER, [
214-
'Accept: application/json', // 请求报头
215-
'Content-Type: application/json', // 实体报头
216-
'Content-Length: ' . strlen($data)
217-
]);
219+
// curl_setopt($ch, CURLOPT_HTTPHEADER, [
220+
// 'Accept: application/json', // 请求报头
221+
// 'Content-Type: application/json', // 实体报头
222+
// 'Content-Length: ' . strlen($data)
223+
// ]);
218224

219225
// 如果data有数据,则用POST请求
220226
if ($data) {

app/helpers.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,7 @@ function getIPv6($ip)
165165
try {
166166
$ch = curl_init();
167167
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
168-
curl_setopt($ch, CURLOPT_TIMEOUT, 500);
169-
// 为保证第三方服务器与微信服务器之间数据传输的安全性,所有微信接口采用https方式调用,必须使用下面2行代码打开ssl安全校验。
170-
// 如果在部署过程中代码在此处验证失败,请到 http://curl.haxx.se/ca/cacert.pem 下载新的证书判别文件。
168+
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
171169
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
172170
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
173171
curl_setopt($ch, CURLOPT_URL, $url);

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"overtrue/laravel-lang": "~3.0",
2020
"paypal/rest-api-sdk-php": "*",
2121
"phpoffice/phpspreadsheet": "^1.4",
22+
"predis/predis": "^1.1",
2223
"rap2hpoutre/laravel-log-viewer": "^0.19.1",
2324
"spatie/laravel-permission": "^2.23",
2425
"youzan/open-sdk": "^1.0"

composer.lock

Lines changed: 57 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)