aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2022-04-13 13:55:41 +0200
committerGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2022-04-13 13:55:41 +0200
commit7c540f1208da749c3932aab8f2c392048c4546ae (patch)
treee1e134387b5660297dd9cd4bc3325af4d0cdcab9 /src
parentafac5664c802c8480fe2c457bcfb7f5e26829cdf (diff)
downloadit-tools-7c540f1208da749c3932aab8f2c392048c4546ae.tar.gz
it-tools-7c540f1208da749c3932aab8f2c392048c4546ae.tar.zst
it-tools-7c540f1208da749c3932aab8f2c392048c4546ae.zip
feat(tool): random port generator
Diffstat (limited to 'src')
-rw-r--r--src/tools/index.ts3
-rw-r--r--src/tools/random-port-generator/index.ts11
-rw-r--r--src/tools/random-port-generator/random-port-generator.model.ts3
-rw-r--r--src/tools/random-port-generator/random-port-generator.vue31
4 files changed, 47 insertions, 1 deletions
diff --git a/src/tools/index.ts b/src/tools/index.ts
index 7cfa07e..7bf1348 100644
--- a/src/tools/index.ts
+++ b/src/tools/index.ts
@@ -11,6 +11,7 @@ import { tool as dateTimeConverter } from './date-time-converter';
import { tool as gitMemo } from './git-memo';
import { tool as baseConverter } from './integer-base-converter';
import { tool as urlEncoder } from './url-encoder';
+import { tool as randomPortGenerator } from './random-port-generator';
export const toolsByCategory: ToolCategory[] = [
{
@@ -31,7 +32,7 @@ export const toolsByCategory: ToolCategory[] = [
{
name: 'Development',
icon: LockOpen,
- components: [gitMemo],
+ components: [gitMemo, randomPortGenerator],
},
];
diff --git a/src/tools/random-port-generator/index.ts b/src/tools/random-port-generator/index.ts
new file mode 100644
index 0000000..63c24cb
--- /dev/null
+++ b/src/tools/random-port-generator/index.ts
@@ -0,0 +1,11 @@
+import { Server } from '@vicons/tabler';
+import type { ITool } from '../Tool';
+
+export const tool: ITool = {
+ name: 'Random port generator',
+ path: '/random-port-generator',
+ description: 'Generate random port numbers outside of the range of "known" ports (0-1023).',
+ keywords: ['system', 'port', 'lan', 'generator', 'random', 'developement', 'computer'],
+ component: () => import('./random-port-generator.vue'),
+ icon: Server,
+};
diff --git a/src/tools/random-port-generator/random-port-generator.model.ts b/src/tools/random-port-generator/random-port-generator.model.ts
new file mode 100644
index 0000000..b73871d
--- /dev/null
+++ b/src/tools/random-port-generator/random-port-generator.model.ts
@@ -0,0 +1,3 @@
+import { randIntFromInterval } from '@/utils/random';
+
+export const generatePort = () => randIntFromInterval(1024, 65535);
diff --git a/src/tools/random-port-generator/random-port-generator.vue b/src/tools/random-port-generator/random-port-generator.vue
new file mode 100644
index 0000000..5c94a63
--- /dev/null
+++ b/src/tools/random-port-generator/random-port-generator.vue
@@ -0,0 +1,31 @@
+<template>
+ <n-card>
+ <n-input :value="port" readonly style="text-align: center; font-family: monospace;" />
+ <br>
+ <br>
+ <n-space justify="center">
+ <n-button @click="copy" secondary>Copy</n-button>
+ <n-button @click="refreshPort" secondary>Refresh</n-button>
+ </n-space>
+ </n-card>
+</template>
+
+<script setup lang="ts">
+import { useCopy } from '@/composable/copy';
+import { ref } from 'vue'
+import { generatePort } from './random-port-generator.model'
+
+const port = ref('')
+
+const { copy } = useCopy({ source: port, text: 'Port copied to the clipboard' })
+
+function refreshPort() {
+ port.value = String(generatePort())
+}
+
+refreshPort()
+
+</script>
+
+<style lang="scss" scoped>
+</style> \ No newline at end of file