Compare commits
No commits in common. "master" and "sql" have entirely different histories.
@ -11,6 +11,10 @@ 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];
|
||||
@ -27,10 +31,6 @@ 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,10 +49,6 @@ 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, {
|
||||
@ -90,11 +86,7 @@ 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);
|
||||
|
||||
const client = new Client({
|
||||
url: conf.url,
|
||||
});
|
||||
if(userLUR.get(filter)) return userLUR.get(filter)
|
||||
|
||||
await client.bind(conf.bindDN, conf.bindPassword);
|
||||
const res = await client.search(conf.userBase, {
|
||||
@ -139,10 +131,6 @@ 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();
|
||||
|
@ -22,12 +22,7 @@ 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) {
|
||||
@ -43,13 +38,12 @@ function generateRegexForDomain(domain) {
|
||||
router.all("/*", proxy({
|
||||
target: proxyTarget.target,
|
||||
agent: proxyTarget.target.startsWith('https') ? https.globalAgent : http.globalAgent,
|
||||
secure: true,
|
||||
secure: false,
|
||||
autoRewrite: true,
|
||||
changeOrigin: true,
|
||||
followRedirects: true,
|
||||
headers: {
|
||||
host: proxyTarget.host,
|
||||
'Accept-Encoding': 'gzip',
|
||||
host: proxyTarget.host
|
||||
},
|
||||
selfHandleResponse: true, // so that the onProxyRes takes care of sending the response
|
||||
onProxyRes: function(proxyRes, req, res){
|
||||
@ -60,7 +54,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()
|
||||
}
|
||||
@ -80,7 +74,6 @@ 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 &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user