-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(new tool): OVH X-VR-SPAMCAUSE Decoder
- Loading branch information
Showing
5 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { RecordMail } from '@vicons/tabler'; | ||
import { defineTool } from '../tool'; | ||
|
||
export const tool = defineTool({ | ||
name: 'X vr spamcause decoder', | ||
path: '/x-vr-spamcause-decoder', | ||
description: 'Decode X-VR-SPAMCAUSE header in OVH mails', | ||
keywords: ['ovh', 'vade', 'retro', 'vr', 'spam', 'spamcause', 'decoder'], | ||
component: () => import('./x-vr-spamcause-decoder.vue'), | ||
icon: RecordMail, | ||
createdAt: new Date('2024-08-15'), | ||
}); |
10 changes: 10 additions & 0 deletions
10
src/tools/x-vr-spamcause-decoder/x-vr-spamcause-decoder.service.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { spamCauseDecode } from './x-vr-spamcause-decoder.service'; | ||
|
||
describe('x-vr-spamcause-decoder', () => { | ||
it('should decode X-VR-SPAMCAUSE', () => { | ||
expect(spamCauseDecode('gggruggvucftvghtrhhoucdtuddrfeelgedrvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfenuceurghilhhouhhtmecufedttdenucgohfhorhgsihguuggvnhfjughrucdlhedttddm')).toBe( | ||
'Vade Retro 01.394.21 AS+AV+AP+RT Profile: OVH; Bailout: 300; ^ForbiddenHdr (500)', | ||
); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
src/tools/x-vr-spamcause-decoder/x-vr-spamcause-decoder.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function unrot(a: string, b: string, pos: number) { | ||
if (b === undefined) { | ||
return ''; | ||
} | ||
|
||
if (pos % 2 === 0) { | ||
const c = a; | ||
a = b; | ||
b = c; | ||
} | ||
|
||
const offset = ('g'.charCodeAt(0) - a.charCodeAt(0)) * 16; | ||
return String.fromCharCode((a.charCodeAt(0) + b.charCodeAt(0)) - 'x'.charCodeAt(0) - offset); | ||
} | ||
|
||
export function spamCauseDecode(text: string) { | ||
let result = ''; | ||
|
||
for (let n = 0; n < text.length; n += 2) { | ||
result += unrot(text[n], text[n + 1], Math.floor(n / 2)); | ||
} | ||
|
||
return result; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/tools/x-vr-spamcause-decoder/x-vr-spamcause-decoder.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script setup lang="ts"> | ||
import { spamCauseDecode } from './x-vr-spamcause-decoder.service'; | ||
const encodedXVRSpamCause = ref(''); | ||
const decoded = computed(() => spamCauseDecode(encodedXVRSpamCause.value)); | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<c-input-text | ||
v-model:value="encodedXVRSpamCause" | ||
label="Encoded X-VR-SPAMCAUSE:" | ||
multiline | ||
rows="1" | ||
autosize | ||
placeholder="Your X-VR-SPAMCAUSE header value..." | ||
mb-6 | ||
/> | ||
|
||
<n-divider /> | ||
|
||
<textarea-copyable readonly label="Decoded" :value="decoded" /> | ||
</div> | ||
</template> |