import { logger } from '@server/helpers/logger'
import { updateTorrentUrls } from '@server/helpers/webtorrent'
import { CONFIG } from '@server/initializers/config'
+import { P2P_MEDIA_LOADER_PEER_VERSION } from '@server/initializers/constants'
import { storeHLSFile, storeWebTorrentFile } from '@server/lib/object-storage'
import { getHLSDirectory, getHlsResolutionPlaylistFilename } from '@server/lib/paths'
import { moveToNextState } from '@server/lib/video-state'
playlist.storage = VideoStorage.OBJECT_STORAGE
+ playlist.assignP2PMediaLoaderInfoHashes(video, playlist.VideoFiles)
+ playlist.p2pMediaLoaderPeerVersion = P2P_MEDIA_LOADER_PEER_VERSION
+
await playlist.save()
}
createMultipleServers,
doubleFollow,
expectStartWith,
+ hlsInfohashExist,
makeRawRequest,
ObjectStorageCommand,
PeerTubeServer,
const masterPlaylist = await server.streamingPlaylists.get({ url: hlsPlaylist.playlistUrl })
+ let i = 0
for (const resolution of resolutions) {
expect(masterPlaylist).to.contain(`${resolution}.m3u8`)
expect(masterPlaylist).to.contain(`${resolution}.m3u8`)
+
+ const url = 'http://' + videoDetails.account.host
+ await hlsInfohashExist(url, hlsPlaylist.playlistUrl, i)
+
+ i++
}
}
function makeGetRequest (options: CommonRequestParams & {
query?: any
+ rawQuery?: string
}) {
const req = request(options.url).get(options.path)
- .query(options.query)
+
+ if (options.query) req.query(options.query)
+ if (options.rawQuery) req.query(options.rawQuery)
return buildRequest(req, { contentType: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options })
}
export * from './servers-command'
export * from './servers'
export * from './stats-command'
+export * from './tracker'
--- /dev/null
+import { expect } from 'chai'
+import { sha1 } from '@server/helpers/core-utils'
+import { makeGetRequest } from '../requests'
+
+async function hlsInfohashExist (serverUrl: string, masterPlaylistUrl: string, fileNumber: number) {
+ const path = '/tracker/announce'
+
+ const infohash = sha1(`2${masterPlaylistUrl}+V${fileNumber}`)
+
+ // From bittorrent-tracker
+ const infohashBinary = escape(Buffer.from(infohash, 'hex').toString('binary')).replace(/[@*/+]/g, function (char) {
+ return '%' + char.charCodeAt(0).toString(16).toUpperCase()
+ })
+
+ const res = await makeGetRequest({
+ url: serverUrl,
+ path,
+ rawQuery: `peer_id=-WW0105-NkvYO/egUAr4&info_hash=${infohashBinary}&port=42100`,
+ expectedStatus: 200
+ })
+
+ expect(res.text).to.not.contain('failure')
+}
+
+export {
+ hlsInfohashExist
+}