mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-23 06:11:06 +03:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d5e8be848 |
No files matched your search
@@ -6,10 +6,6 @@
|
||||
|
||||
Useful tools for developer and people working in IT. [Have a look !](https://it-tools.tech).
|
||||
|
||||
## Sponsors
|
||||
|
||||
[](https://renderize.tech?utm_source=it-tools&utm_medium=readme)
|
||||
|
||||
## Functionalities and roadmap
|
||||
|
||||
Please check the [issues](https://github.com/CorentinTh/it-tools/issues) to see if some feature listed to be implemented.
|
||||
|
||||
Vendored
-1
@@ -103,7 +103,6 @@ declare module '@vue/runtime-core' {
|
||||
IconMdiTriangleDown: typeof import('~icons/mdi/triangle-down')['default']
|
||||
InputCopyable: typeof import('./src/components/InputCopyable.vue')['default']
|
||||
IntegerBaseConverter: typeof import('./src/tools/integer-base-converter/integer-base-converter.vue')['default']
|
||||
IpIncludeExclude: typeof import('./src/tools/ip-include-exclude/ip-include-exclude.vue')['default']
|
||||
Ipv4AddressConverter: typeof import('./src/tools/ipv4-address-converter/ipv4-address-converter.vue')['default']
|
||||
Ipv4RangeExpander: typeof import('./src/tools/ipv4-range-expander/ipv4-range-expander.vue')['default']
|
||||
Ipv4SubnetCalculator: typeof import('./src/tools/ipv4-subnet-calculator/ipv4-subnet-calculator.vue')['default']
|
||||
|
||||
@@ -54,7 +54,6 @@
|
||||
"@vueuse/router": "^10.0.0",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"change-case": "^4.1.2",
|
||||
"cidr-tools": "^11.0.2",
|
||||
"colord": "^2.9.3",
|
||||
"composerize-ts": "^0.6.2",
|
||||
"country-code-lookup": "^0.1.0",
|
||||
@@ -71,7 +70,6 @@
|
||||
"highlight.js": "^11.7.0",
|
||||
"iarna-toml-esm": "^3.0.5",
|
||||
"ibantools": "^4.3.3",
|
||||
"ip-matching": "^2.1.2",
|
||||
"js-base64": "^3.7.6",
|
||||
"json5": "^2.2.3",
|
||||
"jwt-decode": "^3.1.2",
|
||||
|
||||
Generated
+8489
-6651
File diff suppressed because it is too large.
Load diff
+1
-19
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { IconDragDrop, IconFileDescription, IconHeart } from '@tabler/icons-vue';
|
||||
import { IconDragDrop, IconHeart } from '@tabler/icons-vue';
|
||||
import { useHead } from '@vueuse/head';
|
||||
import { computed } from 'vue';
|
||||
import Draggable from 'vuedraggable';
|
||||
@@ -43,24 +43,6 @@ function onUpdateFavoriteTools() {
|
||||
{{ $t('home.follow.thankYou') }}
|
||||
<n-icon :component="IconHeart" />
|
||||
</ColoredCard>
|
||||
|
||||
<a href="https://renderize.tech?utm_source=it-tools&utm_medium=banner" target="_blank" rel="noopener" class="text-current decoration-none">
|
||||
<c-card v-if="config.showSponsorBanner" class="cursor-pointer !border-2px !hover:border-primary">
|
||||
<div class="flex items-center justify-between">
|
||||
<n-icon :component="IconFileDescription" class="text-neutral-400 dark:text-neutral-600" size="40" />
|
||||
<div class="rounded-full bg-#eeeeee px-10px py-2px text-xs text-black dark:bg-#333333 dark:text-white">
|
||||
Sponsor
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="my-5px flex items-baseline gap-4 text-balance text-lg text-black dark:text-white">
|
||||
Generate PDFs from HTML with Renderize API
|
||||
</div>
|
||||
<div class="text-neutral-500 dark:text-neutral-400">
|
||||
Automate your document generation with our fast, developer-friendly API. Start with a free forever plan.
|
||||
</div>
|
||||
</c-card>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<transition name="height">
|
||||
|
||||
+1
-10
@@ -1,7 +1,6 @@
|
||||
import { tool as base64FileConverter } from './base64-file-converter';
|
||||
import { tool as base64StringConverter } from './base64-string-converter';
|
||||
import { tool as basicAuthGenerator } from './basic-auth-generator';
|
||||
import { tool as ipIncludeExclude } from './ip-include-exclude';
|
||||
import { tool as emailNormalizer } from './email-normalizer';
|
||||
|
||||
import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
||||
@@ -165,15 +164,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
},
|
||||
{
|
||||
name: 'Network',
|
||||
components: [
|
||||
ipv4SubnetCalculator,
|
||||
ipv4AddressConverter,
|
||||
ipv4RangeExpander,
|
||||
ipIncludeExclude,
|
||||
macAddressLookup,
|
||||
macAddressGenerator,
|
||||
ipv6UlaGenerator,
|
||||
],
|
||||
components: [ipv4SubnetCalculator, ipv4AddressConverter, ipv4RangeExpander, macAddressLookup, macAddressGenerator, ipv6UlaGenerator],
|
||||
},
|
||||
{
|
||||
name: 'Math',
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { UnfoldMoreOutlined } from '@vicons/material';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'IP Subnets Exclude Calculator',
|
||||
path: '/ip-include-exclude',
|
||||
description: 'Substract a disallowed IP Ranges/Mask/CIDR list from an allowed IP Ranges/Mask/CIDR list',
|
||||
keywords: ['ip', 'allowed', 'disallowed', 'include', 'exclude', 'subnet', 'cidr'],
|
||||
component: () => import('./ip-include-exclude.vue'),
|
||||
icon: UnfoldMoreOutlined,
|
||||
createdAt: new Date('2024-08-15'),
|
||||
});
|
||||
@@ -1,63 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { substractCIDRs } from './ip-include-exclude.service';
|
||||
|
||||
describe('ip-include-exclude', () => {
|
||||
describe('substractCIDRs', () => {
|
||||
it('should return error on invalid values', () => {
|
||||
expect(substractCIDRs({ allowedRanges: '192.168.0.', disallowedRanges: '' })).to.deep.eq({ // NOSONAR
|
||||
allowedCIDRs: [],
|
||||
allowedSubnets: [],
|
||||
disallowedSubnets: [],
|
||||
error: 'Error: Invalid IP (range/subnetwork)',
|
||||
});
|
||||
});
|
||||
it('should return correct substractions and subnets', () => {
|
||||
expect(substractCIDRs({ allowedRanges: '192.168.3.0/24', disallowedRanges: '' })).to.deep.eq({ // NOSONAR
|
||||
allowedCIDRs: ['192.168.3.0/24'], // NOSONAR
|
||||
allowedSubnets: [{ cidr: '192.168.3.0/24', end: '192.168.3.255', start: '192.168.3.0' }], // NOSONAR
|
||||
disallowedSubnets: [],
|
||||
error: '',
|
||||
});
|
||||
expect(substractCIDRs({ allowedRanges: '192.168.2.0/24', disallowedRanges: '192.168.2.1' })).to.deep.eq({ // NOSONAR
|
||||
allowedCIDRs: ['192.168.2.0/32', // NOSONAR
|
||||
'192.168.2.2/31', // NOSONAR
|
||||
'192.168.2.4/30', // NOSONAR
|
||||
'192.168.2.8/29', // NOSONAR
|
||||
'192.168.2.16/28', // NOSONAR
|
||||
'192.168.2.32/27', // NOSONAR
|
||||
'192.168.2.64/26', // NOSONAR
|
||||
'192.168.2.128/25'], // NOSONAR
|
||||
allowedSubnets: [
|
||||
{ cidr: '192.168.2.0/24', end: '192.168.2.255', start: '192.168.2.0' }, // NOSONAR
|
||||
],
|
||||
disallowedSubnets: [
|
||||
{ cidr: '192.168.2.1/32', end: '192.168.2.1', start: '192.168.2.1' }, // NOSONAR
|
||||
],
|
||||
error: '',
|
||||
});
|
||||
expect(substractCIDRs({ allowedRanges: '192.168.12.0/24', disallowedRanges: '192.168.12.1-192.168.12.10, 192.168.12.34' })).to.deep.eq({ // NOSONAR
|
||||
allowedCIDRs: ['192.168.12.0/32', // NOSONAR
|
||||
'192.168.12.11/32', // NOSONAR
|
||||
'192.168.12.12/30', // NOSONAR
|
||||
'192.168.12.16/28', // NOSONAR
|
||||
'192.168.12.32/31', // NOSONAR
|
||||
'192.168.12.35/32', // NOSONAR
|
||||
'192.168.12.36/30', // NOSONAR
|
||||
'192.168.12.40/29', // NOSONAR
|
||||
'192.168.12.48/28', // NOSONAR
|
||||
'192.168.12.64/26', // NOSONAR
|
||||
'192.168.12.128/25'], // NOSONAR
|
||||
allowedSubnets: [{ cidr: '192.168.12.0/24', end: '192.168.12.255', start: '192.168.12.0' }], // NOSONAR
|
||||
disallowedSubnets: [
|
||||
{ cidr: '192.168.12.1/32', end: '192.168.12.1', start: '192.168.12.1' }, // NOSONAR
|
||||
{ cidr: '192.168.12.2/31', end: '192.168.12.3', start: '192.168.12.2' }, // NOSONAR
|
||||
{ cidr: '192.168.12.4/30', end: '192.168.12.7', start: '192.168.12.4' }, // NOSONAR
|
||||
{ cidr: '192.168.12.8/31', end: '192.168.12.9', start: '192.168.12.8' }, // NOSONAR
|
||||
{ cidr: '192.168.12.10/32', end: '192.168.12.10', start: '192.168.12.10' }, // NOSONAR
|
||||
{ cidr: '192.168.12.34/32', end: '192.168.12.34', start: '192.168.12.34' }, // NOSONAR
|
||||
],
|
||||
error: '',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,49 +0,0 @@
|
||||
import type { IPMask } from 'ip-matching';
|
||||
import { getMatch } from 'ip-matching';
|
||||
import { excludeCidr } from 'cidr-tools';
|
||||
|
||||
function convertToCIDR(mask: IPMask) {
|
||||
const subnet = mask.convertToSubnet();
|
||||
if (!subnet) {
|
||||
return { cidr: mask.toString(), start: '', end: '' };
|
||||
}
|
||||
return {
|
||||
cidr: subnet.toString(),
|
||||
start: subnet.getFirst().toString(),
|
||||
end: subnet.getLast().toString(),
|
||||
};
|
||||
}
|
||||
|
||||
export function substractCIDRs(
|
||||
{ allowedRanges, disallowedRanges }:
|
||||
{
|
||||
allowedRanges: string
|
||||
disallowedRanges: string
|
||||
}) {
|
||||
try {
|
||||
const allowedRangesMatchMasks = allowedRanges.split(/\s*[,;|]+\s*/g) // NOSONAR
|
||||
.filter(range => range)
|
||||
.flatMap(range => getMatch(range)?.convertToMasks() || []);
|
||||
const disallowedRangesMatchMasks = disallowedRanges.split(/\s*[,;|]+\s*/g) // NOSONAR
|
||||
.filter(range => range)
|
||||
.flatMap(range => getMatch(range)?.convertToMasks() || []);
|
||||
|
||||
const allowedSubnets = allowedRangesMatchMasks.map(convertToCIDR);
|
||||
const disallowedSubnets = disallowedRangesMatchMasks.map(convertToCIDR);
|
||||
|
||||
return {
|
||||
error: '',
|
||||
allowedSubnets,
|
||||
disallowedSubnets,
|
||||
allowedCIDRs: excludeCidr(allowedSubnets.map(net => net.cidr), disallowedSubnets.map(net => net.cidr)),
|
||||
};
|
||||
}
|
||||
catch (e: any) {
|
||||
return {
|
||||
error: e.toString(),
|
||||
allowedSubnets: [],
|
||||
disallowedSubnets: [],
|
||||
allowedCIDRs: [],
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { useStorage } from '@vueuse/core';
|
||||
import { substractCIDRs } from './ip-include-exclude.service';
|
||||
import SpanCopyable from '@/components/SpanCopyable.vue';
|
||||
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
||||
|
||||
const allowedRanges = useStorage('ip-inc-exc:allow', '192.168.0.1/24'); // NOSONAR
|
||||
const disallowedRanges = useStorage('ip-inc-exc:disallow', '192.168.0.6'); // NOSONAR
|
||||
|
||||
const result = computed(() => substractCIDRs({
|
||||
allowedRanges: allowedRanges.value, disallowedRanges: disallowedRanges.value,
|
||||
}));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-input-text
|
||||
v-model:value="allowedRanges"
|
||||
label="AllowedIPs (IPv4/6 CIDR/Range/Mask/Wildcard)"
|
||||
placeholder="An IPv4/6 CIDR/Range/Mask/Wildcard..."
|
||||
mb-4
|
||||
/>
|
||||
|
||||
<c-input-text
|
||||
v-model:value="disallowedRanges"
|
||||
label="DisallowedIPs (IPv4/6 CIDR/Range/Mask/Wildcard)"
|
||||
placeholder="An IPv4/6 CIDR/Range/Mask/Wildcard..."
|
||||
mb-4
|
||||
/>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<c-alert v-if="result.error">
|
||||
{{ result.error }}
|
||||
</c-alert>
|
||||
|
||||
<div v-if="!result.error">
|
||||
<n-form-item label="Final AllowedIPs:">
|
||||
<TextareaCopyable :value="result.allowedCIDRs.join(', ')" />
|
||||
</n-form-item>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<c-card title="Allowed Subnets">
|
||||
<n-table>
|
||||
<tbody>
|
||||
<tr v-for="{ cidr, start, end } in result.allowedSubnets" :key="cidr">
|
||||
<td font-bold>
|
||||
<SpanCopyable :value="cidr" />
|
||||
</td>
|
||||
<td>
|
||||
<SpanCopyable :value="start" />
|
||||
</td>
|
||||
<td>
|
||||
<SpanCopyable :value="end" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</n-table>
|
||||
</c-card>
|
||||
<c-card title="Disallowed Subnets">
|
||||
<n-table>
|
||||
<tbody>
|
||||
<tr v-for="{ cidr, start, end } in result.disallowedSubnets" :key="cidr">
|
||||
<td font-bold>
|
||||
<SpanCopyable :value="cidr" />
|
||||
</td>
|
||||
<td>
|
||||
<SpanCopyable :value="start" />
|
||||
</td>
|
||||
<td>
|
||||
<SpanCopyable :value="end" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</n-table>
|
||||
</c-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -91,14 +91,41 @@ watch(
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
/**
|
||||
* Checks if the given HTMLElement overflows
|
||||
* copied from stackoverflow: https://stackoverflow.com/questions/143815/determine-if-an-html-elements-content-overflows
|
||||
* @param el The HTMLElement to check
|
||||
*/
|
||||
function checkOverflow(el: HTMLElement) {
|
||||
const curOverflow = el.style.overflow;
|
||||
if (!curOverflow || curOverflow === 'visible') {
|
||||
el.style.overflow = 'hidden';
|
||||
}
|
||||
|
||||
const isOverflowing = el.clientWidth < el.scrollWidth || el.clientHeight < el.scrollHeight;
|
||||
|
||||
el.style.overflow = curOverflow;
|
||||
|
||||
return isOverflowing;
|
||||
}
|
||||
|
||||
function resizeTextarea() {
|
||||
if (!textareaRef.value || !inputWrapperRef.value) {
|
||||
if (textareaRef.value === undefined) {
|
||||
return; // cannot chnge textarea if element is not available
|
||||
}
|
||||
|
||||
if (!multiline) {
|
||||
return; // textarea wont be displayed if multiline === false
|
||||
}
|
||||
|
||||
if (!checkOverflow(textareaRef.value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const scrollHeight = textareaRef.value.scrollHeight + 2;
|
||||
const textAreaElement = textareaRef.value!;
|
||||
|
||||
inputWrapperRef.value.style.height = `${scrollHeight}px`;
|
||||
const scrollHeight = textAreaElement.scrollHeight + 2;
|
||||
textAreaElement.style.height = `${scrollHeight}px`;
|
||||
}
|
||||
|
||||
const htmlInputType = computed(() => {
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import {
|
||||
import { presetScrollbar } from 'unocss-preset-scrollbar';
|
||||
|
||||
export default defineConfig({
|
||||
presets: [presetUno(), presetAttributify(), presetTypography(), presetScrollbar()],
|
||||
presets: [presetUno(), presetAttributify({ ignoreAttributes: ['size'] }), presetTypography(), presetScrollbar()],
|
||||
transformers: [transformerDirectives(), transformerVariantGroup()],
|
||||
theme: {
|
||||
colors: {
|
||||
|
||||
Reference in new issue
Block a user