mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
feat: useNetworkUtilsConfig and basic auth for all tools requiring external docker services
This commit is contained in:
1 parent
b1d3849f87
commit
65955d9b33
12 files changed
+2602
-2126
No files matched your search
+1952
-1822
File diff suppressed because it is too large.
Load diff
@@ -6,7 +6,6 @@ import { useNetworkUtilsConfig } from '@/tools/network-utils/network-utils-confi
|
||||
import { Base64 } from 'js-base64';
|
||||
|
||||
const { serverHost, serverAuth, hasFixedConfig } = useNetworkUtilsConfig({
|
||||
toolKey: 'dns-prop',
|
||||
urlStorageKey: 'dns-prop:url',
|
||||
authStorageKey: 'dns-prop:auth',
|
||||
});
|
||||
@@ -19,13 +18,15 @@ async function api(path: string, params: Record<string, string | number | boolea
|
||||
|
||||
const url = `${serverHost.value}${path}?${pathParams.toString()}`;
|
||||
|
||||
const response = await fetch(url,
|
||||
const response = await fetch(
|
||||
url,
|
||||
serverAuth.value
|
||||
? {
|
||||
method: 'GET',
|
||||
headers: { Authorization: `Basic ${Base64.encode(serverAuth.value)}` },
|
||||
}
|
||||
: undefined);
|
||||
: undefined,
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
const text = await response.text();
|
||||
@@ -84,15 +85,12 @@ const builtinResolvers = [
|
||||
];
|
||||
|
||||
interface Resolver {
|
||||
ip: string
|
||||
name: string
|
||||
ip: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
const customResolvers = useITStorage<Resolver[]>('dns-prop:cust', []);
|
||||
const resolvers = computed(() => [
|
||||
...builtinResolvers,
|
||||
...customResolvers.value,
|
||||
]);
|
||||
const resolvers = computed(() => [...builtinResolvers, ...customResolvers.value]);
|
||||
|
||||
const propDomain = useQueryParamOrStorage({ name: 'domain', storageName: 'dns-prop:d', defaultValue: '' });
|
||||
const propType = useQueryParamOrStorage({ name: 'type', storageName: 'dns-prop:t', defaultValue: 'A' });
|
||||
@@ -100,11 +98,11 @@ const propType = useQueryParamOrStorage({ name: 'type', storageName: 'dns-prop:t
|
||||
const selectedResolvers = ref<string[]>([]);
|
||||
|
||||
interface DNSQueryResult {
|
||||
ok: boolean
|
||||
domain: string
|
||||
record_type: string
|
||||
answers?: string[] | null
|
||||
error?: string | null
|
||||
ok: boolean;
|
||||
domain: string;
|
||||
record_type: string;
|
||||
answers?: string[] | null;
|
||||
error?: string | null;
|
||||
}
|
||||
type Result = Record<string, { status: 'checking' | 'success' | 'error'; result?: DNSQueryResult }>;
|
||||
const propResults = reactive<Result>({});
|
||||
@@ -129,7 +127,7 @@ function addCustomResolver() {
|
||||
}
|
||||
|
||||
function removeCustomResolver(ip: string) {
|
||||
customResolvers.value = customResolvers.value.filter(r => r.ip !== ip);
|
||||
customResolvers.value = customResolvers.value.filter((r) => r.ip !== ip);
|
||||
}
|
||||
|
||||
async function runPropagation() {
|
||||
@@ -145,30 +143,31 @@ async function runPropagation() {
|
||||
|
||||
const allPromises: Promise<void>[] = [];
|
||||
for (const ip of selectedResolvers.value) {
|
||||
allPromises.push((async () => {
|
||||
try {
|
||||
const dnsResult = await api('/dns-query', {
|
||||
domain: propDomain.value,
|
||||
record_type: propType.value,
|
||||
resolver_ip: ip,
|
||||
});
|
||||
propResults[ip] = {
|
||||
status: dnsResult.ok ? 'success' : 'error',
|
||||
result: dnsResult,
|
||||
};
|
||||
}
|
||||
catch (err: any) {
|
||||
propResults[ip] = {
|
||||
status: 'error',
|
||||
result: {
|
||||
ok: false,
|
||||
allPromises.push(
|
||||
(async () => {
|
||||
try {
|
||||
const dnsResult = await api('/dns-query', {
|
||||
domain: propDomain.value,
|
||||
record_type: propType.value,
|
||||
error: err.toString(),
|
||||
},
|
||||
};
|
||||
}
|
||||
})());
|
||||
resolver_ip: ip,
|
||||
});
|
||||
propResults[ip] = {
|
||||
status: dnsResult.ok ? 'success' : 'error',
|
||||
result: dnsResult,
|
||||
};
|
||||
} catch (err: any) {
|
||||
propResults[ip] = {
|
||||
status: 'error',
|
||||
result: {
|
||||
ok: false,
|
||||
domain: propDomain.value,
|
||||
record_type: propType.value,
|
||||
error: err.toString(),
|
||||
},
|
||||
};
|
||||
}
|
||||
})(),
|
||||
);
|
||||
}
|
||||
Promise.all(allPromises).then(() => {
|
||||
loading.value = false;
|
||||
@@ -179,15 +178,34 @@ async function runPropagation() {
|
||||
<template>
|
||||
<div>
|
||||
<details v-if="!hasFixedConfig" mb-2>
|
||||
<summary>{{ t('tools.dns-propagation-tester.texts.tag-network-utilities-service-configuration-self-hosted') }}</summary>
|
||||
<summary>
|
||||
{{ t('tools.dns-propagation-tester.texts.tag-network-utilities-service-configuration-self-hosted') }}
|
||||
</summary>
|
||||
<n-card>
|
||||
<NFormItem :label="t('tools.dns-propagation-tester.texts.label-network-utilities-service-url')" label-placement="top">
|
||||
<NInput v-model:value="serverHost" :placeholder="t('tools.dns-propagation-tester.texts.placeholder-http-localhost-3000')" />
|
||||
<NFormItem
|
||||
:label="t('tools.dns-propagation-tester.texts.label-network-utilities-service-url')"
|
||||
label-placement="top"
|
||||
>
|
||||
<NInput
|
||||
v-model:value="serverHost"
|
||||
:placeholder="t('tools.dns-propagation-tester.texts.placeholder-http-localhost-3000')"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem :label="t('tools.dns-propagation-tester.texts.label-basic-authentication')" label-placement="left" label-width="auto">
|
||||
<NInput v-model:value="serverAuth" :placeholder="t('tools.dns-propagation-tester.texts.placeholder-username-password')" />
|
||||
<NFormItem
|
||||
:label="t('tools.dns-propagation-tester.texts.label-basic-authentication')"
|
||||
label-placement="left"
|
||||
label-width="auto"
|
||||
>
|
||||
<NInput
|
||||
v-model:value="serverAuth"
|
||||
:placeholder="t('tools.dns-propagation-tester.texts.placeholder-username-password')"
|
||||
/>
|
||||
</NFormItem>
|
||||
<n-p>{{ t('tools.dns-propagation-tester.texts.tag-you-must-self-host-network-utilities-service-see') }}<c-link href="https://github.com/sharevb/network-utils-ws#running-in-docker" target="_blank">{{ t('tools.dns-propagation-tester.texts.tag-network-utilities-service-docker-install') }}</c-link>
|
||||
<n-p
|
||||
>{{ t('tools.dns-propagation-tester.texts.tag-you-must-self-host-network-utilities-service-see')
|
||||
}}<c-link href="https://github.com/sharevb/network-utils-ws#running-in-docker" target="_blank">{{
|
||||
t('tools.dns-propagation-tester.texts.tag-network-utilities-service-docker-install')
|
||||
}}</c-link>
|
||||
</n-p>
|
||||
</n-card>
|
||||
</details>
|
||||
@@ -195,26 +213,38 @@ async function runPropagation() {
|
||||
<n-tabs type="line" animated>
|
||||
<n-tab-pane name="propagation" :tab="t('tools.dns-propagation-tester.texts.tab-dns-propagation')">
|
||||
<n-form>
|
||||
<c-input-text v-model:value="propDomain" :label="t('tools.dns-propagation-tester.texts.label-domain')" label-position="left" :placeholder="t('tools.dns-propagation-tester.texts.placeholder-example-com')" mb-1 />
|
||||
<c-input-text
|
||||
v-model:value="propDomain"
|
||||
:label="t('tools.dns-propagation-tester.texts.label-domain')"
|
||||
label-position="left"
|
||||
:placeholder="t('tools.dns-propagation-tester.texts.placeholder-example-com')"
|
||||
mb-1
|
||||
/>
|
||||
<c-select
|
||||
v-model:value="propType" :label="t('tools.dns-propagation-tester.texts.label-record-type')"
|
||||
v-model:value="propType"
|
||||
:label="t('tools.dns-propagation-tester.texts.label-record-type')"
|
||||
mb-1
|
||||
label-position="left"
|
||||
:options="['A', 'AAAA', 'CNAME', 'MX', 'NS', 'TXT', 'SRV', 'SOA', 'CAA', 'DS', 'DNSKEY'].map(x => ({ label: x, value: x }))"
|
||||
:options="
|
||||
['A', 'AAAA', 'CNAME', 'MX', 'NS', 'TXT', 'SRV', 'SOA', 'CAA', 'DS', 'DNSKEY'].map((x) => ({
|
||||
label: x,
|
||||
value: x,
|
||||
}))
|
||||
"
|
||||
/>
|
||||
|
||||
<n-card :title="t('tools.dns-propagation-tester.texts.title-resolvers-to-check')" mb-2>
|
||||
<n-space justify="center" mb-1 gap-1>
|
||||
<n-button size="tiny" @click="selectedResolvers = resolvers.map(r => r.ip)">{{ t('tools.dns-propagation-tester.texts.tag-select-all') }}</n-button>
|
||||
<n-button size="tiny" @click="selectedResolvers = []">{{ t('tools.dns-propagation-tester.texts.tag-deselect-all') }}</n-button>
|
||||
<n-button size="tiny" @click="selectedResolvers = resolvers.map((r) => r.ip)">{{
|
||||
t('tools.dns-propagation-tester.texts.tag-select-all')
|
||||
}}</n-button>
|
||||
<n-button size="tiny" @click="selectedResolvers = []">{{
|
||||
t('tools.dns-propagation-tester.texts.tag-deselect-all')
|
||||
}}</n-button>
|
||||
</n-space>
|
||||
<n-checkbox-group v-model:value="selectedResolvers">
|
||||
<n-space wrap>
|
||||
<n-checkbox
|
||||
v-for="r in resolvers"
|
||||
:key="r.ip"
|
||||
:value="r.ip"
|
||||
>
|
||||
<n-checkbox v-for="r in resolvers" :key="r.ip" :value="r.ip">
|
||||
{{ r.name }} <em>({{ r.ip }})</em>
|
||||
</n-checkbox>
|
||||
</n-space>
|
||||
@@ -222,7 +252,13 @@ async function runPropagation() {
|
||||
</n-card>
|
||||
|
||||
<n-space justify="center" mb-1>
|
||||
<n-button type="primary" :disabled="!propDomain || !propType || !selectedResolvers.length || loading" :loading="loading" @click="runPropagation">{{ t('tools.dns-propagation-tester.texts.tag-check-propagation') }}</n-button>
|
||||
<n-button
|
||||
type="primary"
|
||||
:disabled="!propDomain || !propType || !selectedResolvers.length || loading"
|
||||
:loading="loading"
|
||||
@click="runPropagation"
|
||||
>{{ t('tools.dns-propagation-tester.texts.tag-check-propagation') }}</n-button
|
||||
>
|
||||
</n-space>
|
||||
</n-form>
|
||||
|
||||
@@ -238,7 +274,7 @@ async function runPropagation() {
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(res, ip) in propResults" :key="ip">
|
||||
<td>{{ resolvers.find(r => r.ip === ip)?.name || ip }}</td>
|
||||
<td>{{ resolvers.find((r) => r.ip === ip)?.name || ip }}</td>
|
||||
<td>{{ ip }}</td>
|
||||
<td>
|
||||
<n-tag :type="res.status === 'success' ? 'success' : res.status === 'error' ? 'error' : 'default'">
|
||||
@@ -246,10 +282,12 @@ async function runPropagation() {
|
||||
</n-tag>
|
||||
</td>
|
||||
<td>
|
||||
<div v-if="res.result?.error" style="color: red;">
|
||||
<div v-if="res.result?.error" style="color: red">
|
||||
{{ res.result.error }}
|
||||
</div>
|
||||
<div v-else-if="res.status === 'checking'">{{ t('tools.dns-propagation-tester.texts.tag-checking') }}</div>
|
||||
<div v-else-if="res.status === 'checking'">
|
||||
{{ t('tools.dns-propagation-tester.texts.tag-checking') }}
|
||||
</div>
|
||||
<ul v-else-if="res.result?.answers">
|
||||
<li v-for="(a, idx) in res.result.answers" :key="idx">
|
||||
{{ a }}
|
||||
@@ -265,22 +303,40 @@ async function runPropagation() {
|
||||
|
||||
<n-tab-pane name="custom-resolvers" :tab="t('tools.dns-propagation-tester.texts.tab-custom-resolvers')">
|
||||
<n-card :title="t('tools.dns-propagation-tester.texts.title-add-custom-resolver')">
|
||||
<c-input-text v-model:value="newResolverName" :label="t('tools.dns-propagation-tester.texts.label-resolver-name')" label-width="120px" label-position="left" :placeholder="t('tools.dns-propagation-tester.texts.placeholder-resolver-name-e-g-my-dns')" mb-1 />
|
||||
<c-input-text v-model:value="newResolverIp" :label="t('tools.dns-propagation-tester.texts.label-resolver-ip')" label-width="120px" label-position="left" :placeholder="t('tools.dns-propagation-tester.texts.placeholder-resolver-ip-e-g-10-0-0-1')" mb-1 />
|
||||
<c-input-text
|
||||
v-model:value="newResolverName"
|
||||
:label="t('tools.dns-propagation-tester.texts.label-resolver-name')"
|
||||
label-width="120px"
|
||||
label-position="left"
|
||||
:placeholder="t('tools.dns-propagation-tester.texts.placeholder-resolver-name-e-g-my-dns')"
|
||||
mb-1
|
||||
/>
|
||||
<c-input-text
|
||||
v-model:value="newResolverIp"
|
||||
:label="t('tools.dns-propagation-tester.texts.label-resolver-ip')"
|
||||
label-width="120px"
|
||||
label-position="left"
|
||||
:placeholder="t('tools.dns-propagation-tester.texts.placeholder-resolver-ip-e-g-10-0-0-1')"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<n-space justify="center" mb-1>
|
||||
<n-button type="primary" @click="addCustomResolver">{{ t('tools.dns-propagation-tester.texts.tag-add-resolver') }}</n-button>
|
||||
<n-button type="primary" @click="addCustomResolver">{{
|
||||
t('tools.dns-propagation-tester.texts.tag-add-resolver')
|
||||
}}</n-button>
|
||||
</n-space>
|
||||
</n-card>
|
||||
|
||||
<n-card v-if="customResolvers.length" :title="t('tools.dns-propagation-tester.texts.title-your-custom-resolvers')">
|
||||
<div
|
||||
v-for="r in customResolvers"
|
||||
:key="r.ip"
|
||||
>
|
||||
<div style="display:flex; justify-content:space-between; align-items:center;">
|
||||
<n-card
|
||||
v-if="customResolvers.length"
|
||||
:title="t('tools.dns-propagation-tester.texts.title-your-custom-resolvers')"
|
||||
>
|
||||
<div v-for="r in customResolvers" :key="r.ip">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center">
|
||||
<div>{{ r.name }} — {{ r.ip }}</div>
|
||||
<n-button type="error" size="tiny" @click="removeCustomResolver(r.ip)">{{ t('tools.dns-propagation-tester.texts.tag-remove') }}</n-button>
|
||||
<n-button type="error" size="tiny" @click="removeCustomResolver(r.ip)">{{
|
||||
t('tools.dns-propagation-tester.texts.tag-remove')
|
||||
}}</n-button>
|
||||
</div>
|
||||
</div>
|
||||
</n-card>
|
||||
|
||||
@@ -6,7 +6,6 @@ import { Base64 } from 'js-base64';
|
||||
import { isIP } from 'is-ip';
|
||||
|
||||
const { serverHost, serverAuth, hasFixedConfig } = useNetworkUtilsConfig({
|
||||
toolKey: 'dns-tester',
|
||||
urlStorageKey: 'dns-tester:url',
|
||||
authStorageKey: 'dns-tester:auth',
|
||||
});
|
||||
@@ -24,13 +23,15 @@ async function api(path: string, params: Record<string, string | number | boolea
|
||||
|
||||
const url = `${serverHost.value}${path}?${pathParams.toString()}`;
|
||||
|
||||
const response = await fetch(url,
|
||||
const response = await fetch(
|
||||
url,
|
||||
serverAuth.value
|
||||
? {
|
||||
method: 'GET',
|
||||
headers: { Authorization: `Basic ${Base64.encode(serverAuth.value)}` },
|
||||
}
|
||||
: undefined);
|
||||
: undefined,
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
const text = await response.text();
|
||||
@@ -38,11 +39,9 @@ async function api(path: string, params: Record<string, string | number | boolea
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
}
|
||||
catch (err: any) {
|
||||
} catch (err: any) {
|
||||
error.value = err.toString();
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
@@ -50,51 +49,50 @@ async function api(path: string, params: Record<string, string | number | boolea
|
||||
type AnyDict = Record<string, any>;
|
||||
|
||||
interface DNSQueryResult {
|
||||
ok: boolean
|
||||
domain: string
|
||||
record_type: string
|
||||
answers?: string[] | null
|
||||
error?: string | null
|
||||
ok: boolean;
|
||||
domain: string;
|
||||
record_type: string;
|
||||
answers?: string[] | null;
|
||||
error?: string | null;
|
||||
}
|
||||
|
||||
interface WhoisResult {
|
||||
ok: boolean
|
||||
domain: string
|
||||
raw?: string | null
|
||||
parsed?: AnyDict | null
|
||||
error?: string | null
|
||||
ok: boolean;
|
||||
domain: string;
|
||||
raw?: string | null;
|
||||
parsed?: AnyDict | null;
|
||||
error?: string | null;
|
||||
}
|
||||
|
||||
interface DNSSECResult {
|
||||
ok: boolean
|
||||
domain: string
|
||||
validated: boolean
|
||||
dnskey?: string | null
|
||||
rrsig?: string | null
|
||||
error?: string | null
|
||||
ok: boolean;
|
||||
domain: string;
|
||||
validated: boolean;
|
||||
dnskey?: string | null;
|
||||
rrsig?: string | null;
|
||||
error?: string | null;
|
||||
}
|
||||
|
||||
interface ReverseDNSResult {
|
||||
ok: boolean
|
||||
ip: string
|
||||
ptr?: string | null
|
||||
error?: string | null
|
||||
ok: boolean;
|
||||
ip: string;
|
||||
ptr?: string | null;
|
||||
error?: string | null;
|
||||
}
|
||||
|
||||
interface AXFRResult {
|
||||
ok: boolean
|
||||
domain: string
|
||||
soa?: string | null
|
||||
axfr_allowed: boolean
|
||||
records?: string[] | null
|
||||
error?: string | null
|
||||
ok: boolean;
|
||||
domain: string;
|
||||
soa?: string | null;
|
||||
axfr_allowed: boolean;
|
||||
records?: string[] | null;
|
||||
error?: string | null;
|
||||
}
|
||||
|
||||
function prettyJSON(value: unknown): string {
|
||||
try {
|
||||
return JSON.stringify(value, null, 2);
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
return String(value);
|
||||
}
|
||||
}
|
||||
@@ -192,7 +190,9 @@ const resolverOptions = [
|
||||
|
||||
const resolverIP = ref('');
|
||||
const customResolverIP = ref('');
|
||||
const effectiveResolverIP = computed(() => resolverIP.value === '__custom__' ? customResolverIP.value.trim() : resolverIP.value);
|
||||
const effectiveResolverIP = computed(() =>
|
||||
resolverIP.value === '__custom__' ? customResolverIP.value.trim() : resolverIP.value,
|
||||
);
|
||||
const customResolverIpError = computed(() => {
|
||||
if (resolverIP.value !== '__custom__' || !customResolverIP.value.trim()) {
|
||||
return '';
|
||||
@@ -200,7 +200,9 @@ const customResolverIpError = computed(() => {
|
||||
|
||||
return isIP(customResolverIP.value.trim()) ? '' : 'Please enter a valid IPv4 or IPv6 address.';
|
||||
});
|
||||
const canRunWithSelectedResolver = computed(() => resolverIP.value !== '__custom__' || customResolverIpError.value === '');
|
||||
const canRunWithSelectedResolver = computed(
|
||||
() => resolverIP.value !== '__custom__' || customResolverIpError.value === '',
|
||||
);
|
||||
|
||||
const dnsDomain = ref('');
|
||||
const dnsType = ref('A');
|
||||
@@ -258,23 +260,34 @@ const labelProps = {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="min-height: 80vh;">
|
||||
<div style="min-height: 80vh">
|
||||
<details v-if="!hasFixedConfig" mb-2>
|
||||
<summary>{{ t('tools.dns-tester.texts.tag-network-utilities-service-configuration-self-hosted') }}</summary>
|
||||
<n-card>
|
||||
<NFormItem :label="t('tools.dns-tester.texts.label-network-utilities-service-url')" label-placement="top">
|
||||
<NInput v-model:value="serverHost" :placeholder="t('tools.dns-tester.texts.placeholder-http-localhost-3000')" />
|
||||
<NInput
|
||||
v-model:value="serverHost"
|
||||
:placeholder="t('tools.dns-tester.texts.placeholder-http-localhost-3000')"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem :label="t('tools.dns-tester.texts.label-basic-authentication')" label-placement="left" label-width="auto">
|
||||
<NFormItem
|
||||
:label="t('tools.dns-tester.texts.label-basic-authentication')"
|
||||
label-placement="left"
|
||||
label-width="auto"
|
||||
>
|
||||
<NInput v-model:value="serverAuth" :placeholder="t('tools.dns-tester.texts.placeholder-username-password')" />
|
||||
</NFormItem>
|
||||
<n-p>{{ t('tools.dns-tester.texts.tag-you-must-self-host-network-utilities-service-see') }}<c-link href="https://github.com/sharevb/network-utils-ws#running-in-docker" target="_blank">{{ t('tools.dns-tester.texts.tag-network-utilities-service-docker-install') }}</c-link>
|
||||
<n-p
|
||||
>{{ t('tools.dns-tester.texts.tag-you-must-self-host-network-utilities-service-see')
|
||||
}}<c-link href="https://github.com/sharevb/network-utils-ws#running-in-docker" target="_blank">{{
|
||||
t('tools.dns-tester.texts.tag-network-utilities-service-docker-install')
|
||||
}}</c-link>
|
||||
</n-p>
|
||||
</n-card>
|
||||
</details>
|
||||
|
||||
<NFormItem :label="t('tools.dns-tester.texts.label-target-dns-resolver-ip')" label-placement="left">
|
||||
<div style="width: 100%;">
|
||||
<div style="width: 100%">
|
||||
<NSelect
|
||||
v-model:value="resolverIP"
|
||||
:options="resolverOptions"
|
||||
@@ -288,7 +301,7 @@ const labelProps = {
|
||||
v-model:value="customResolverIP"
|
||||
:placeholder="t('tools.dns-tester.texts.placeholder-e-g-10-0-0-53')"
|
||||
/>
|
||||
<div v-if="customResolverIpError" style="margin-top: 6px; color: var(--n-error-color); font-size: 12px;">
|
||||
<div v-if="customResolverIpError" style="margin-top: 6px; color: var(--n-error-color); font-size: 12px">
|
||||
{{ customResolverIpError }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -296,8 +309,14 @@ const labelProps = {
|
||||
|
||||
<n-tabs type="line" animated>
|
||||
<!-- DNS QUERY -->
|
||||
<n-tab-pane name="dns" :tab="t('tools.dns-tester.texts.tab-dns-query')" style="min-height: 80vh;">
|
||||
<c-input-text v-model:value="dnsDomain" :label="t('tools.dns-tester.texts.label-domain')" v-bind="labelProps" :placeholder="t('tools.dns-tester.texts.placeholder-example-com')" mb-1 />
|
||||
<n-tab-pane name="dns" :tab="t('tools.dns-tester.texts.tab-dns-query')" style="min-height: 80vh">
|
||||
<c-input-text
|
||||
v-model:value="dnsDomain"
|
||||
:label="t('tools.dns-tester.texts.label-domain')"
|
||||
v-bind="labelProps"
|
||||
:placeholder="t('tools.dns-tester.texts.placeholder-example-com')"
|
||||
mb-1
|
||||
/>
|
||||
<c-select
|
||||
v-model:value="dnsType"
|
||||
:label="t('tools.dns-tester.texts.label-dns-record-type')"
|
||||
@@ -306,7 +325,9 @@ const labelProps = {
|
||||
mb-1
|
||||
/>
|
||||
<div mb-2 flex justify-center>
|
||||
<n-button :loading="loading" :disabled="!canRunWithSelectedResolver" @click="runDns">{{ t('tools.dns-tester.texts.tag-query-dns') }}</n-button>
|
||||
<n-button :loading="loading" :disabled="!canRunWithSelectedResolver" @click="runDns">{{
|
||||
t('tools.dns-tester.texts.tag-query-dns')
|
||||
}}</n-button>
|
||||
</div>
|
||||
|
||||
<n-card v-if="dnsResult" :title="t('tools.dns-tester.texts.title-result')">
|
||||
@@ -316,23 +337,24 @@ const labelProps = {
|
||||
</n-tag>
|
||||
</n-space>
|
||||
|
||||
<input-copyable :label="t('tools.dns-tester.texts.label-domain')" v-bind="labelProps" :value="dnsResult.domain" mb-1 />
|
||||
<input-copyable :label="t('tools.dns-tester.texts.label-record-type')" v-bind="labelProps" :value="dnsResult.record_type" mb-1 />
|
||||
<input-copyable
|
||||
:label="t('tools.dns-tester.texts.label-domain')"
|
||||
v-bind="labelProps"
|
||||
:value="dnsResult.domain"
|
||||
mb-1
|
||||
/>
|
||||
<input-copyable
|
||||
:label="t('tools.dns-tester.texts.label-record-type')"
|
||||
v-bind="labelProps"
|
||||
:value="dnsResult.record_type"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<n-card v-if="dnsResult.answers" :title="t('tools.dns-tester.texts.title-answers')" mb-1>
|
||||
<textarea-copyable
|
||||
v-if="dnsResult.answers"
|
||||
:value="dnsResult.answers.join('\n')"
|
||||
mb-1
|
||||
/>
|
||||
<textarea-copyable v-if="dnsResult.answers" :value="dnsResult.answers.join('\n')" mb-1 />
|
||||
</n-card>
|
||||
|
||||
<n-alert
|
||||
v-if="dnsResult.error"
|
||||
type="error"
|
||||
:bordered="false"
|
||||
show-icon
|
||||
>
|
||||
<n-alert v-if="dnsResult.error" type="error" :bordered="false" show-icon>
|
||||
{{ dnsResult.error }}
|
||||
</n-alert>
|
||||
</n-card>
|
||||
@@ -344,9 +366,17 @@ const labelProps = {
|
||||
|
||||
<!-- WHOIS -->
|
||||
<n-tab-pane name="whois" :tab="t('tools.dns-tester.texts.tab-whois')">
|
||||
<c-input-text v-model:value="whoisDomain" :label="t('tools.dns-tester.texts.label-domain')" v-bind="labelProps" :placeholder="t('tools.dns-tester.texts.placeholder-example-com')" mb-1 />
|
||||
<c-input-text
|
||||
v-model:value="whoisDomain"
|
||||
:label="t('tools.dns-tester.texts.label-domain')"
|
||||
v-bind="labelProps"
|
||||
:placeholder="t('tools.dns-tester.texts.placeholder-example-com')"
|
||||
mb-1
|
||||
/>
|
||||
<div mb-2 flex justify-center>
|
||||
<n-button type="primary" :loading="loading" @click="runWhois">{{ t('tools.dns-tester.texts.tag-lookup-whois') }}</n-button>
|
||||
<n-button type="primary" :loading="loading" @click="runWhois">{{
|
||||
t('tools.dns-tester.texts.tag-lookup-whois')
|
||||
}}</n-button>
|
||||
</div>
|
||||
|
||||
<n-card v-if="whoisResult" :title="t('tools.dns-tester.texts.title-result')">
|
||||
@@ -356,7 +386,12 @@ const labelProps = {
|
||||
</n-tag>
|
||||
</n-space>
|
||||
|
||||
<input-copyable :label="t('tools.dns-tester.texts.label-domain')" v-bind="labelProps" :value="whoisResult.domain" mb-1 />
|
||||
<input-copyable
|
||||
:label="t('tools.dns-tester.texts.label-domain')"
|
||||
v-bind="labelProps"
|
||||
:value="whoisResult.domain"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<textarea-copyable
|
||||
v-if="whoisResult.raw"
|
||||
@@ -373,12 +408,7 @@ const labelProps = {
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<n-alert
|
||||
v-if="whoisResult.error"
|
||||
type="error"
|
||||
:bordered="false"
|
||||
show-icon
|
||||
>
|
||||
<n-alert v-if="whoisResult.error" type="error" :bordered="false" show-icon>
|
||||
{{ whoisResult.error }}
|
||||
</n-alert>
|
||||
</n-card>
|
||||
@@ -390,9 +420,17 @@ const labelProps = {
|
||||
|
||||
<!-- DNSSEC -->
|
||||
<n-tab-pane name="dnssec" :tab="t('tools.dns-tester.texts.tab-dnssec-validation')">
|
||||
<c-input-text v-model:value="dnssecDomain" :label="t('tools.dns-tester.texts.label-domain')" v-bind="labelProps" :placeholder="t('tools.dns-tester.texts.placeholder-example-com')" mb-1 />
|
||||
<c-input-text
|
||||
v-model:value="dnssecDomain"
|
||||
:label="t('tools.dns-tester.texts.label-domain')"
|
||||
v-bind="labelProps"
|
||||
:placeholder="t('tools.dns-tester.texts.placeholder-example-com')"
|
||||
mb-1
|
||||
/>
|
||||
<div mb-2 flex justify-center>
|
||||
<n-button type="primary" :loading="loading" :disabled="!canRunWithSelectedResolver" @click="runDnssec">{{ t('tools.dns-tester.texts.tag-validate-dnssec') }}</n-button>
|
||||
<n-button type="primary" :loading="loading" :disabled="!canRunWithSelectedResolver" @click="runDnssec">{{
|
||||
t('tools.dns-tester.texts.tag-validate-dnssec')
|
||||
}}</n-button>
|
||||
</div>
|
||||
|
||||
<n-card v-if="dnssecResult" :title="t('tools.dns-tester.texts.title-result')">
|
||||
@@ -402,7 +440,12 @@ const labelProps = {
|
||||
</n-tag>
|
||||
</n-space>
|
||||
|
||||
<input-copyable :label="t('tools.dns-tester.texts.label-domain')" v-bind="labelProps" :value="dnssecResult.domain" mb-1 />
|
||||
<input-copyable
|
||||
:label="t('tools.dns-tester.texts.label-domain')"
|
||||
v-bind="labelProps"
|
||||
:value="dnssecResult.domain"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable
|
||||
:label="t('tools.dns-tester.texts.label-validated')"
|
||||
@@ -427,12 +470,7 @@ const labelProps = {
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<n-alert
|
||||
v-if="dnssecResult.error"
|
||||
type="error"
|
||||
:bordered="false"
|
||||
show-icon
|
||||
>
|
||||
<n-alert v-if="dnssecResult.error" type="error" :bordered="false" show-icon>
|
||||
{{ dnssecResult.error }}
|
||||
</n-alert>
|
||||
</n-card>
|
||||
@@ -444,9 +482,17 @@ const labelProps = {
|
||||
|
||||
<!-- REVERSE DNS -->
|
||||
<n-tab-pane name="reverse" :tab="t('tools.dns-tester.texts.tab-reverse-dns-ptr')">
|
||||
<c-input-text v-model:value="reverseIp" :label="t('tools.dns-tester.texts.label-ip-address')" v-bind="labelProps" :placeholder="t('tools.dns-tester.texts.placeholder-8-8-8-8')" mb-1 />
|
||||
<c-input-text
|
||||
v-model:value="reverseIp"
|
||||
:label="t('tools.dns-tester.texts.label-ip-address')"
|
||||
v-bind="labelProps"
|
||||
:placeholder="t('tools.dns-tester.texts.placeholder-8-8-8-8')"
|
||||
mb-1
|
||||
/>
|
||||
<div mb-2 flex justify-center>
|
||||
<n-button type="primary" :loading="loading" :disabled="!canRunWithSelectedResolver" @click="runReverse">{{ t('tools.dns-tester.texts.tag-reverse-lookup') }}</n-button>
|
||||
<n-button type="primary" :loading="loading" :disabled="!canRunWithSelectedResolver" @click="runReverse">{{
|
||||
t('tools.dns-tester.texts.tag-reverse-lookup')
|
||||
}}</n-button>
|
||||
</div>
|
||||
|
||||
<n-card v-if="reverseResult" :title="t('tools.dns-tester.texts.title-result')">
|
||||
@@ -456,7 +502,12 @@ const labelProps = {
|
||||
</n-tag>
|
||||
</n-space>
|
||||
|
||||
<input-copyable :label="t('tools.dns-tester.texts.label-ip')" v-bind="labelProps" :value="reverseResult.ip" mb-1 />
|
||||
<input-copyable
|
||||
:label="t('tools.dns-tester.texts.label-ip')"
|
||||
v-bind="labelProps"
|
||||
:value="reverseResult.ip"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable
|
||||
v-if="reverseResult.ptr"
|
||||
@@ -466,12 +517,7 @@ const labelProps = {
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<n-alert
|
||||
v-if="reverseResult.error"
|
||||
type="error"
|
||||
:bordered="false"
|
||||
show-icon
|
||||
>
|
||||
<n-alert v-if="reverseResult.error" type="error" :bordered="false" show-icon>
|
||||
{{ reverseResult.error }}
|
||||
</n-alert>
|
||||
</n-card>
|
||||
@@ -483,9 +529,17 @@ const labelProps = {
|
||||
|
||||
<!-- SOA + AXFR -->
|
||||
<n-tab-pane name="axfr" :tab="t('tools.dns-tester.texts.tab-soa-axfr-test')">
|
||||
<c-input-text v-model:value="axfrDomain" :label="t('tools.dns-tester.texts.label-domain')" v-bind="labelProps" :placeholder="t('tools.dns-tester.texts.placeholder-example-com')" mb-1 />
|
||||
<c-input-text
|
||||
v-model:value="axfrDomain"
|
||||
:label="t('tools.dns-tester.texts.label-domain')"
|
||||
v-bind="labelProps"
|
||||
:placeholder="t('tools.dns-tester.texts.placeholder-example-com')"
|
||||
mb-1
|
||||
/>
|
||||
<div mb-2 flex justify-center>
|
||||
<n-button type="primary" :loading="loading" :disabled="!canRunWithSelectedResolver" @click="runAxfr">{{ t('tools.dns-tester.texts.tag-run-soa-axfr') }}</n-button>
|
||||
<n-button type="primary" :loading="loading" :disabled="!canRunWithSelectedResolver" @click="runAxfr">{{
|
||||
t('tools.dns-tester.texts.tag-run-soa-axfr')
|
||||
}}</n-button>
|
||||
</div>
|
||||
|
||||
<n-card v-if="axfrResult" :title="t('tools.dns-tester.texts.title-result')">
|
||||
@@ -495,7 +549,12 @@ const labelProps = {
|
||||
</n-tag>
|
||||
</n-space>
|
||||
|
||||
<input-copyable :label="t('tools.dns-tester.texts.label-domain')" v-bind="labelProps" :value="axfrResult.domain" mb-1 />
|
||||
<input-copyable
|
||||
:label="t('tools.dns-tester.texts.label-domain')"
|
||||
v-bind="labelProps"
|
||||
:value="axfrResult.domain"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<textarea-copyable
|
||||
v-if="axfrResult.soa"
|
||||
@@ -518,12 +577,7 @@ const labelProps = {
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<n-alert
|
||||
v-if="axfrResult.error"
|
||||
type="error"
|
||||
:bordered="false"
|
||||
show-icon
|
||||
>
|
||||
<n-alert v-if="axfrResult.error" type="error" :bordered="false" show-icon>
|
||||
{{ axfrResult.error }}
|
||||
</n-alert>
|
||||
</n-card>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useITStorage, useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
import { Base64 } from 'js-base64';
|
||||
import { useNetworkUtilsConfig } from '../network-utils/network-utils-config';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -14,8 +15,12 @@ const password = ref('');
|
||||
const image = useQueryParamOrStorage({ name: 'image', storageName: 'docker-dl:i', defaultValue: '' });
|
||||
const platform = useQueryParamOrStorage({ name: 'platform', storageName: 'docker-dl:p', defaultValue: '' });
|
||||
const registry = useQueryParamOrStorage({ name: 'registry', storageName: 'docker-dl:r', defaultValue: '' });
|
||||
const serverHost = useITStorage('docker-dl:url', 'http://localhost:3000');
|
||||
const serverAuth = useITStorage('docker-dl:auth', '');
|
||||
|
||||
const { serverHost, serverAuth, hasFixedConfig } = useNetworkUtilsConfig({
|
||||
urlStorageKey: 'docker-dl:url',
|
||||
authStorageKey: 'docker-dl:auth',
|
||||
defaultUrl: 'http://localhost:3000',
|
||||
});
|
||||
|
||||
const loading = ref(false);
|
||||
const error = ref<string | null>(null);
|
||||
@@ -60,13 +65,15 @@ async function downloadImage() {
|
||||
|
||||
const url = `${serverHost.value}/download?${params.toString()}`;
|
||||
|
||||
const response = await fetch(url,
|
||||
const response = await fetch(
|
||||
url,
|
||||
serverAuth.value
|
||||
? {
|
||||
method: 'GET',
|
||||
headers: { Authorization: `Basic ${Base64.encode(serverAuth.value)}` },
|
||||
}
|
||||
: undefined);
|
||||
: undefined,
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
const text = await response.text();
|
||||
@@ -75,9 +82,7 @@ async function downloadImage() {
|
||||
|
||||
// Extract filename from Content-Disposition
|
||||
const disposition = response.headers.get('Content-Disposition');
|
||||
const filename
|
||||
= disposition?.match(/filename="(.+)"/)?.[1]
|
||||
|| `${image.value.replace(/[/:]/g, '_')}.tar`;
|
||||
const filename = disposition?.match(/filename="(.+)"/)?.[1] || `${image.value.replace(/[/:]/g, '_')}.tar`;
|
||||
|
||||
// Download file
|
||||
const blob = await response.blob();
|
||||
@@ -90,12 +95,10 @@ async function downloadImage() {
|
||||
title: 'Download started',
|
||||
description: `Downloading ${filename}`,
|
||||
});
|
||||
}
|
||||
catch (err: any) {
|
||||
} catch (err: any) {
|
||||
error.value = err.message || 'Unknown error';
|
||||
message.error(error.value!);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
@@ -104,17 +107,36 @@ async function downloadImage() {
|
||||
<template>
|
||||
<div>
|
||||
<NForm label-width="120px" label-placement="left">
|
||||
<details mb-2>
|
||||
<summary>{{ t('tools.docker-image-downloader.texts.tag-docker-image-download-service-configuration-self-hosted') }}</summary>
|
||||
<details mb-2 v-if="!hasFixedConfig">
|
||||
<summary>
|
||||
{{ t('tools.docker-image-downloader.texts.tag-docker-image-download-service-configuration-self-hosted') }}
|
||||
</summary>
|
||||
<n-card>
|
||||
<NFormItem :label="t('tools.docker-image-downloader.texts.label-docker-image-download-service-url')" label-placement="top">
|
||||
<NInput v-model:value="serverHost" :placeholder="t('tools.docker-image-downloader.texts.placeholder-http-localhost-3000')" />
|
||||
<NFormItem
|
||||
:label="t('tools.docker-image-downloader.texts.label-docker-image-download-service-url')"
|
||||
label-placement="top"
|
||||
>
|
||||
<NInput
|
||||
v-model:value="serverHost"
|
||||
:placeholder="t('tools.docker-image-downloader.texts.placeholder-http-localhost-3000')"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem :label="t('tools.docker-image-downloader.texts.label-basic-authentication')" label-placement="left" label-width="auto">
|
||||
<NInput v-model:value="serverAuth" :placeholder="t('tools.docker-image-downloader.texts.placeholder-username-password')" />
|
||||
<NFormItem
|
||||
:label="t('tools.docker-image-downloader.texts.label-basic-authentication')"
|
||||
label-placement="left"
|
||||
label-width="auto"
|
||||
>
|
||||
<NInput
|
||||
v-model:value="serverAuth"
|
||||
:placeholder="t('tools.docker-image-downloader.texts.placeholder-username-password')"
|
||||
/>
|
||||
</NFormItem>
|
||||
<n-p>
|
||||
{{ t('tools.docker-image-downloader.texts.tag-you-must-self-host-docker-image-download-service-see') }}<c-link href="https://github.com/sharevb/docker-image-download-server?tab=readme-ov-file#running-in-docker" target="_blank">
|
||||
{{ t('tools.docker-image-downloader.texts.tag-you-must-self-host-docker-image-download-service-see')
|
||||
}}<c-link
|
||||
href="https://github.com/sharevb/docker-image-download-server?tab=readme-ov-file#running-in-docker"
|
||||
target="_blank"
|
||||
>
|
||||
{{ t('tools.docker-image-downloader.texts.tag-docker-image-download-service-install') }}
|
||||
</c-link>
|
||||
</n-p>
|
||||
@@ -122,19 +144,21 @@ async function downloadImage() {
|
||||
</details>
|
||||
|
||||
<NFormItem :label="t('tools.docker-image-downloader.texts.label-docker-image')">
|
||||
<NInput v-model:value="image" :placeholder="t('tools.docker-image-downloader.texts.placeholder-alpine-latest')" />
|
||||
</NFormItem>
|
||||
|
||||
<NFormItem :label="t('tools.docker-image-downloader.texts.label-platform')">
|
||||
<NSelect
|
||||
v-model:value="platform"
|
||||
:options="platformOptions"
|
||||
clearable
|
||||
<NInput
|
||||
v-model:value="image"
|
||||
:placeholder="t('tools.docker-image-downloader.texts.placeholder-alpine-latest')"
|
||||
/>
|
||||
</NFormItem>
|
||||
|
||||
<NFormItem :label="t('tools.docker-image-downloader.texts.label-platform')">
|
||||
<NSelect v-model:value="platform" :options="platformOptions" clearable />
|
||||
</NFormItem>
|
||||
|
||||
<NFormItem :label="t('tools.docker-image-downloader.texts.label-registry-url')">
|
||||
<NInput v-model:value="registry" :placeholder="t('tools.docker-image-downloader.texts.placeholder-myregistry-com-optional')" />
|
||||
<NInput
|
||||
v-model:value="registry"
|
||||
:placeholder="t('tools.docker-image-downloader.texts.placeholder-myregistry-com-optional')"
|
||||
/>
|
||||
</NFormItem>
|
||||
|
||||
<NFormItem :label="t('tools.docker-image-downloader.texts.label-username')">
|
||||
@@ -142,20 +166,12 @@ async function downloadImage() {
|
||||
</NFormItem>
|
||||
|
||||
<NFormItem :label="t('tools.docker-image-downloader.texts.label-password')">
|
||||
<NInput
|
||||
v-model:value="password"
|
||||
type="password"
|
||||
show-password-on="click"
|
||||
/>
|
||||
<NInput v-model:value="password" type="password" show-password-on="click" />
|
||||
</NFormItem>
|
||||
</NForm>
|
||||
|
||||
<n-space justify="center">
|
||||
<NButton
|
||||
type="primary"
|
||||
:loading="loading"
|
||||
@click="downloadImage"
|
||||
>
|
||||
<NButton type="primary" :loading="loading" @click="downloadImage">
|
||||
{{ t('tools.docker-image-downloader.texts.tag-download-image') }}
|
||||
</NButton>
|
||||
</n-space>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useITStorage } from '@/composable/queryParams';
|
||||
import { Base64 } from 'js-base64';
|
||||
import { useNetworkUtilsConfig } from '../network-utils/network-utils-config';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -10,8 +11,11 @@ const html = ref('');
|
||||
const error = ref('');
|
||||
const isRunning = ref(false);
|
||||
|
||||
const serverHost = useITStorage('html-to-pdf:url', 'http://localhost:3000');
|
||||
const serverAuth = useITStorage('html-to-pdf:auth', '');
|
||||
const { serverHost, serverAuth, hasFixedConfig } = useNetworkUtilsConfig({
|
||||
urlStorageKey: 'html-to-pdf:url',
|
||||
authStorageKey: 'html-to-pdf:auth',
|
||||
defaultUrl: 'http://localhost:3000',
|
||||
});
|
||||
|
||||
const options = useITStorage('html-to-pdf:opts', {
|
||||
format: 'A4',
|
||||
@@ -89,11 +93,14 @@ async function generateFromUrl() {
|
||||
error.value = '';
|
||||
isRunning.value = true;
|
||||
try {
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
...(serverAuth.value ? { Authorization: `Basic ${Base64.encode(serverAuth.value)}` } : {}),
|
||||
};
|
||||
const res = await fetch(`${serverHost.value}/pdf/url`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
headers,
|
||||
body: JSON.stringify(payload),
|
||||
...(serverAuth.value ? { headers: { Authorization: `Basic ${Base64.encode(serverAuth.value)}` } } : {}),
|
||||
});
|
||||
|
||||
const blob = await res.blob();
|
||||
@@ -178,7 +185,7 @@ async function generateBatch() {
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<details mb-2>
|
||||
<details mb-2 v-if="!hasFixedConfig">
|
||||
<summary>{{ t('tools.html-to-pdf.texts.tag-html-to-pdf-service-configuration-self-hosted') }}</summary>
|
||||
<n-card>
|
||||
<NFormItem :label="t('tools.html-to-pdf.texts.label-html-to-pdf-service-url')" label-placement="top">
|
||||
|
||||
@@ -5,7 +5,6 @@ import { useNetworkUtilsConfig } from '@/tools/network-utils/network-utils-confi
|
||||
import { Base64 } from 'js-base64';
|
||||
|
||||
const { serverHost, serverAuth, hasFixedConfig } = useNetworkUtilsConfig({
|
||||
toolKey: 'https-tester',
|
||||
urlStorageKey: 'https-tester:url',
|
||||
authStorageKey: 'https-tester:auth',
|
||||
});
|
||||
@@ -136,22 +135,50 @@ const labelProps = {
|
||||
<summary>{{ t('tools.https-tester.texts.tag-network-utilities-service-configuration-self-hosted') }}</summary>
|
||||
<n-card>
|
||||
<NFormItem :label="t('tools.https-tester.texts.label-network-utilities-service-url')" label-placement="top">
|
||||
<NInput v-model:value="serverHost" :placeholder="t('tools.https-tester.texts.placeholder-http-localhost-3000')" />
|
||||
<NInput
|
||||
v-model:value="serverHost"
|
||||
:placeholder="t('tools.https-tester.texts.placeholder-http-localhost-3000')"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem :label="t('tools.https-tester.texts.label-basic-authentication')" label-placement="left" label-width="auto">
|
||||
<NInput v-model:value="serverAuth" :placeholder="t('tools.https-tester.texts.placeholder-username-password')" />
|
||||
<NFormItem
|
||||
:label="t('tools.https-tester.texts.label-basic-authentication')"
|
||||
label-placement="left"
|
||||
label-width="auto"
|
||||
>
|
||||
<NInput
|
||||
v-model:value="serverAuth"
|
||||
:placeholder="t('tools.https-tester.texts.placeholder-username-password')"
|
||||
/>
|
||||
</NFormItem>
|
||||
<n-p>{{ t('tools.https-tester.texts.tag-you-must-self-host-network-utilities-service-see') }}<c-link href="https://github.com/sharevb/network-utils-ws#running-in-docker" target="_blank">{{ t('tools.https-tester.texts.tag-network-utilities-service-docker-install') }}</c-link>
|
||||
<n-p
|
||||
>{{ t('tools.https-tester.texts.tag-you-must-self-host-network-utilities-service-see')
|
||||
}}<c-link href="https://github.com/sharevb/network-utils-ws#running-in-docker" target="_blank">{{
|
||||
t('tools.https-tester.texts.tag-network-utilities-service-docker-install')
|
||||
}}</c-link>
|
||||
</n-p>
|
||||
</n-card>
|
||||
</details>
|
||||
|
||||
<n-tabs type="line" animated>
|
||||
<n-tab-pane name="cert" :tab="t('tools.https-tester.texts.tab-certificate')">
|
||||
<c-input-text v-model:value="certHost" :label="t('tools.https-tester.texts.label-host')" v-bind="labelProps" :placeholder="t('tools.https-tester.texts.placeholder-example-com')" mb-1 />
|
||||
<c-input-text v-model:value="certPort" :label="t('tools.https-tester.texts.label-port')" v-bind="labelProps" :placeholder="t('tools.https-tester.texts.placeholder-443')" mb-1 />
|
||||
<c-input-text
|
||||
v-model:value="certHost"
|
||||
:label="t('tools.https-tester.texts.label-host')"
|
||||
v-bind="labelProps"
|
||||
:placeholder="t('tools.https-tester.texts.placeholder-example-com')"
|
||||
mb-1
|
||||
/>
|
||||
<c-input-text
|
||||
v-model:value="certPort"
|
||||
:label="t('tools.https-tester.texts.label-port')"
|
||||
v-bind="labelProps"
|
||||
:placeholder="t('tools.https-tester.texts.placeholder-443')"
|
||||
mb-1
|
||||
/>
|
||||
<div mb-2 flex justify-center>
|
||||
<n-button type="primary" :loading="loading" @click="runCertificate">{{ t('tools.https-tester.texts.tag-check-certificate') }}</n-button>
|
||||
<n-button type="primary" :loading="loading" @click="runCertificate">{{
|
||||
t('tools.https-tester.texts.tag-check-certificate')
|
||||
}}</n-button>
|
||||
</div>
|
||||
|
||||
<n-card v-if="certResult" :title="t('tools.https-tester.texts.title-result')">
|
||||
@@ -161,12 +188,32 @@ const labelProps = {
|
||||
</n-tag>
|
||||
</n-space>
|
||||
|
||||
<input-copyable :label="t('tools.https-tester.texts.label-hostname')" v-bind="labelProps" :value="certResult.hostname" mb-1 />
|
||||
<input-copyable :label="t('tools.https-tester.texts.label-port')" v-bind="labelProps" :value="certResult.port" mb-1 />
|
||||
<input-copyable
|
||||
:label="t('tools.https-tester.texts.label-hostname')"
|
||||
v-bind="labelProps"
|
||||
:value="certResult.hostname"
|
||||
mb-1
|
||||
/>
|
||||
<input-copyable
|
||||
:label="t('tools.https-tester.texts.label-port')"
|
||||
v-bind="labelProps"
|
||||
:value="certResult.port"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable :label="t('tools.https-tester.texts.label-not-before')" v-bind="labelProps" :value="formatDate(certResult.not_before)" mb-1 />
|
||||
<input-copyable
|
||||
:label="t('tools.https-tester.texts.label-not-before')"
|
||||
v-bind="labelProps"
|
||||
:value="formatDate(certResult.not_before)"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable :label="t('tools.https-tester.texts.label-not-after')" v-bind="labelProps" :value="formatDate(certResult.not_after)" mb-1 />
|
||||
<input-copyable
|
||||
:label="t('tools.https-tester.texts.label-not-after')"
|
||||
v-bind="labelProps"
|
||||
:value="formatDate(certResult.not_after)"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable
|
||||
:label="t('tools.https-tester.texts.label-days-until-expiry')"
|
||||
@@ -175,9 +222,19 @@ const labelProps = {
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable :label="t('tools.https-tester.texts.label-subject')" v-bind="labelProps" :value="prettyJSON(certResult.subject)" mb-1 />
|
||||
<input-copyable
|
||||
:label="t('tools.https-tester.texts.label-subject')"
|
||||
v-bind="labelProps"
|
||||
:value="prettyJSON(certResult.subject)"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable :label="t('tools.https-tester.texts.label-issuer')" v-bind="labelProps" :value="prettyJSON(certResult.issuer)" mb-1 />
|
||||
<input-copyable
|
||||
:label="t('tools.https-tester.texts.label-issuer')"
|
||||
v-bind="labelProps"
|
||||
:value="prettyJSON(certResult.issuer)"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable
|
||||
v-for="(san, index) in certResult.san"
|
||||
@@ -200,9 +257,17 @@ const labelProps = {
|
||||
|
||||
<!-- HSTS -->
|
||||
<n-tab-pane name="hsts" :tab="t('tools.https-tester.texts.tab-hsts')">
|
||||
<c-input-text v-model:value="hstsUrl" :label="t('tools.https-tester.texts.label-url')" v-bind="labelProps" :placeholder="t('tools.https-tester.texts.placeholder-https-example-com')" mb-1 />
|
||||
<c-input-text
|
||||
v-model:value="hstsUrl"
|
||||
:label="t('tools.https-tester.texts.label-url')"
|
||||
v-bind="labelProps"
|
||||
:placeholder="t('tools.https-tester.texts.placeholder-https-example-com')"
|
||||
mb-1
|
||||
/>
|
||||
<div mb-2 flex justify-center>
|
||||
<n-button type="primary" :loading="loading" @click="runHsts">{{ t('tools.https-tester.texts.tag-check-hsts') }}</n-button>
|
||||
<n-button type="primary" :loading="loading" @click="runHsts">{{
|
||||
t('tools.https-tester.texts.tag-check-hsts')
|
||||
}}</n-button>
|
||||
</div>
|
||||
|
||||
<n-card v-if="hstsResult" :title="t('tools.https-tester.texts.title-result')">
|
||||
@@ -212,7 +277,12 @@ const labelProps = {
|
||||
</n-tag>
|
||||
</n-space>
|
||||
|
||||
<input-copyable :label="t('tools.https-tester.texts.label-url')" v-bind="labelProps" :value="hstsResult.url" mb-1 />
|
||||
<input-copyable
|
||||
:label="t('tools.https-tester.texts.label-url')"
|
||||
v-bind="labelProps"
|
||||
:value="hstsResult.url"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable
|
||||
:label="t('tools.https-tester.texts.label-hsts-present')"
|
||||
@@ -236,7 +306,12 @@ const labelProps = {
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable :label="t('tools.https-tester.texts.label-preload')" v-bind="labelProps" :value="hstsResult.preload ? 'Yes' : 'No'" mb-1 />
|
||||
<input-copyable
|
||||
:label="t('tools.https-tester.texts.label-preload')"
|
||||
v-bind="labelProps"
|
||||
:value="hstsResult.preload ? 'Yes' : 'No'"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable
|
||||
v-if="hstsResult.raw_header"
|
||||
@@ -267,7 +342,9 @@ const labelProps = {
|
||||
mb-1
|
||||
/>
|
||||
<div mb-2 flex justify-center>
|
||||
<n-button type="primary" :loading="loading" @click="runRedirect">{{ t('tools.https-tester.texts.tag-check-redirect') }}</n-button>
|
||||
<n-button type="primary" :loading="loading" @click="runRedirect">{{
|
||||
t('tools.https-tester.texts.tag-check-redirect')
|
||||
}}</n-button>
|
||||
</div>
|
||||
</n-form>
|
||||
|
||||
@@ -278,7 +355,12 @@ const labelProps = {
|
||||
</n-tag>
|
||||
</n-space>
|
||||
|
||||
<input-copyable :label="t('tools.https-tester.texts.label-http-url')" v-bind="labelProps" :value="redirectResult.http_url" mb-1 />
|
||||
<input-copyable
|
||||
:label="t('tools.https-tester.texts.label-http-url')"
|
||||
v-bind="labelProps"
|
||||
:value="redirectResult.http_url"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable
|
||||
:label="t('tools.https-tester.texts.label-redirected')"
|
||||
@@ -287,9 +369,19 @@ const labelProps = {
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable :label="t('tools.https-tester.texts.label-final-url')" v-bind="labelProps" :value="redirectResult.final_url" mb-1 />
|
||||
<input-copyable
|
||||
:label="t('tools.https-tester.texts.label-final-url')"
|
||||
v-bind="labelProps"
|
||||
:value="redirectResult.final_url"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable :label="t('tools.https-tester.texts.label-status-code')" v-bind="labelProps" :value="String(redirectResult.status_code)" mb-1 />
|
||||
<input-copyable
|
||||
:label="t('tools.https-tester.texts.label-status-code')"
|
||||
v-bind="labelProps"
|
||||
:value="String(redirectResult.status_code)"
|
||||
mb-1
|
||||
/>
|
||||
|
||||
<input-copyable
|
||||
v-if="redirectResult.redirect_chain"
|
||||
|
||||
@@ -1,10 +1,33 @@
|
||||
import JSZip from 'jszip';
|
||||
|
||||
import { translate as t } from '@/plugins/i18n.plugin';
|
||||
import { Base64 } from 'js-base64';
|
||||
|
||||
export async function downloadLinks(
|
||||
links: string,
|
||||
corsAnywhere?: {
|
||||
serverHost: string;
|
||||
serverAuth: string;
|
||||
},
|
||||
): Promise<void> {
|
||||
const doFetch = (url: string) => {
|
||||
if (corsAnywhere?.serverHost) {
|
||||
const corsUrl = `${corsAnywhere.serverHost.replace(/\/+$/g, '')}/${url}`;
|
||||
return fetch(
|
||||
corsUrl,
|
||||
corsAnywhere.serverAuth
|
||||
? {
|
||||
method: 'GET',
|
||||
headers: { Authorization: `Basic ${Base64.encode(corsAnywhere.serverAuth)}` },
|
||||
}
|
||||
: undefined,
|
||||
);
|
||||
}
|
||||
return fetch(url);
|
||||
};
|
||||
|
||||
export async function downloadLinks(links: string): Promise<void> {
|
||||
// Split links by newline and filter out empty ones
|
||||
const linksArray: string[] = links.split('\n').filter(link => link.trim() !== '');
|
||||
const linksArray: string[] = links.split('\n').filter((link) => link.trim() !== '');
|
||||
|
||||
// Helper function to handle duplicate filenames
|
||||
function getUniqueFileName(existingNames: Set<string>, originalName: string): string {
|
||||
@@ -35,7 +58,7 @@ export async function downloadLinks(links: string): Promise<void> {
|
||||
// Single link: download directly
|
||||
const linkUrl: string = linksArray[0];
|
||||
try {
|
||||
const response: Response = await fetch(linkUrl);
|
||||
const response: Response = await doFetch(linkUrl);
|
||||
if (!response.ok) {
|
||||
throw new Error(t('tools.multi-link-downloader.service.text.failed-to-fetch-linkurl', [linkUrl]));
|
||||
}
|
||||
@@ -57,12 +80,10 @@ export async function downloadLinks(links: string): Promise<void> {
|
||||
// Clean up
|
||||
document.body.removeChild(a);
|
||||
window.URL.revokeObjectURL(downloadUrl);
|
||||
}
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error('Error downloading the file:', error);
|
||||
}
|
||||
}
|
||||
else if (linksArray.length > 1) {
|
||||
} else if (linksArray.length > 1) {
|
||||
// Multiple links: create a zip file
|
||||
const zip = new JSZip();
|
||||
const fileNamesSet = new Set<string>(); // To track file names for duplicates
|
||||
@@ -84,8 +105,7 @@ export async function downloadLinks(links: string): Promise<void> {
|
||||
|
||||
// Add file to the zip
|
||||
zip.file(fileName, blob);
|
||||
}
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
console.error(`Error downloading file from ${linkUrl}:${error}`);
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -1,51 +1,84 @@
|
||||
<script lang="ts">
|
||||
<script setup lang="ts">
|
||||
/* NO EXTRACT SCRIPT */
|
||||
import { defineComponent, ref } from 'vue';
|
||||
import { downloadLinks } from './multi-link-downloader.service';
|
||||
import { useNetworkUtilsConfig } from '../network-utils/network-utils-config';
|
||||
import { useITStorage } from '@/composable/queryParams';
|
||||
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
const links = ref<string>('');
|
||||
const downloadMultiLinks = () => {
|
||||
if (links.value) {
|
||||
downloadLinks(links.value);
|
||||
}
|
||||
};
|
||||
const { t } = useI18n();
|
||||
|
||||
const clearInput = () => {
|
||||
links.value = '';
|
||||
};
|
||||
|
||||
return {
|
||||
links,
|
||||
downloadMultiLinks,
|
||||
clearInput,
|
||||
};
|
||||
},
|
||||
const {
|
||||
serverHost: corsAnywhereUrl,
|
||||
serverAuth,
|
||||
hasFixedConfig,
|
||||
} = useNetworkUtilsConfig({
|
||||
urlStorageKey: 'multi-links-dl:url',
|
||||
authStorageKey: 'multi-links-dl:auth',
|
||||
});
|
||||
|
||||
const links = ref<string>('');
|
||||
const downloadMultiLinks = () => {
|
||||
if (links.value) {
|
||||
downloadLinks(
|
||||
links.value,
|
||||
corsAnywhereUrl.value
|
||||
? {
|
||||
serverHost: corsAnywhereUrl.value,
|
||||
serverAuth: serverAuth.value,
|
||||
}
|
||||
: undefined,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const clearInput = () => {
|
||||
links.value = '';
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<c-card>
|
||||
<details v-if="!hasFixedConfig">
|
||||
<summary>{{ t('tools.short-urls-expander.texts.cors-anywhere-configuration') }}</summary>
|
||||
<n-card>
|
||||
<c-input-text
|
||||
v-model:value="corsAnywhereUrl"
|
||||
:label="t('tools.short-urls-expander.texts.cors-anywhere-instance-url')"
|
||||
label-position="left"
|
||||
:placeholder="t('tools.short-urls-expander.texts.put-your-cors-anywhere-instance-url')"
|
||||
mb-1
|
||||
/>
|
||||
<NFormItem
|
||||
:label="t('tools.https-tester.texts.label-basic-authentication')"
|
||||
label-placement="left"
|
||||
label-width="auto"
|
||||
>
|
||||
<NInput
|
||||
v-model:value="serverAuth"
|
||||
:placeholder="t('tools.https-tester.texts.placeholder-username-password')"
|
||||
/>
|
||||
</NFormItem>
|
||||
<n-p>
|
||||
{{
|
||||
t(
|
||||
'tools.short-urls-expander.texts.this-tools-requires-a-cors-anywhere-instance-to-bypass-cors-policy-you-can-use-a',
|
||||
)
|
||||
}}
|
||||
<a href="https://github.com/sharevb/cors-anywhere?tab=readme-ov-file#run-with-docker" target="_blank">
|
||||
{{ t('tools.short-urls-expander.texts.self-hosted-cors-anywhere') }}
|
||||
</a>
|
||||
</n-p>
|
||||
</n-card>
|
||||
</details>
|
||||
<div class="mb-4 flex justify-between">
|
||||
<c-button
|
||||
class="mr-2"
|
||||
:disabled="!links"
|
||||
@click="downloadMultiLinks"
|
||||
>
|
||||
Start Download
|
||||
</c-button>
|
||||
<c-button
|
||||
class="ml-2"
|
||||
@click="clearInput"
|
||||
>
|
||||
Clear
|
||||
<c-button class="mr-2" :disabled="!links" @click="downloadMultiLinks">
|
||||
{{ t('tools.multi-link-downloader.texts.tag-start-download') }}
|
||||
</c-button>
|
||||
<c-button class="ml-2" @click="clearInput"> {{ t('tools.multi-link-downloader.texts.tag-clear') }} </c-button>
|
||||
</div>
|
||||
|
||||
<c-input-text
|
||||
v-model:value="links"
|
||||
placeholder="Add links separated by new lines..."
|
||||
:placeholder="t('tools.multi-link-downloader.texts.placeholder-add-links-separated-by-new-lines')"
|
||||
multiline
|
||||
:rows="20"
|
||||
/>
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
import { getITToolsSetting, useITStorage } from '@/composable/queryParams';
|
||||
import { ref } from 'vue';
|
||||
|
||||
export function useNetworkUtilsConfig({ toolKey, urlStorageKey, authStorageKey }: { toolKey: string; urlStorageKey: string; authStorageKey: string }) {
|
||||
const fixedUrl = String(getITToolsSetting(`${toolKey}:url`, '') || '').trim();
|
||||
const fixedAuth = String(getITToolsSetting(`${toolKey}:auth`, '') || '').trim();
|
||||
export function useNetworkUtilsConfig({
|
||||
urlStorageKey,
|
||||
authStorageKey,
|
||||
defaultUrl = 'http://localhost:8000',
|
||||
}: {
|
||||
urlStorageKey: string;
|
||||
authStorageKey: string;
|
||||
defaultUrl?: string;
|
||||
}) {
|
||||
const fixedUrl = String(getITToolsSetting(urlStorageKey, '') || '').trim();
|
||||
const fixedAuth = String(getITToolsSetting(authStorageKey, '') || '').trim();
|
||||
const hasFixedConfig = Boolean(fixedUrl);
|
||||
|
||||
return {
|
||||
serverHost: hasFixedConfig
|
||||
? ref(fixedUrl)
|
||||
: useITStorage(urlStorageKey, 'http://localhost:8000'),
|
||||
serverAuth: hasFixedConfig
|
||||
? ref(fixedAuth)
|
||||
: useITStorage(authStorageKey, ''),
|
||||
serverHost: hasFixedConfig ? ref(fixedUrl) : useITStorage(urlStorageKey, defaultUrl),
|
||||
serverAuth: hasFixedConfig ? ref(fixedAuth) : useITStorage(authStorageKey, ''),
|
||||
hasFixedConfig,
|
||||
};
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import { Base64 } from 'js-base64';
|
||||
const { t } = useI18n();
|
||||
|
||||
const { serverHost, serverAuth, hasFixedConfig } = useNetworkUtilsConfig({
|
||||
toolKey: 'ping',
|
||||
urlStorageKey: 'ping:url',
|
||||
authStorageKey: 'ping:auth',
|
||||
});
|
||||
|
||||
@@ -1,13 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useITStorage } from '@/composable/queryParams';
|
||||
import { useNetworkUtilsConfig } from '../network-utils/network-utils-config';
|
||||
import { Base64 } from 'js-base64';
|
||||
|
||||
const { t } = useI18n();
|
||||
const inputUrls = ref('');
|
||||
const results = ref<{ short: string; expanded: string | null; ok: boolean; status: string }[]>([]);
|
||||
const error = ref('');
|
||||
const loading = ref(false);
|
||||
const corsAnywhereUrl = useITStorage('short-urls-expander:cors-anywhere-url', '//cors.outils-libre.org');
|
||||
|
||||
const {
|
||||
serverHost: corsAnywhereUrl,
|
||||
serverAuth,
|
||||
hasFixedConfig,
|
||||
} = useNetworkUtilsConfig({
|
||||
urlStorageKey: 'short-urls-expander:cors-anywhere-url',
|
||||
authStorageKey: 'short-urls-expander:auth',
|
||||
defaultUrl: '//cors.outils-libre.org',
|
||||
});
|
||||
|
||||
function expandSingleUrl(
|
||||
url: string,
|
||||
@@ -17,6 +27,9 @@ function expandSingleUrl(
|
||||
const corsUrl = `${corsAnywhereUrl.value.replace(/\/+$/g, '')}/${url}`;
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('HEAD', corsUrl, true);
|
||||
if (serverAuth.value) {
|
||||
xhr.setRequestHeader('Authorization', `Basic ${Base64.encode(serverAuth.value)}`);
|
||||
}
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === xhr.DONE) {
|
||||
// In browsers, xhr.responseURL gives the final resolved URL after redirects
|
||||
@@ -95,7 +108,7 @@ function downloadCsv() {
|
||||
<template>
|
||||
<div>
|
||||
<NSpace vertical>
|
||||
<details>
|
||||
<details v-if="!hasFixedConfig">
|
||||
<summary>{{ t('tools.short-urls-expander.texts.cors-anywhere-configuration') }}</summary>
|
||||
<n-card>
|
||||
<c-input-text
|
||||
@@ -105,6 +118,16 @@ function downloadCsv() {
|
||||
:placeholder="t('tools.short-urls-expander.texts.put-your-cors-anywhere-instance-url')"
|
||||
mb-1
|
||||
/>
|
||||
<NFormItem
|
||||
:label="t('tools.https-tester.texts.label-basic-authentication')"
|
||||
label-placement="left"
|
||||
label-width="auto"
|
||||
>
|
||||
<NInput
|
||||
v-model:value="serverAuth"
|
||||
:placeholder="t('tools.https-tester.texts.placeholder-username-password')"
|
||||
/>
|
||||
</NFormItem>
|
||||
<n-p>
|
||||
{{
|
||||
t(
|
||||
|
||||
@@ -1,15 +1,24 @@
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useITStorage, useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
import { useNetworkUtilsConfig } from '../network-utils/network-utils-config';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const wsUrl = useITStorage('tcp-udp-port-tester:ws', 'ws://localhost:8080');
|
||||
const { serverHost: wsUrl, hasFixedConfig } = useNetworkUtilsConfig({
|
||||
urlStorageKey: 'tcp-udp-port-tester:ws',
|
||||
authStorageKey: 'tcp-udp-port-tester:auth',
|
||||
defaultUrl: 'ws://localhost:8080',
|
||||
});
|
||||
const socket = ref<WebSocket | null>(null);
|
||||
const isConnected = ref(false);
|
||||
const logs = ref<string[]>([]);
|
||||
|
||||
const targetHost = useQueryParamOrStorage({ name: 'target', storageName: 'tcp-udp-port-tester:t', defaultValue: 'localhost' });
|
||||
const targetHost = useQueryParamOrStorage({
|
||||
name: 'target',
|
||||
storageName: 'tcp-udp-port-tester:t',
|
||||
defaultValue: 'localhost',
|
||||
});
|
||||
const targetPort = useQueryParamOrStorage({ name: 'port', storageName: 'tcp-udp-port-tester:p', defaultValue: 9000 });
|
||||
const protocol = useQueryParamOrStorage({ name: 'proto', storageName: 'tcp-udp-port-tester:o', defaultValue: 'tcp' });
|
||||
|
||||
@@ -40,22 +49,22 @@ function connect() {
|
||||
const json = JSON.parse(event.data);
|
||||
if (json.error) {
|
||||
addLog(`${t('tools.tcp-udp-port-tester.texts.error')} ${json.error}`);
|
||||
}
|
||||
else if (json.end) {
|
||||
} else if (json.end) {
|
||||
addLog(`${t('tools.tcp-udp-port-tester.texts.end')} ${json.end}`);
|
||||
}
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
if (typeof event.data === 'string') {
|
||||
addLog(`${t('tools.tcp-udp-port-tester.texts.text')} ${event.data}`);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
const buffer = new Uint8Array(event.data);
|
||||
addLog(`${t('tools.tcp-udp-port-tester.texts.binary')} ${Array.from(buffer).map(b => b.toString(16).padStart(2, '0')).join(' ')}`);
|
||||
addLog(
|
||||
`${t('tools.tcp-udp-port-tester.texts.binary')} ${Array.from(buffer)
|
||||
.map((b) => b.toString(16).padStart(2, '0'))
|
||||
.join(' ')}`,
|
||||
);
|
||||
try {
|
||||
addLog(`${t('tools.tcp-udp-port-tester.texts.text')} ${new TextDecoder().decode(buffer)}`);
|
||||
}
|
||||
catch {}
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -87,13 +96,17 @@ function configureTarget() {
|
||||
port: targetPort.value,
|
||||
};
|
||||
socket.value.send(JSON.stringify(config));
|
||||
addLog(`${t('tools.tcp-udp-port-tester.texts.configured')} ${protocol.value.toUpperCase()} → ${targetHost.value}:${targetPort.value}`);
|
||||
addLog(
|
||||
`${t('tools.tcp-udp-port-tester.texts.configured')} ${protocol.value.toUpperCase()} → ${targetHost.value}:${targetPort.value}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function sendText() {
|
||||
if (socket.value && isConnected.value && textPayload.value.trim() !== '') {
|
||||
socket.value.send(JSON.stringify({ type: 'send', payload: textPayload.value.replace(/\\n/g, '\n').replace(/\\r/g, '\r') }));
|
||||
socket.value.send(
|
||||
JSON.stringify({ type: 'send', payload: textPayload.value.replace(/\\n/g, '\n').replace(/\\r/g, '\r') }),
|
||||
);
|
||||
addLog(`${t('tools.tcp-udp-port-tester.texts.sent-text')} ${textPayload.value}`);
|
||||
}
|
||||
}
|
||||
@@ -107,7 +120,7 @@ function sendHex() {
|
||||
}
|
||||
|
||||
function hexStringToBytes(hex: string): number[] {
|
||||
return hex.match(/.{1,2}/g)?.map(byte => Number.parseInt(byte, 16)) ?? [];
|
||||
return hex.match(/.{1,2}/g)?.map((byte) => Number.parseInt(byte, 16)) ?? [];
|
||||
}
|
||||
|
||||
function clearLogs() {
|
||||
@@ -136,13 +149,26 @@ onBeforeUnmount(() => {
|
||||
<template>
|
||||
<div>
|
||||
<div mb-1>
|
||||
<details mb-2>
|
||||
<details mb-2 v-if="!hasFixedConfig">
|
||||
<summary mb-1>
|
||||
{{ t('tools.tcp-udp-port-tester.texts.tag-websocket-tcp-udp-bridge-configuration') }}
|
||||
</summary>
|
||||
<c-input-text v-model:value="wsUrl" :label="t('tools.tcp-udp-port-tester.texts.label-websocket-tcp-udp-bridge-url')" label-position="left" :placeholder="t('tools.tcp-udp-port-tester.texts.placeholder-websocket-url')" mb-1 />
|
||||
<c-input-text
|
||||
v-model:value="wsUrl"
|
||||
:label="t('tools.tcp-udp-port-tester.texts.label-websocket-tcp-udp-bridge-url')"
|
||||
label-position="left"
|
||||
:placeholder="t('tools.tcp-udp-port-tester.texts.placeholder-websocket-url')"
|
||||
mb-1
|
||||
/>
|
||||
<n-p mb-1>
|
||||
{{ t('tools.tcp-udp-port-tester.texts.tag-to-use-this-tool-you-need-to-host-a-websocket-tcp-udp-bridge-based-on') }}<c-link target="_blank" href="https://github.com/sharevb/ws-tcp-udp-bridge?tab=readme-ov-file#running-with-it-tools">
|
||||
{{
|
||||
t(
|
||||
'tools.tcp-udp-port-tester.texts.tag-to-use-this-tool-you-need-to-host-a-websocket-tcp-udp-bridge-based-on',
|
||||
)
|
||||
}}<c-link
|
||||
target="_blank"
|
||||
href="https://github.com/sharevb/ws-tcp-udp-bridge?tab=readme-ov-file#running-with-it-tools"
|
||||
>
|
||||
{{ t('tools.tcp-udp-port-tester.texts.tag-https-github-com-sharevb-ws-tcp-udp-bridge') }}
|
||||
</c-link>
|
||||
</n-p>
|
||||
@@ -159,14 +185,27 @@ onBeforeUnmount(() => {
|
||||
|
||||
<n-space justify="center">
|
||||
<n-tag :type="isConnected ? 'success' : 'error'">
|
||||
{{ isConnected ? t('tools.tcp-udp-port-tester.text.connected') : t('tools.tcp-udp-port-tester.text.disconnected') }}
|
||||
{{
|
||||
isConnected
|
||||
? t('tools.tcp-udp-port-tester.text.connected')
|
||||
: t('tools.tcp-udp-port-tester.text.disconnected')
|
||||
}}
|
||||
</n-tag>
|
||||
</n-space>
|
||||
</div>
|
||||
|
||||
<n-form-item :label="t('tools.tcp-udp-port-tester.texts.label-target')" label-placement="left">
|
||||
<n-input v-model:value="targetHost" :placeholder="t('tools.tcp-udp-port-tester.texts.placeholder-target-ip')" mr-1 />
|
||||
<n-input-number v-model:value="targetPort" :placeholder="t('tools.tcp-udp-port-tester.texts.placeholder-port')" style="width: 250px" mr-1 />
|
||||
<n-input
|
||||
v-model:value="targetHost"
|
||||
:placeholder="t('tools.tcp-udp-port-tester.texts.placeholder-target-ip')"
|
||||
mr-1
|
||||
/>
|
||||
<n-input-number
|
||||
v-model:value="targetPort"
|
||||
:placeholder="t('tools.tcp-udp-port-tester.texts.placeholder-port')"
|
||||
style="width: 250px"
|
||||
mr-1
|
||||
/>
|
||||
|
||||
<n-select
|
||||
v-model:value="protocol"
|
||||
@@ -186,13 +225,16 @@ onBeforeUnmount(() => {
|
||||
{{ t('tools.tcp-udp-port-tester.texts.tag-clear-logs') }}
|
||||
</n-button>
|
||||
</n-space>
|
||||
<div ref="logsRef" style="font-size: .8em; height: 250px; overflow-y: scroll">
|
||||
<div ref="logsRef" style="font-size: 0.8em; height: 250px; overflow-y: scroll">
|
||||
<pre v-for="(msg, idx) in logs" :key="idx" style="white-space: pre-wrap">{{ msg }}</pre>
|
||||
</div>
|
||||
</n-card>
|
||||
|
||||
<n-card :title="t('tools.tcp-udp-port-tester.texts.title-payload-builder')" mb-1>
|
||||
<n-form-item :label="t('tools.tcp-udp-port-tester.texts.label-send-text-payload-can-add-r-n')" label-placement="left">
|
||||
<n-form-item
|
||||
:label="t('tools.tcp-udp-port-tester.texts.label-send-text-payload-can-add-r-n')"
|
||||
label-placement="left"
|
||||
>
|
||||
<n-input
|
||||
v-model:value="textPayload"
|
||||
:placeholder="t('tools.tcp-udp-port-tester.texts.placeholder-text-payload')"
|
||||
|
||||
Reference in new issue
Block a user