|
|
@ -84,8 +84,8 @@ wss.on('connection', ws => {
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
let xhr = new XMLHttpRequest();
|
|
|
|
let xhr = new XMLHttpRequest();
|
|
|
|
console.log(msg[1])
|
|
|
|
console.log(msg[1])
|
|
|
|
|
|
|
|
xhr.timeout = 1000;
|
|
|
|
xhr.open('GET', msg[1], true);
|
|
|
|
xhr.open('GET', msg[1], true);
|
|
|
|
xhr.timeout = 2000;
|
|
|
|
|
|
|
|
xhr.ontimeout = function(e) {ws.send('error;url timed out')}
|
|
|
|
xhr.ontimeout = function(e) {ws.send('error;url timed out')}
|
|
|
|
xhr.onreadystatechange = function() {
|
|
|
|
xhr.onreadystatechange = function() {
|
|
|
|
if (xhr.readyState === 4) {
|
|
|
|
if (xhr.readyState === 4) {
|
|
|
@ -124,6 +124,10 @@ function get_key(length) {
|
|
|
|
for (let i = 0; i < length; i++ )
|
|
|
|
for (let i = 0; i < length; i++ )
|
|
|
|
output += characters.charAt(Math.floor(Math.random() * characters.length))
|
|
|
|
output += characters.charAt(Math.floor(Math.random() * characters.length))
|
|
|
|
for (let i = 0; i < forbidden_array.length; i++) if (output === forbidden_array[i]) forbidden = true
|
|
|
|
for (let i = 0; i < forbidden_array.length; i++) if (output === forbidden_array[i]) forbidden = true
|
|
|
|
|
|
|
|
redis_cli.hget("surl;"+output, "url", function(err, obj) {
|
|
|
|
|
|
|
|
if(err) console.log(err)
|
|
|
|
|
|
|
|
if(obj) forbidden = true
|
|
|
|
|
|
|
|
})
|
|
|
|
} while (forbidden)
|
|
|
|
} while (forbidden)
|
|
|
|
return output
|
|
|
|
return output
|
|
|
|
}
|
|
|
|
}
|
|
|
|