Skip to content

Commit

Permalink
✔ Torrent Tracker ~
Browse files Browse the repository at this point in the history
  • Loading branch information
bifeldy committed Nov 9, 2023
1 parent cbd4f70 commit a8a33de
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/api/controllers/torrent.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class TorrentController {
try {
if ('magnetHash' in req.body) {
webtorrentHealth(req.body.magnetHash, {
trackers: environment.torrent.trackerAnnounce,
trackers: req.body.trackList || environment.torrent.trackerAnnounce,
timeout: req.body.trackTimeout || 1234
}, (err, data) => {
if (err) {
Expand Down
10 changes: 3 additions & 7 deletions src/app/_pages/torrent/torrent.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ export class TorrentComponent implements OnInit, OnDestroy {
subsUser = null;
subsTableDataRow = null;

timedOut = null;

constructor(
private snackBar: MatSnackBar,
private clipboard: Clipboard,
Expand Down Expand Up @@ -106,10 +104,6 @@ export class TorrentComponent implements OnInit, OnDestroy {
this.subsDialog?.unsubscribe();
this.subsUser?.unsubscribe();
this.subsTableDataRow?.unsubscribe();
if (this.timedOut) {
clearTimeout(this.timedOut);
this.timedOut = null;
}
}

copyMagnetHashToClipboard(magnetHash: string): void {
Expand Down Expand Up @@ -140,8 +134,10 @@ export class TorrentComponent implements OnInit, OnDestroy {
}

reviveTorrent(): void {
this.bs.busy();
this.torrent.resurrectFiles((error, result) => {
this.refreshAllGraph();
this.bs.idle();
});
}

Expand Down Expand Up @@ -278,7 +274,7 @@ export class TorrentComponent implements OnInit, OnDestroy {

refreshAllGraph(): void {
for (const d of this.dataSource.data) {
this.timedOut = setTimeout(() => {
setTimeout(() => {
this.refreshGraph(d);
}, 1234);
}
Expand Down
6 changes: 4 additions & 2 deletions src/app/_shared/services/torrent.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { BehaviorSubject, Observable } from 'rxjs';
import { Options, Instance, Torrent, TorrentOptions } from 'webtorrent';
import { Wire } from 'bittorrent-protocol';
import { openDB } from 'idb';
import { Buffer } from 'buffer';
import { Buffer } from 'buffer';

import { environment } from '../../../environments/app/environment';

Expand Down Expand Up @@ -211,7 +211,9 @@ export class TorrentService {
this.refCallback = callback;
this.checkHealthOnTracker({
magnetHash,
trackTimeout: 1234
trackTimeout: 1234,
trackList: environment.torrent.trackerAnnounce,
iceServers: environment.torrent.iceServers
}).subscribe({
next: (res: any) => {
this.gs.log('[TORRENT_CLIENT_HEALTH_SUCCESS]', res.result);
Expand Down
11 changes: 11 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ export const CONSTANTS = {
timeLoginRememberMe: 7 * 24 * 60 * 60, // 7 Days
timeResetAccount: 5 * 60, // 5 Minutes
timeMaxDaysNotification: 7 * 24 * 60 * 60 * 1000, // 7 Days
torrentIceStunServer: [
'stun:stun.cloudflare.com',
'stun:stun.l.google.com:19302',
'stun:tracker.fansub.id:11111'
],
torrentTracker: [
'wss://tracker.fansub.id',
'wss://tracker.openwebtorrent.com',
'wss://tracker.webtorrent.dev',
'wss://tracker.btorrent.xyz'
],
verificationDomainCname: [
'ghs.google.com'
],
Expand Down
6 changes: 3 additions & 3 deletions src/environments/api/environment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { SECRETS } from '../../secrets';

import { CONSTANTS } from '../../constants';

import { Anime } from '../../api/entities/Anime';
import { Attachment } from '../../api/entities/Attachment';
import { ApiKey } from '../../api/entities/ApiKey';
Expand Down Expand Up @@ -162,9 +164,7 @@ export const environment = {
externalApiDorama: 'https://kuryana.vercel.app',
externalApiImage: 'https://api.imgbb.com/1/upload',
torrent: {
trackerAnnounce: [
`wss://tracker.fansub.id`
],
trackerAnnounce: CONSTANTS.torrentTracker
},
malClientId: SECRETS().MAL_CLIENT_ID, // '',
idCloudHost: {
Expand Down
16 changes: 4 additions & 12 deletions src/environments/app/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { CONSTANTS } from "../../constants";

export const environment = {
production: true,
siteName: 'FansubID',
Expand All @@ -13,19 +15,9 @@ export const environment = {
guild_id: '342220398022098944'
},
torrent: {
trackerAnnounce: [
'wss://tracker.fansub.id',
'wss://tracker.btorrent.xyz',
'wss://tracker.openwebtorrent.com'
],
trackerAnnounce: CONSTANTS.torrentTracker,
iceServers: [
{
urls: [
'stun:tracker.fansub.id:11111',
'stun:openrelay.metered.ca:80',
'stun:stun.l.google.com:19302'
]
}
{ urls: CONSTANTS.torrentIceStunServer }
]
}
};
16 changes: 4 additions & 12 deletions src/environments/app/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.

import { CONSTANTS } from "../../constants";

export const environment = {
production: false,
siteName: 'FansubID',
Expand All @@ -17,19 +19,9 @@ export const environment = {
guild_id: '342220398022098944'
},
torrent: {
trackerAnnounce: [
'wss://tracker.fansub.id',
'wss://tracker.btorrent.xyz',
'wss://tracker.openwebtorrent.com'
],
trackerAnnounce: CONSTANTS.torrentTracker,
iceServers: [
{
urls: [
'stun:tracker.fansub.id:11111',
'stun:openrelay.metered.ca:80',
'stun:stun.l.google.com:19302'
]
}
{ urls: CONSTANTS.torrentIceStunServer }
]
}
};
Expand Down

0 comments on commit a8a33de

Please sign in to comment.