mirror of
https://github.com/Lissy93/web-check.git
synced 2024-11-25 17:53:19 +01:00
24 lines
554 B
JavaScript
24 lines
554 B
JavaScript
const dns = require('dns');
|
|
const middleware = require('./_common/middleware');
|
|
|
|
const lookupAsync = (address) => {
|
|
return new Promise((resolve, reject) => {
|
|
dns.lookup(address, (err, ip, family) => {
|
|
if (err) {
|
|
reject(err);
|
|
} else {
|
|
resolve({ ip, family });
|
|
}
|
|
});
|
|
});
|
|
};
|
|
|
|
const handler = async (url) => {
|
|
const address = url.replaceAll('https://', '').replaceAll('http://', '');
|
|
return await lookupAsync(address);
|
|
};
|
|
|
|
|
|
module.exports = middleware(handler);
|
|
module.exports.handler = middleware(handler);
|