proxy fixes #8
| @ -22,7 +22,12 @@ const proxyTarget = { | |||||||
|         target: 'https://piratebay.party', |         target: 'https://piratebay.party', | ||||||
|         host: 'piratebay.party', |         host: 'piratebay.party', | ||||||
|         // target: 'http://172.16.0.1', |         // target: 'http://172.16.0.1', | ||||||
|  |         // target: 'http://piratebayo3klnzokct3wt5yyxb2vpebbuyjl7m623iaxmqhsd52coid.onion', | ||||||
|         // host: 'piratebayo3klnzokct3wt5yyxb2vpebbuyjl7m623iaxmqhsd52coid.onion' |         // host: 'piratebayo3klnzokct3wt5yyxb2vpebbuyjl7m623iaxmqhsd52coid.onion' | ||||||
|  |         // target: 'https://thepiratebay.org', | ||||||
|  |         // host: 'thepiratebay.org', | ||||||
|  |         // target: 'https://www2.thepiratebay3.to', | ||||||
|  |         // host: 'www2.thepiratebay3.to' | ||||||
| } | } | ||||||
|  |  | ||||||
| function generateRegexForDomain(domain) { | function generateRegexForDomain(domain) { | ||||||
| @ -38,12 +43,13 @@ function generateRegexForDomain(domain) { | |||||||
| router.all("/*", proxy({ | router.all("/*", proxy({ | ||||||
|         target: proxyTarget.target, |         target: proxyTarget.target, | ||||||
|         agent: proxyTarget.target.startsWith('https') ? https.globalAgent : http.globalAgent, |         agent: proxyTarget.target.startsWith('https') ? https.globalAgent : http.globalAgent, | ||||||
| 	secure: false, |         secure: true, | ||||||
|         autoRewrite: true, |         autoRewrite: true, | ||||||
|         changeOrigin: true, |         changeOrigin: true, | ||||||
|     followRedirects: true, |     followRedirects: true, | ||||||
|                 headers: { |                 headers: { | ||||||
|     		host: proxyTarget.host  |                 host: proxyTarget.host, | ||||||
|  |                 'Accept-Encoding': 'gzip', | ||||||
|         }, |         }, | ||||||
|         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){ | ||||||
| @ -54,7 +60,7 @@ router.all("/*", proxy({ | |||||||
|                         console.log('403') |                         console.log('403') | ||||||
|                         var url = (req.protocol + '://' + req.get('host') + req.originalUrl); |                         var url = (req.protocol + '://' + req.get('host') + req.originalUrl); | ||||||
|                         proxyRes.headers['location'] = url.replace(/\??ckattempt\=\d+/, ''); |                         proxyRes.headers['location'] = url.replace(/\??ckattempt\=\d+/, ''); | ||||||
| 			proxyRes.statusCode == 307 |                         proxyRes.statusCode = 307; | ||||||
|  |  | ||||||
|                         return res.end() |                         return res.end() | ||||||
|                 } |                 } | ||||||
| @ -74,6 +80,7 @@ router.all("/*", proxy({ | |||||||
|                 }); |                 }); | ||||||
|  |  | ||||||
|                 proxyRes.on('end', function(){ |                 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'] === 'gzip' ? zlib.gunzipSync(body).toString('utf8') : body; | ||||||
|                         body = proxyRes.headers['content-encoding'] === 'br' ? zlib.brotliDecompressSync(body).toString('utf8') : body; |                         body = proxyRes.headers['content-encoding'] === 'br' ? zlib.brotliDecompressSync(body).toString('utf8') : body; | ||||||
|                         if(proxyRes.statusCode === 200 && |                         if(proxyRes.statusCode === 200 && | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user