Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit c09e7f6

Browse files
committed
🐛 向主控同步文件时不带token
1 parent 840a919 commit c09e7f6

File tree

3 files changed

+39
-12
lines changed

3 files changed

+39
-12
lines changed

inc/cluster.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class download {
116116
private $maxConcurrent;
117117
private $semaphore;
118118

119-
public function __construct($filesList, $maxConcurrent = 1) {
119+
public function __construct($filesList = [], $maxConcurrent = 1) {
120120
$this->filesList = $filesList;
121121
$this->maxConcurrent = $maxConcurrent;
122122
$this->semaphore = new Swoole\Coroutine\Channel($maxConcurrent);
@@ -239,6 +239,34 @@ public function downloadFiles() {
239239
$bar->display();
240240
$bar->end();
241241
}
242+
243+
private function downloadnopoen($hash) {
244+
global $DOWNLOAD_DIR;
245+
global $tokendata;
246+
$filePath = $DOWNLOAD_DIR . '/' . substr($hash, 0, 2) . '/';
247+
if (!file_exists($filePath)) {
248+
mkdir($filePath, 0777, true);
249+
}
250+
$filepath = "/openbmclapi/download/{$hash}?noopen=1"
251+
$client = new Swoole\Coroutine\Http\Client('openbmclapi.bangbang93.com', 443, true);
252+
$client->set([
253+
'timeout' => -1
254+
]);
255+
$client->setHeaders([
256+
'Host' => 'openbmclapi.bangbang93.com',
257+
'User-Agent' => USERAGENT,
258+
'Accept' => '*/*',
259+
'Authorization' => "Bearer {$tokendata['token']}"
260+
]);
261+
$downloader = $client->download($filepath,$DOWNLOAD_DIR.'/'.substr($hash, 0, 2).'/'.$hash);
262+
if (!$downloader) {
263+
mlog("Error download to the main control:{$client->errMsg}",2);
264+
return false;
265+
}
266+
else($client->statusCode == "200"){
267+
return true;
268+
}
269+
}
242270
}
243271

244272
class FilesCheck {

inc/server.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,8 @@ public function startserver() {
4646
$filepath = $this->dir.'/'.substr($downloadhash, 0, 2).'/'.$downloadhash;
4747
if ($this->check_sign($downloadhash, $this->secret, $allurl['s'], $allurl['e'])){
4848
if (!file_exists($filepath)) {
49-
$Missfile[] = new BMCLAPIFile(
50-
'/openbmclapi/download/'.$downloadhash,
51-
$downloadhash,
52-
$downloadhash,
53-
$downloadhash
54-
);
55-
$download = new download($Missfile);
56-
$download->downloadFiles();
49+
$download = new download();
50+
$download->downloadnopoen($downloadhash);
5751
}
5852
if(isset($request->header['range'])){
5953
preg_match('/bytes=(\d+)-(\d+)?/', $request->header['range'], $matches);
@@ -72,6 +66,7 @@ public function startserver() {
7266
}
7367
$code = 206;
7468
$response->header('Content-Type', 'application/octet-stream');
69+
$response->header('Content-Type', 'application/octet-stream');
7570
$response->sendfile($filepath,$start_byte,$length);
7671
}
7772
else{
@@ -83,6 +78,7 @@ public function startserver() {
8378
}
8479
$code = 200;
8580
$response->header('Content-Type', 'application/octet-stream');
81+
$response->header('Content-Type', 'application/octet-stream');
8682
$response->sendfile($filepath);
8783
}
8884
}

inc/socketio.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,12 @@ public function IsTime($inputString) {
172172
}
173173

174174
public function disable() {
175-
$this->ack("disable");
176-
Coroutine::sleep(2);
175+
global $enable;
176+
if ($enable;){
177+
$this->ack("disable");
178+
Coroutine::sleep(2);
179+
}
177180
mlog("[socket.io]Close Connection");
178-
$client->close();
181+
$this->$client->close();
179182
}
180183
}

0 commit comments

Comments
 (0)