Skip to content

Commit

Permalink
Merge pull request #158 from jason5ng32/dev
Browse files Browse the repository at this point in the history
Add DNS Resolver
  • Loading branch information
jason5ng32 authored Apr 9, 2024
2 parents c9366f5 + a5c2e27 commit 3650d00
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions api/dnsresolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,18 @@ const dnsResolver = async (req, res) => {

const { hostname } = req.query;

if (typeof hostname !== 'string') {
return res.status(400).send({ error: 'Hostname parameter must be a string' });
}

if (!hostname) {
return res.status(400).send({ error: 'Missing hostname parameter' });
}

if (!hostname.includes('.')) {
return res.status(400).send({ error: 'Invalid hostname' });
}

const dnsPromises = Object.entries(dnsServers).map(([name, ip]) => resolveDns(hostname, name, ip));
const dohPromises = Object.entries(dohServers).map(([name, url]) => resolveDoh(hostname, name, url));

Expand Down
9 changes: 9 additions & 0 deletions src/components/empty.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<template>
<div></div>
</template>

<script>
export default {
name: 'EmptyComponent',
};
</script>
2 changes: 1 addition & 1 deletion src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"Note": "在一些地区,某些运营商可能会因为政治原因或者商业原因,对一些域名进行污染,以至于直接进行访问的时候,无法返回正确的结果。使用 DNS 解析检查,将帮助你从全球各个知名的 DNS 厂商里检查域名的解析结果。在检测内置的 DNS 中,有一部分服务商来自中国,其 DNS 解析的结果可能会受到污染。请注意鉴别。",
"Note2": "请输入 URL 或域名,开始进行解析:",
"Placeholder": "URL 或域名",
"Run": "运行",
"Run": "解析",
"invalidURL": "无效的 URL 或域名",
"fetchError": "无法获取解析结果",
"Provider": "DNS 服务商",
Expand Down
2 changes: 2 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ const MTRTest = () => import('../components/mtrtest.vue');
const PingTest = () => import('../components/globallatency.vue');
const RuleTest = () => import('../components/ruletest.vue');
const DNSResolver = () => import('../components/dnsresolver.vue');
const EmptyComponent = () => import('../components/empty.vue');

const routes = [
{ path: '/', component: EmptyComponent },
{ path: '/mtrtest', component: MTRTest },
{ path: '/pingtest', component: PingTest },
{ path: '/ruletest', component: RuleTest },
Expand Down

0 comments on commit 3650d00

Please sign in to comment.