Make tracker configurable, add crypto donations (#114)

pull/116/head
Alex Kern 6 years ago committed by GitHub
parent a693751502
commit 5c67daf4cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -62,7 +62,7 @@ export default class App extends React.Component {
</div> </div>
<footer className="footer"> <footer className="footer">
<p> <p>
BTC Donations: <strong>1P7yFQAC3EmpvsB7K9s6bKPvXEP1LPoQnY</strong> <strong>Like FilePizza?</strong> Support it&apos;s development with a <a href="https://commerce.coinbase.com/checkout/247b6ffe-fb4e-47a8-9a76-e6b7ef83ea22">donation in crypto</a>.
</p> </p>
<p className="byline"> <p className="byline">

@ -42,6 +42,14 @@ app.use([
require("./middleware/react") require("./middleware/react")
]); ]);
const TRACKERS = process.env.WEBTORRENT_TRACKERS
? process.env.WEBTORRENT_TRACKERS.split(',').map(t => [t.trim()])
: [
["wss://tracker.openwebtorrent.com"],
["wss://tracker.btorrent.xyz"],
["wss://tracker.fastcast.nz"]
];
function bootServer(server) { function bootServer(server) {
var io = socketIO(server); var io = socketIO(server);
io.set("transports", ["polling"]); io.set("transports", ["polling"]);
@ -61,9 +69,9 @@ function bootServer(server) {
}); });
}); });
socket.on("rtcConfig", function(_, res) { socket.on("trackerConfig", function(_, res) {
ice.getICEServers().then(function(iceServers) { ice.getICEServers().then(function(iceServers) {
res({ iceServers: iceServers }); res({ rtcConfig: { iceServers }, announce: TRACKERS });
}); });
}); });

@ -34,8 +34,8 @@ export default alt.createStore(class DownloadStore {
if (this.status !== 'ready') return if (this.status !== 'ready') return
this.status = 'requesting' this.status = 'requesting'
getClient().then((client) => { getClient().then(client => {
client.add(this.infoHash, (torrent) => { client.add(this.infoHash, { announce: client.tracker.announce }, (torrent) => {
this.setState({ status: 'downloading' }) this.setState({ status: 'downloading' })
const updateSpeed = () => { const updateSpeed = () => {

@ -3,14 +3,6 @@ import alt from "../alt";
import socket from "filepizza-socket"; import socket from "filepizza-socket";
import { getClient } from "../wt"; import { getClient } from "../wt";
const TRACKERS = process.env.WEBTORRENT_TRACKERS
? process.env.WEBTORRENT_TRACKERS.split(',').map(t => t.trim())
: [
["wss://tracker.openwebtorrent.com"],
["wss://tracker.btorrent.xyz"],
["wss://tracker.fastcast.nz"]
];
const SPEED_REFRESH_TIME = 2000; const SPEED_REFRESH_TIME = 2000;
export default alt.createStore( export default alt.createStore(
@ -34,7 +26,7 @@ export default alt.createStore(
this.status = "processing"; this.status = "processing";
getClient().then(client => { getClient().then(client => {
client.seed(file, { announce: TRACKERS }, torrent => { client.seed(file, { announce: client.tracker.announce }, torrent => {
const updateSpeed = () => { const updateSpeed = () => {
this.setState({ this.setState({
speedUp: torrent.uploadSpeed, speedUp: torrent.uploadSpeed,

@ -2,9 +2,9 @@ import socket from 'filepizza-socket'
export function getClient() { export function getClient() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
socket.emit('rtcConfig', {}, (rtcConfig) => { socket.emit('trackerConfig', {}, (trackerConfig) => {
const client = new WebTorrent({ const client = new WebTorrent({
tracker: { rtcConfig } tracker: trackerConfig
}) })
resolve(client) resolve(client)
}) })

Loading…
Cancel
Save