Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const WebTorrent = require('webtorrent')
const zeroFill = require('zero-fill')
const crashReporter = require('../crash-reporter')
const config = require('../config')
const { TorrentKeyNotFoundError } = require('./lib/errors')
const torrentPoster = require('./lib/torrent-poster')
// Report when the process crashes
crashReporter.init()
// Send & receive messages from the main window
const ipc = electron.ipcRenderer
// Force use of webtorrent trackers on all torrents
global.WEBTORRENT_ANNOUNCE = defaultAnnounceList
.map((arr) => arr[0])
.filter((url) => url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0)
/**
* WebTorrent version.
*/
const VERSION = require('../../package.json').version
/**
* Version number in Azureus-style. Generated from major and minor semver version.
* For example:
* '0.16.1' -> '0016'
* '1.2.5' -> '0102'
*/
const VERSION_STR = VERSION.match(/([0-9]+)/g)
.slice(0, 2)
*/
import { ipcRenderer as ipc } from 'electron';
// import TorrentEngine from '../main/TorrentEngine';
import crypto from 'crypto';
// import { EventEmitter } from 'events';
import { announceList } from 'create-torrent';
import WebTorrent from 'webtorrent';
import zeroFill from 'zero-fill';
import networkAddress from 'network-address';
import pkg from '../package.json';
console.time('init');
// Force use of webtorrent trackers on all torrents
global.WEBTORRENT_ANNOUNCE = announceList
.map((arr) => arr[0])
.filter((url) => url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0);
/**
* Version number in Azureus-style. Generated from major and minor semver version.
* For example:
* '0.0.1' -> '0000'
* '0.1.0' -> '0001'
* '1.1.0' -> '0101'
*/
const VERSION = pkg.version;
/**
* Version prefix string (used in peer ID). MovieCast uses the Azureus-style
* encoding: '-', two characters for client id ('MC'), four ascii digits for version
* number, '-', followed by random numbers.
import WebTorrent from 'webtorrent';
import zeroFill from 'zero-fill';
import networkAddress from 'network-address';
import pkg from '../package.json';
import {
torrentWarning,
torrentError,
torrentInfoHash,
torrentMetaData,
torrentProgress,
torrentDone,
streamServerStarted
} from '../shared/actions/torrent';
// Force use of webtorrent trackers on all torrents
global.WEBTORRENT_ANNOUNCE = announceList
.map((arr) => arr[0])
.filter((url) => url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0);
/**
* Manager for WebTorrent
*
* A lot of the code here is inspired
* by WebTorrent Desktop
*
* @todo
* The torrent engine causes the UI to lagg
* In order to fix this the torrent engine should
* move to it's own window
*/
class TorrentEngine {
getInstance() {
if (this.client === null) {
const announce = announceList
.map((arr) => arr[0])
.filter((url) => url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0);
this.client = new WebTorrent({
peerId: Streamer.PEER_ID,
tracker: { announce }
});
}
return this.client;
}
}