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