mirror of https://github.com/kern/filepizza
Add explicit tracker list
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"],
|
||||||
export default alt.createStore(class UploadStore {
|
["wss://tracker.openwebtorrent.com"],
|
||||||
|
["wss://tracker.fastcast.nz"]
|
||||||
constructor() {
|
];
|
||||||
this.bindActions(UploadActions)
|
|
||||||
|
const SPEED_REFRESH_TIME = 2000;
|
||||||
this.fileName = ''
|
|
||||||
this.fileSize = 0
|
export default alt.createStore(
|
||||||
this.fileType = ''
|
class UploadStore {
|
||||||
this.infoHash = null
|
constructor() {
|
||||||
this.peers = 0
|
this.bindActions(UploadActions);
|
||||||
this.speedUp = 0
|
|
||||||
this.status = 'ready'
|
this.fileName = "";
|
||||||
this.token = null
|
this.fileSize = 0;
|
||||||
}
|
this.fileType = "";
|
||||||
|
this.infoHash = null;
|
||||||
onUploadFile(file) {
|
this.peers = 0;
|
||||||
if (this.status !== 'ready') return
|
this.speedUp = 0;
|
||||||
this.status = 'processing'
|
this.status = "ready";
|
||||||
|
this.token = null;
|
||||||
getClient().then((client) => {
|
}
|
||||||
client.seed(file, (torrent) => {
|
|
||||||
|
onUploadFile(file) {
|
||||||
const updateSpeed = () => {
|
if (this.status !== "ready") return;
|
||||||
this.setState({
|
this.status = "processing";
|
||||||
speedUp: torrent.uploadSpeed,
|
|
||||||
peers: torrent.numPeers
|
getClient().then(client => {
|
||||||
})
|
client.seed(file, { announce: TRACKERS }, torrent => {
|
||||||
}
|
const updateSpeed = () => {
|
||||||
|
this.setState({
|
||||||
torrent.on('upload', updateSpeed)
|
speedUp: torrent.uploadSpeed,
|
||||||
torrent.on('download', updateSpeed)
|
peers: torrent.numPeers
|
||||||
setInterval(updateSpeed, SPEED_REFRESH_TIME)
|
});
|
||||||
|
};
|
||||||
socket.emit('upload', {
|
|
||||||
fileName: file.name,
|
torrent.on("upload", updateSpeed);
|
||||||
fileSize: file.size,
|
torrent.on("download", updateSpeed);
|
||||||
fileType: file.type,
|
setInterval(updateSpeed, SPEED_REFRESH_TIME);
|
||||||
infoHash: torrent.magnetURI
|
|
||||||
}, (token) => {
|
socket.emit(
|
||||||
this.setState({
|
"upload",
|
||||||
status: 'uploading',
|
{
|
||||||
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
|
},
|
||||||
})
|
token => {
|
||||||
})
|
this.setState({
|
||||||
|
status: "uploading",
|
||||||
})
|
token: token,
|
||||||
})
|
fileName: file.name,
|
||||||
}
|
fileSize: file.size,
|
||||||
|
fileType: file.type,
|
||||||
}, 'UploadStore')
|
infoHash: torrent.magnetURI
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"UploadStore"
|
||||||
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue