Add explicit tracker list

pull/72/head
Alex Kern 8 years ago
parent 4b0c5a4da3
commit f1952c3e88

@ -1,61 +1,70 @@
import UploadActions from '../actions/UploadActions' import UploadActions from "../actions/UploadActions";
import alt from '../alt' import alt from "../alt";
import socket from 'filepizza-socket' import socket from "filepizza-socket";
import { getClient } from '../wt' import { getClient } from "../wt";
const SPEED_REFRESH_TIME = 2000 const TRACKERS = [
["wss://tracker.btorrent.xyz"],
["wss://tracker.openwebtorrent.com"],
["wss://tracker.fastcast.nz"]
];
export default alt.createStore(class UploadStore { const SPEED_REFRESH_TIME = 2000;
export default alt.createStore(
class UploadStore {
constructor() { constructor() {
this.bindActions(UploadActions) this.bindActions(UploadActions);
this.fileName = '' this.fileName = "";
this.fileSize = 0 this.fileSize = 0;
this.fileType = '' this.fileType = "";
this.infoHash = null this.infoHash = null;
this.peers = 0 this.peers = 0;
this.speedUp = 0 this.speedUp = 0;
this.status = 'ready' this.status = "ready";
this.token = null this.token = null;
} }
onUploadFile(file) { onUploadFile(file) {
if (this.status !== 'ready') return if (this.status !== "ready") return;
this.status = 'processing' this.status = "processing";
getClient().then((client) => {
client.seed(file, (torrent) => {
getClient().then(client => {
client.seed(file, { announce: TRACKERS }, torrent => {
const updateSpeed = () => { const updateSpeed = () => {
this.setState({ this.setState({
speedUp: torrent.uploadSpeed, speedUp: torrent.uploadSpeed,
peers: torrent.numPeers peers: torrent.numPeers
}) });
} };
torrent.on('upload', updateSpeed) torrent.on("upload", updateSpeed);
torrent.on('download', updateSpeed) torrent.on("download", updateSpeed);
setInterval(updateSpeed, SPEED_REFRESH_TIME) setInterval(updateSpeed, SPEED_REFRESH_TIME);
socket.emit('upload', { socket.emit(
"upload",
{
fileName: file.name, fileName: file.name,
fileSize: file.size, fileSize: file.size,
fileType: file.type, fileType: file.type,
infoHash: torrent.magnetURI infoHash: torrent.magnetURI
}, (token) => { },
token => {
this.setState({ this.setState({
status: 'uploading', status: "uploading",
token: token, token: token,
fileName: file.name, fileName: file.name,
fileSize: file.size, fileSize: file.size,
fileType: file.type, fileType: file.type,
infoHash: torrent.magnetURI infoHash: torrent.magnetURI
}) });
})
})
})
} }
);
}, 'UploadStore') });
});
}
},
"UploadStore"
);

Loading…
Cancel
Save