merged
This commit is contained in:
commit
c8f00cdeaf
31
app.js
31
app.js
@ -1,5 +1,6 @@
|
|||||||
const zlib = require('zlib');
|
const zlib = require('zlib');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
var https = require('https');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const proxy = require('http-proxy-middleware');
|
const proxy = require('http-proxy-middleware');
|
||||||
|
|
||||||
@ -14,7 +15,9 @@ const mainjs = fs.readFileSync('./static/main.js', 'utf8');
|
|||||||
|
|
||||||
const Transmission = require('transmission-promise')
|
const Transmission = require('transmission-promise')
|
||||||
var tr_client = new Transmission({
|
var tr_client = new Transmission({
|
||||||
host:'192.168.1.176',
|
host:'tran.718it.biz',
|
||||||
|
ssl: true,
|
||||||
|
port: 443,
|
||||||
username: 'william',
|
username: 'william',
|
||||||
password: 'palm7',
|
password: 'palm7',
|
||||||
})
|
})
|
||||||
@ -55,13 +58,25 @@ app.all('/static/main.js', function(req,res){
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.all("/*", proxy({
|
app.all("/*", proxy({
|
||||||
target: 'http://piratebayztemzmv.onion', //'http://piratebayztemzmv.onion',
|
target: 'https://piratebay.party',
|
||||||
|
agent: https.globalAgent,
|
||||||
autoRewrite: true,
|
autoRewrite: true,
|
||||||
|
secure: false,
|
||||||
|
followRedirects: true,
|
||||||
|
autoRewrite: true,
|
||||||
|
changeOrigin: true,
|
||||||
|
secure: false,
|
||||||
|
followRedirects: true,
|
||||||
|
autoRewrite: true,
|
||||||
|
changeOrigin: true,
|
||||||
|
headers: {
|
||||||
|
host: 'piratebay.party'
|
||||||
|
},
|
||||||
selfHandleResponse: true, // so that the onProxyRes takes care of sending the response
|
selfHandleResponse: true, // so that the onProxyRes takes care of sending the response
|
||||||
onProxyRes: function(proxyRes, req, res){
|
onProxyRes: function(proxyRes, req, res){
|
||||||
|
|
||||||
if(proxyRes.statusCode === 403 && proxyRes.headers['content-type'] &&
|
if(proxyRes.statusCode === 403 && proxyRes.headers['content-type'] &&
|
||||||
proxyRes.headers['content-type'].match('html')
|
proxyRes.headers['content-type'].match('html')
|
||||||
){
|
){
|
||||||
console.log('403')
|
console.log('403')
|
||||||
var url = (req.protocol + '://' + req.get('host') + req.originalUrl);
|
var url = (req.protocol + '://' + req.get('host') + req.originalUrl);
|
||||||
@ -73,10 +88,13 @@ app.all("/*", proxy({
|
|||||||
|
|
||||||
for(let key of Object.keys(proxyRes.headers)){
|
for(let key of Object.keys(proxyRes.headers)){
|
||||||
if(['content-encoding'].includes(key)) continue;
|
if(['content-encoding'].includes(key)) continue;
|
||||||
res.set(key, proxyRes.headers[key].toString().replace('http://', 'https://'))
|
// res.set(key, proxyRes.headers[key].toString().replace('http://', 'https://'))
|
||||||
}
|
}
|
||||||
|
|
||||||
let body = new Buffer('');
|
let body = new Buffer('');
|
||||||
|
proxyRes.on('error', function(e){
|
||||||
|
console.error('ERROR!', e)
|
||||||
|
});
|
||||||
|
|
||||||
proxyRes.on('data', function(data){
|
proxyRes.on('data', function(data){
|
||||||
body = Buffer.concat([body, data]);
|
body = Buffer.concat([body, data]);
|
||||||
@ -84,12 +102,13 @@ app.all("/*", proxy({
|
|||||||
|
|
||||||
proxyRes.on('end', function(){
|
proxyRes.on('end', function(){
|
||||||
body = proxyRes.headers['content-encoding'] === 'gzip' ? zlib.gunzipSync(body).toString('utf8') : body;
|
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 &&
|
if(proxyRes.statusCode === 200 &&
|
||||||
proxyRes.headers['content-type'] &&
|
proxyRes.headers['content-type'] &&
|
||||||
proxyRes.headers['content-type'].match('html')
|
proxyRes.headers['content-type'].match('html')
|
||||||
){
|
){
|
||||||
body = body.replace(/http\:\/\/piratebayztemzmv\.onion\//g, '/');
|
body = body.toString().replace(/<\s*script[^]*?script>/igm, '');
|
||||||
// body = body.toString().replace(/<\s*script[^]*?script>/igm, '');
|
body = body.replace(/piratebay\.party/ig, 'tpb.718it.biz');
|
||||||
body = body.replace(/<\s*iframe[^]*?iframe>/igm, '');
|
body = body.replace(/<\s*iframe[^]*?iframe>/igm, '');
|
||||||
body = body.replace("</html>", '');
|
body = body.replace("</html>", '');
|
||||||
body = body+inject+"</html>";
|
body = body+inject+"</html>";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user