feat: whois timeout
This commit is contained in:
@@ -129,7 +129,7 @@ watch(i18n.locale, newDomain);
|
|||||||
{{ $t("button.new_domain") }}
|
{{ $t("button.new_domain") }}
|
||||||
</button>
|
</button>
|
||||||
<br />
|
<br />
|
||||||
<p v-if="domain && state === State.Ready">
|
<p v-if="domain">
|
||||||
<small
|
<small
|
||||||
><a class="underline" href="#" @click.prevent="removeExt">{{
|
><a class="underline" href="#" @click.prevent="removeExt">{{
|
||||||
$t("page_random.dont_suggest", { ext: `.${domain.extension}` })
|
$t("page_random.dont_suggest", { ext: `.${domain.extension}` })
|
||||||
|
|||||||
+5
-13
@@ -1,10 +1,4 @@
|
|||||||
import type {
|
import type { WhoIsResponse, WhoIsData, WhoIsEvent, WhoIsIpAddresses, Domain } from "@/types";
|
||||||
WhoIsResponse,
|
|
||||||
WhoIsData,
|
|
||||||
WhoIsEvent,
|
|
||||||
WhoIsIpAddresses,
|
|
||||||
Domain,
|
|
||||||
} from "@/types";
|
|
||||||
|
|
||||||
function checkEvents(events: WhoIsEvent[]): boolean {
|
function checkEvents(events: WhoIsEvent[]): boolean {
|
||||||
for (const event of events) {
|
for (const event of events) {
|
||||||
@@ -21,18 +15,16 @@ function checkIpAddresses(ipAddresses: WhoIsIpAddresses): boolean {
|
|||||||
|
|
||||||
function checkWhoIsData(data: WhoIsData): boolean {
|
function checkWhoIsData(data: WhoIsData): boolean {
|
||||||
return (
|
return (
|
||||||
checkEvents(data.events) &&
|
checkEvents(data.events) && checkIpAddresses(data.ipAddresses) && data.nameservers.length === 0
|
||||||
checkIpAddresses(data.ipAddresses) &&
|
|
||||||
data.nameservers.length === 0
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function isDomainAvailable(domain: Domain): Promise<boolean> {
|
export async function isDomainAvailable(domain: Domain): Promise<boolean> {
|
||||||
domain.searching = true;
|
domain.searching = true;
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(`https://whois.klemek.fr/api/lookup/${domain.name}`, {
|
||||||
`https://whois.klemek.fr/api/lookup/${domain.name}`,
|
signal: AbortSignal.timeout(5000),
|
||||||
);
|
});
|
||||||
const content: WhoIsResponse = await response.json();
|
const content: WhoIsResponse = await response.json();
|
||||||
domain.available = checkWhoIsData(content.data);
|
domain.available = checkWhoIsData(content.data);
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user