diff options
author | Chocobozzz <me@florianbigard.com> | 2021-09-07 15:16:26 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-09-07 15:16:26 +0200 |
commit | fb72d2e1c24cd4660fd6611ef723c5827c47294c (patch) | |
tree | c2a2991a9e6944cd3d22c87e34de096a47b8db9e /shared/extra-utils/server/tracker.ts | |
parent | 6f9719b568fad75959a1404b6927b7a278061c41 (diff) | |
download | PeerTube-fb72d2e1c24cd4660fd6611ef723c5827c47294c.tar.gz PeerTube-fb72d2e1c24cd4660fd6611ef723c5827c47294c.tar.zst PeerTube-fb72d2e1c24cd4660fd6611ef723c5827c47294c.zip |
Fix infohash with object storage
Diffstat (limited to 'shared/extra-utils/server/tracker.ts')
-rw-r--r-- | shared/extra-utils/server/tracker.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/shared/extra-utils/server/tracker.ts b/shared/extra-utils/server/tracker.ts new file mode 100644 index 000000000..f04e8f8a1 --- /dev/null +++ b/shared/extra-utils/server/tracker.ts | |||
@@ -0,0 +1,27 @@ | |||
1 | import { expect } from 'chai' | ||
2 | import { sha1 } from '@server/helpers/core-utils' | ||
3 | import { makeGetRequest } from '../requests' | ||
4 | |||
5 | async function hlsInfohashExist (serverUrl: string, masterPlaylistUrl: string, fileNumber: number) { | ||
6 | const path = '/tracker/announce' | ||
7 | |||
8 | const infohash = sha1(`2${masterPlaylistUrl}+V${fileNumber}`) | ||
9 | |||
10 | // From bittorrent-tracker | ||
11 | const infohashBinary = escape(Buffer.from(infohash, 'hex').toString('binary')).replace(/[@*/+]/g, function (char) { | ||
12 | return '%' + char.charCodeAt(0).toString(16).toUpperCase() | ||
13 | }) | ||
14 | |||
15 | const res = await makeGetRequest({ | ||
16 | url: serverUrl, | ||
17 | path, | ||
18 | rawQuery: `peer_id=-WW0105-NkvYO/egUAr4&info_hash=${infohashBinary}&port=42100`, | ||
19 | expectedStatus: 200 | ||
20 | }) | ||
21 | |||
22 | expect(res.text).to.not.contain('failure') | ||
23 | } | ||
24 | |||
25 | export { | ||
26 | hlsInfohashExist | ||
27 | } | ||