Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 331298825e | |||
| 4719117504 | |||
| c0c33b8859 | |||
| 1922cf5b87 | |||
| fa5b7a3249 | |||
| 60f65152cb | |||
| d34b74e505 | |||
| 600173c959 | |||
| 49fd73aaf9 | |||
| dc9f73961e | |||
| a4094cb795 |
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
privateDownloadLocation: '/media/torrents-zfs',
|
||||
ldap: {
|
||||
url: 'ldap://10.1.0.55:389',
|
||||
bindDN: 'cn=ldapclient service,ou=people,dc=theta42,dc=com',
|
||||
@@ -21,5 +22,6 @@ module.exports = {
|
||||
port: 9091,
|
||||
username: 'william',
|
||||
password: '__IN SRECREST FILE__',
|
||||
statusUpdateInterval: 500,
|
||||
}
|
||||
};
|
||||
|
||||
4
conf/development.js
Normal file
4
conf/development.js
Normal file
@@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
};
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
const ps = require('./pubsub.js');
|
||||
const {Torrent} = require('>/models');
|
||||
|
||||
console.log('here!!!!!!!!!!!!!')
|
||||
const conf = require('>/conf');
|
||||
|
||||
let statusLock = false;
|
||||
setInterval(async function(){
|
||||
@@ -17,9 +16,4 @@ setInterval(async function(){
|
||||
// console.error('status interval error', error)
|
||||
}
|
||||
statusLock = false
|
||||
}, 10000, statusLock);
|
||||
|
||||
|
||||
// ps.subscribe(/./g, function(...args){
|
||||
// console.log('event', args);
|
||||
// });
|
||||
}, conf.transmission.statusUpdateInterval, statusLock);
|
||||
|
||||
@@ -11,10 +11,6 @@ var userLUR = new LRUCache({
|
||||
maxAge: 60000,
|
||||
});
|
||||
|
||||
const client = new Client({
|
||||
url: conf.url,
|
||||
});
|
||||
|
||||
const user_parse = function(data){
|
||||
if(data[conf.userNameAttribute]){
|
||||
data.username = data[conf.userNameAttribute];
|
||||
@@ -31,6 +27,10 @@ User.backing = "LDAP";
|
||||
|
||||
User.list = async function(){
|
||||
try{
|
||||
const client = new Client({
|
||||
url: conf.url,
|
||||
});
|
||||
|
||||
await client.bind(conf.bindDN, conf.bindPassword);
|
||||
|
||||
const res = await client.search(conf.userBase, {
|
||||
@@ -49,6 +49,10 @@ User.list = async function(){
|
||||
|
||||
User.listDetail = async function(){
|
||||
try{
|
||||
const client = new Client({
|
||||
url: conf.url,
|
||||
});
|
||||
|
||||
await client.bind(conf.bindDN, conf.bindPassword);
|
||||
|
||||
const res = await client.search(conf.userBase, {
|
||||
@@ -86,7 +90,11 @@ User.get = async function(data, key){
|
||||
data.searchValue = data.searchValue || data.uid;
|
||||
|
||||
let filter = `(&${conf.userFilter}(${data.searchKey}=${data.searchValue}))`;
|
||||
if(userLUR.get(filter)) return userLUR.get(filter)
|
||||
if(userLUR.get(filter)) return userLUR.get(filter);
|
||||
|
||||
const client = new Client({
|
||||
url: conf.url,
|
||||
});
|
||||
|
||||
await client.bind(conf.bindDN, conf.bindPassword);
|
||||
const res = await client.search(conf.userBase, {
|
||||
@@ -131,6 +139,10 @@ User.login = async function(data){
|
||||
|
||||
let user = await this.get(data.uid || data[conf.userNameAttribute] || data.username);
|
||||
|
||||
const client = new Client({
|
||||
url: conf.url,
|
||||
});
|
||||
|
||||
await client.bind(user.dn, data.password);
|
||||
|
||||
await client.unbind();
|
||||
|
||||
@@ -36,12 +36,18 @@ module.exports = (sequelize, DataTypes, Model) => {
|
||||
// console.log('instance', instance)
|
||||
await this.build(data).validate();
|
||||
// console.log('validate', val);
|
||||
data.isPrivate = data.isPrivate === 'true' ? true : false;
|
||||
|
||||
let res = await tr_client.addUrl(data.magnetLink);
|
||||
let options = {
|
||||
'download-dir': data.isPrivate ? `${conf.privateDownloadLocation}/${data.added_by}` : undefined,
|
||||
};
|
||||
|
||||
let res = await tr_client.addUrl(data.magnetLink, options);
|
||||
|
||||
return await super.create({
|
||||
magnetLink: data.magnetLink,
|
||||
hashString: res.hashString,
|
||||
isPrivate: data.isPrivate,
|
||||
name: res.name,
|
||||
added_by: data.added_by,
|
||||
status: 0,
|
||||
|
||||
2126
package-lock.json
generated
2126
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -55,6 +55,8 @@
|
||||
|
||||
<!--
|
||||
Dialog boxes to be displayed
|
||||
|
||||
Login Dialog
|
||||
-->
|
||||
|
||||
<div id="tbp_proxy_login_dialog" title="SSO Login">
|
||||
@@ -110,7 +112,7 @@
|
||||
|
||||
#tbp_proxy_torrent_dialog ul{
|
||||
height: 400px;
|
||||
overflow-y: scroll;
|
||||
/*overflow-y: scroll;*/
|
||||
list-style-type: none;
|
||||
padding-left: 0;
|
||||
margin-top: 0;
|
||||
@@ -218,7 +220,8 @@
|
||||
<form action="torrent" method="post" onsubmit="formAJAX(this)" evalAJAX="
|
||||
app.publish('torrent:add', {...data, __noSocket: true});
|
||||
$('#tbp_proxy_torrent_add_dialog').dialog('close');
|
||||
openDialog($('#tbp_proxy_torrent_dialog'))
|
||||
openDialog($('#tbp_proxy_torrent_dialog'));
|
||||
savePrivateState(data, this);
|
||||
">
|
||||
<p>
|
||||
<label for="_name">Name:</label>
|
||||
@@ -238,14 +241,12 @@
|
||||
<input type="text" name="hashString" value="{{{hashString}}}" readonly/>
|
||||
</p>
|
||||
|
||||
<p style="display:none">
|
||||
<legend>Public Download:</legend>
|
||||
<p>
|
||||
<label for="isPrivate-false" title="The download will appare in the communal download folder">Public:</label>
|
||||
<input type="radio" name="isPrivate" id="isPrivate-false" value="false" />
|
||||
|
||||
<label for="radio-1" title="The download will appare in the communal download folder">Public</label>
|
||||
<input type="radio" name="isPrivate" id="radio-1" value="true" checked readonly/>
|
||||
|
||||
<label for="radio-2" title="Only you(and the admins) will be able to see this download">Private</label>
|
||||
<input type="radio" name="isPrivate" id="radio-2" value="false" readonly/>
|
||||
<label for="isPrivate-true" title="Only you(and the admins) will be able to see this download">Private:</label>
|
||||
<input type="radio" name="isPrivate" id="isPrivate-true" value="true" />
|
||||
</p>
|
||||
|
||||
<p style="display:none">
|
||||
@@ -260,7 +261,7 @@
|
||||
|
||||
<hr />
|
||||
<button type="submit">Start Download</button>
|
||||
<button onclick="$('#tbp_proxy_torrent_add_dialog').dialog('close')">Cancel</button>
|
||||
<button type="reset" onclick="$('#tbp_proxy_torrent_add_dialog').dialog('close')">Cancel</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -268,7 +269,7 @@
|
||||
|
||||
|
||||
<!--
|
||||
The bar injected at the top of the page
|
||||
Injected Header bar
|
||||
-->
|
||||
|
||||
<div id="tbp_proxy_header_right">
|
||||
@@ -286,37 +287,37 @@
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
var commonDialogOptions = {
|
||||
position: { my: "left top", at: "left bottom", of: '#tbp_proxy_header_right' },
|
||||
position: { my: 'left top', at: 'left bottom', of: '#tbp_proxy_header_right' },
|
||||
autoOpen: false,
|
||||
resizable: false,
|
||||
closeOnEscape: true,
|
||||
draggable: false,
|
||||
width: 'auto',
|
||||
// maxWidth: document.body.clientWidth,
|
||||
// width: 'auto',
|
||||
};
|
||||
|
||||
/* Login Button and dialog*/
|
||||
$( "#tbp_proxy_login_dialog" ).dialog(commonDialogOptions);
|
||||
$('#tbp_proxy_login_dialog').dialog(commonDialogOptions);
|
||||
|
||||
$( "#tbp_proxy_login_dialog_opener" ).on( "click", function() {
|
||||
// https://stackoverflow.com/a/6500385
|
||||
$( "#tbp_proxy_login_dialog" ).parent().css({position:"fixed", 'margin-right': "2em", 'margin-top': '3em'}).end().dialog( "open" );
|
||||
$('#tbp_proxy_login_dialog_opener').on('click', function() {
|
||||
openDialog($('#tbp_proxy_login_dialog'));
|
||||
});
|
||||
|
||||
|
||||
/* Torrent list button and dialog */
|
||||
$( "#tbp_proxy_torrent_dialog" ).dialog(commonDialogOptions);
|
||||
$('#tbp_proxy_torrent_dialog').dialog(commonDialogOptions);
|
||||
|
||||
$( "#tbp_proxy_torrent_dialog_opener" ).on( "click", function() {
|
||||
$( "#tbp_proxy_torrent_dialog" ).parent().css({position:"fixed", 'margin-right': "2em", 'margin-top': '3em'}).end().dialog( "open" );
|
||||
$('#tbp_proxy_torrent_dialog_opener').on('click', function() {
|
||||
if($('#tbp_proxy_torrent_dialog').dialog('isOpen')){
|
||||
$('#tbp_proxy_torrent_dialog').dialog('close')
|
||||
}else{
|
||||
openDialog($('#tbp_proxy_torrent_dialog'));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/* Torrent add button and dialog */
|
||||
$( "#tbp_proxy_torrent_add_dialog" ).dialog({
|
||||
modal: true,
|
||||
height: 300,
|
||||
...commonDialogOptions
|
||||
});
|
||||
$('#tbp_proxy_torrent_add_dialog').dialog(commonDialogOptions);
|
||||
|
||||
|
||||
/* Enable tooltips*/
|
||||
@@ -327,7 +328,7 @@
|
||||
app.auth.isLoggedIn(function(error, data){
|
||||
if(data){
|
||||
|
||||
$("body").on('click', 'img.718link', function(el){
|
||||
$('body').on('click', 'img.718link', function(event){
|
||||
// magnetLink
|
||||
let magnetLinkParams = new URLSearchParams($(this).data('link'));
|
||||
|
||||
@@ -337,14 +338,20 @@
|
||||
hashString: magnetLinkParams.get('magnet:?xt').split(':').pop().toLowerCase(),
|
||||
});
|
||||
|
||||
$('#tbp_proxy_torrent_add_dialog').parent().css({position:"fixed", 'margin-right': "2em", 'margin-top': '3em'}).end().dialog('open');
|
||||
if(localStorage.getItem('isPrivate') === 'true'){
|
||||
$('#isPrivate-true').prop('checked', true);
|
||||
}else{
|
||||
$('#isPrivate-false').prop('checked', true);
|
||||
}
|
||||
|
||||
openDialog($('#tbp_proxy_torrent_add_dialog'));
|
||||
});
|
||||
|
||||
// Look for
|
||||
$('a').each(function(idx, el){
|
||||
var $el = $(el);
|
||||
if($el.attr('href') && $el.attr('href').match("magnet:?")){
|
||||
$el.replaceWith('<img class="tbp_proxy_is_authed 718link" src="/__static/img/Transmission_Icon.svg" height=24 width=24 data-link="'+$el.attr('href')+'"/>')
|
||||
if($el.attr('href') && $el.attr('href').match('magnet:?')){
|
||||
$el.before(`<img class="tbp_proxy_is_authed 718link" src="/__static/img/Transmission_Icon.svg" height=24 width=24 data-link="${$el.attr('href')}"/>`)
|
||||
}
|
||||
});
|
||||
|
||||
@@ -354,35 +361,47 @@
|
||||
|
||||
app.subscribe('torrent:server:status', function(data, topic){
|
||||
app.torrent.isDown = false
|
||||
$('#tbp_proxy_torrent_dialog_opener').css('background', "lightseagreen")
|
||||
$('#tbp_proxy_torrent_dialog_opener').css('background', 'lightseagreen')
|
||||
$.scope.tbp_proxy_torrent_dialog_opener_status.update(app.torrent.parseServerStatus(data));
|
||||
});
|
||||
|
||||
app.subscribe(`app:api:error:555`, function(data, topics){
|
||||
app.subscribe('app:api:error:555', function(data, topics){
|
||||
app.torrent.isDown = true
|
||||
$('#tbp_proxy_torrent_dialog_opener').css('background', "red")
|
||||
$('#tbp_proxy_torrent_dialog_opener').css('background', 'red')
|
||||
});
|
||||
|
||||
app.subscribe('torrent:server:status:down', function(data, topic){
|
||||
app.torrent.isDown = true
|
||||
$('#tbp_proxy_torrent_dialog_opener').css('background', "red")
|
||||
$('#tbp_proxy_torrent_dialog_opener').css('background', 'red')
|
||||
});
|
||||
|
||||
listTorrents();
|
||||
setInterval(refreshTorrents, 5000);
|
||||
setInterval(refreshTorrents, 1000);
|
||||
app.torrent.migrate();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function savePrivateState(data){
|
||||
localStorage.setItem('isPrivate', data.isPrivate);
|
||||
if(data.isPrivate){
|
||||
$('#isPrivate-true').prop('checked', true);
|
||||
} else {
|
||||
$('#isPrivate-false').prop('checked', true);
|
||||
}
|
||||
}
|
||||
|
||||
function humanFileSize(size) {
|
||||
var i = size == 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024));
|
||||
return (size / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
|
||||
}
|
||||
|
||||
function openDialog($el){
|
||||
// https://stackoverflow.com/a/6500385
|
||||
$el.parent().css({
|
||||
position:"fixed", 'margin-right': "2em", 'margin-top': '3em'
|
||||
position: 'fixed',
|
||||
'margin-right': '2em',
|
||||
'margin-top': '3em'
|
||||
}).end().dialog('open');
|
||||
}
|
||||
|
||||
@@ -411,9 +430,9 @@
|
||||
let isDown = false;
|
||||
|
||||
// Dont spam the server if its not online
|
||||
$( document ).on( "ajaxSend", function(event, ajax, res, ...args) {
|
||||
$(document).on('ajaxSend', function(event, ajax, res, ...args) {
|
||||
if(res.url.startsWith('/__api/torrent') && isDown){
|
||||
ajax.abort()
|
||||
ajax.abort();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -469,7 +488,7 @@
|
||||
...data,
|
||||
"downloadSpeed": humanFileSize(data.downloadSpeed)+'/s',
|
||||
"uploadSpeed": humanFileSize(data.uploadSpeed)+'/s',
|
||||
/* "activeTorrentCount": 11,
|
||||
/* 'activeTorrentCount": 11,
|
||||
"cumulative-stats": {
|
||||
"downloadedBytes": 2925927098021,
|
||||
"filesAdded": 80609,
|
||||
@@ -503,25 +522,6 @@
|
||||
"isFinished": torrent.isFinished || percentDone === 100,
|
||||
"createdAtString": moment(torrent.createdAt).fromNow(),
|
||||
|
||||
// "createdAt": "2024-01-05T21:18:30.607Z",
|
||||
// "isFinished": false,
|
||||
// "isStalled": false,
|
||||
// "name": "reacher.s02e06.1080p.web.h264-successfulcrab[EZTVx.to].mkv",
|
||||
// "hashString": "4794a0915cada6c491eb5c910e1f4a0da727cac8",
|
||||
// "status": 4,
|
||||
// "id": 1,
|
||||
|
||||
// "peersConnected": 50,
|
||||
// "added_by": "wmantly",
|
||||
// "errorString": "",
|
||||
|
||||
// "downloadDir": "/media/torrents",
|
||||
// "files": [],
|
||||
// "peers": [],
|
||||
// "magnetLink": "magnet:?xt=urn:btih:4794A0915CADA6C491EB5C910E1F4A0DA727CAC8&dn=Reacher+S02E06+1080p+WEB+H264-SuccessfulCrab&tr=http%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce&tr=udp%3A%2F%2F47.ip-51-68-199.eu%3A6969%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2780%2Fannounce&tr=udp%3A%2F%2F9.rarbg.to%3A2710%2Fannounce&tr=udp%3A%2F%2F9.rarbg.to%3A2730%2Fannounce&tr=udp%3A%2F%2F9.rarbg.to%3A2920%2Fannounce&tr=udp%3A%2F%2Fopen.stealth.si%3A80%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.cyberia.is%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.dler.org%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.internetwarriors.net%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=udp%3A%2F%2Ftracker.pirateparty.gr%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.tiny-vps.com%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.torrent.eu.org%3A451%2Fannounce",
|
||||
// "isPrivate": false,
|
||||
// "updatedAt": "2024-01-05T21:32:54.493Z"
|
||||
// "torrent_id": "454",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,12 @@ const proxyTarget = {
|
||||
target: 'https://piratebay.party',
|
||||
host: 'piratebay.party',
|
||||
// target: 'http://172.16.0.1',
|
||||
// target: 'http://piratebayo3klnzokct3wt5yyxb2vpebbuyjl7m623iaxmqhsd52coid.onion',
|
||||
// host: 'piratebayo3klnzokct3wt5yyxb2vpebbuyjl7m623iaxmqhsd52coid.onion'
|
||||
// target: 'https://thepiratebay.org',
|
||||
// host: 'thepiratebay.org',
|
||||
// target: 'https://www2.thepiratebay3.to',
|
||||
// host: 'www2.thepiratebay3.to'
|
||||
}
|
||||
|
||||
function generateRegexForDomain(domain) {
|
||||
@@ -38,12 +43,13 @@ function generateRegexForDomain(domain) {
|
||||
router.all("/*", proxy({
|
||||
target: proxyTarget.target,
|
||||
agent: proxyTarget.target.startsWith('https') ? https.globalAgent : http.globalAgent,
|
||||
secure: false,
|
||||
secure: true,
|
||||
autoRewrite: true,
|
||||
changeOrigin: true,
|
||||
followRedirects: true,
|
||||
headers: {
|
||||
host: proxyTarget.host
|
||||
host: proxyTarget.host,
|
||||
'Accept-Encoding': 'gzip',
|
||||
},
|
||||
selfHandleResponse: true, // so that the onProxyRes takes care of sending the response
|
||||
onProxyRes: function(proxyRes, req, res){
|
||||
@@ -54,7 +60,7 @@ router.all("/*", proxy({
|
||||
console.log('403')
|
||||
var url = (req.protocol + '://' + req.get('host') + req.originalUrl);
|
||||
proxyRes.headers['location'] = url.replace(/\??ckattempt\=\d+/, '');
|
||||
proxyRes.statusCode == 307
|
||||
proxyRes.statusCode = 307;
|
||||
|
||||
return res.end()
|
||||
}
|
||||
@@ -74,6 +80,7 @@ router.all("/*", proxy({
|
||||
});
|
||||
|
||||
proxyRes.on('end', function(){
|
||||
// console.log("proxyRes.headers['content-encoding']", proxyRes.headers['content-encoding']);
|
||||
body = proxyRes.headers['content-encoding'] === 'gzip' ? zlib.gunzipSync(body).toString('utf8') : body;
|
||||
body = proxyRes.headers['content-encoding'] === 'br' ? zlib.brotliDecompressSync(body).toString('utf8') : body;
|
||||
if(proxyRes.statusCode === 200 &&
|
||||
|
||||
Reference in New Issue
Block a user