mirror of
https://github.com/Lissy93/web-check.git
synced 2024-11-22 16:23:56 +01:00
Removes logs, updates traceroute return types
This commit is contained in:
parent
733f86c5e8
commit
b8705ee48e
@ -6,27 +6,21 @@ const PORTS = [21, 22, 25, 80, 110, 143, 443, 587, 993, 995, 3306, 3389, 5900, 8
|
||||
async function checkPort(port, domain) {
|
||||
return new Promise(resolve => {
|
||||
const socket = new net.Socket();
|
||||
console.log(port, 'Init');
|
||||
|
||||
socket.setTimeout(1500); // you may want to adjust the timeout
|
||||
|
||||
socket.once('connect', () => {
|
||||
console.log(port, 'Connected!');
|
||||
socket.destroy();
|
||||
resolve(port);
|
||||
});
|
||||
|
||||
socket.once('timeout', () => {
|
||||
console.log(port, 'Timedout');
|
||||
socket.destroy();
|
||||
});
|
||||
|
||||
socket.once('error', (e) => {
|
||||
console.log(port, 'Errored', e);
|
||||
socket.destroy();
|
||||
});
|
||||
|
||||
console.log(port, 'End');
|
||||
socket.connect(port, domain);
|
||||
});
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ const traceroutePromise = util.promisify(traceroute.trace);
|
||||
|
||||
exports.handler = async function(event, context) {
|
||||
const urlString = event.queryStringParameters.url;
|
||||
const startTime = Date.now();
|
||||
|
||||
try {
|
||||
if (!urlString) {
|
||||
@ -22,9 +23,10 @@ exports.handler = async function(event, context) {
|
||||
}
|
||||
|
||||
const result = await traceroutePromise(host);
|
||||
const timeTaken = Date.now() - startTime;
|
||||
return {
|
||||
statusCode: 200,
|
||||
body: JSON.stringify({ message: "Traceroute completed!", result }),
|
||||
body: JSON.stringify({ message: "Traceroute completed!", result, timeTaken }),
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user