mirror of
https://github.com/lissy93/networking-toolbox.git
synced 2026-11-24 23:00:22 +03:00
DNS tools for DKIM, DMARC, IDN, LOC, NAPTR, PRT, RP, SSHFP, SVCB, TLSA
This commit is contained in:
1 parent
f4533640d9
commit
294dd1b417
21 files changed
+6262
-6
No files matched your search
@@ -163,6 +163,12 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M112 449.9L112 528L176 528L176 488C176 474.7 186.7 464 200 464L240 464L240 424C240 410.7 250.7 400 264 400L318.1 400L347.3 370.8C353.2 364.9 361.8 362.5 369.9 364.4C379.5 366.7 389.6 368 400 368C470.7 368 528 310.7 528 240C528 169.3 470.7 112 400 112C329.3 112 272 169.3 272 240C272 250.4 273.2 260.5 275.6 270.1C277.6 278.2 275.2 286.8 269.2 292.7L112 449.9zM464 208C464 225.7 449.7 240 432 240C414.3 240 400 225.7 400 208C400 190.3 414.3 176 432 176C449.7 176 464 190.3 464 208z"/><path d="M272 240C272 169.3 329.3 112 400 112C470.7 112 528 169.3 528 240C528 310.7 470.7 368 400 368C389.6 368 379.5 366.8 369.9 364.4C361.8 362.4 353.2 364.9 347.3 370.8L318.1 400L264 400C250.7 400 240 410.7 240 424L240 464L200 464C186.7 464 176 474.7 176 488L176 528L112 528L112 449.9L269.2 292.7C275.1 286.8 277.5 278.2 275.6 270.1C273.3 260.5 272 250.4 272 240zM400 64C302.8 64 224 142.8 224 240C224 249.5 224.7 258.8 226.2 267.9L71 423C66.5 427.5 64 433.6 64 440L64 552C64 565.3 74.7 576 88 576L200 576C213.3 576 224 565.3 224 552L224 512L264 512C277.3 512 288 501.3 288 488L288 448L328 448C334.4 448 340.5 445.5 345 441L372.2 413.8C381.3 415.2 390.6 416 400.1 416C497.3 416 576.1 337.2 576.1 240C576.1 142.8 497.2 64 400 64zM432 240C449.7 240 464 225.7 464 208C464 190.3 449.7 176 432 176C414.3 176 400 190.3 400 208C400 225.7 414.3 240 432 240z"/></svg>
|
||||
{:else if name === 'dns-spf'}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M176 128L176 512C176 520.8 183.2 528 192 528L448 528C456.8 528 464 520.8 464 512L464 272L376 272C336.2 272 304 239.8 304 200L304 112L192 112C183.2 112 176 119.2 176 128zM208 168C208 154.7 218.7 144 232 144L248 144C261.3 144 272 154.7 272 168C272 181.3 261.3 192 248 192L232 192C218.7 192 208 181.3 208 168zM208 248C208 234.7 218.7 224 232 224L248 224C261.3 224 272 234.7 272 248C272 261.3 261.3 272 248 272L232 272C218.7 272 208 261.3 208 248zM213.3 441L273.4 365.9C280.4 357.1 291.1 352 302.3 352C318.7 352 333.1 362.7 337.8 378.4L353.9 432L408 432C421.3 432 432 442.7 432 456C432 469.3 421.3 480 408 480L336 480C325.4 480 316.1 473 313 462.9L297.8 412.2L250.7 471C242.4 481.4 227.3 483 217 474.8C206.7 466.6 205 451.4 213.3 441z"/><path d="M304 112L192 112C183.2 112 176 119.2 176 128L176 512C176 520.8 183.2 528 192 528L448 528C456.8 528 464 520.8 464 512L464 272L376 272C336.2 272 304 239.8 304 200L304 112zM444.1 224L352 131.9L352 200C352 213.3 362.7 224 376 224L444.1 224zM128 128C128 92.7 156.7 64 192 64L325.5 64C342.5 64 358.8 70.7 370.8 82.7L493.3 205.3C505.3 217.3 512 233.6 512 250.6L512 512C512 547.3 483.3 576 448 576L192 576C156.7 576 128 547.3 128 512L128 128zM273.3 365.9C280.3 357.1 291 352 302.2 352C318.6 352 333 362.7 337.7 378.4L353.8 432L407.9 432C421.2 432 431.9 442.7 431.9 456C431.9 469.3 421.2 480 407.9 480L335.9 480C325.3 480 316 473 312.9 462.9L297.7 412.2L250.6 471C242.3 481.4 227.2 483 216.9 474.8C206.6 466.6 205 451.4 213.3 441L273.4 365.9zM232 144L248 144C261.3 144 272 154.7 272 168C272 181.3 261.3 192 248 192L232 192C218.7 192 208 181.3 208 168C208 154.7 218.7 144 232 144zM232 224L248 224C261.3 224 272 234.7 272 248C272 261.3 261.3 272 248 272L232 272C218.7 272 208 261.3 208 248C208 234.7 218.7 224 232 224z"/></svg>
|
||||
{:else if name === 'dns-loc'}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M112 191.2L208 146L208 445L112 490.2L112 191.2zM234.6 91.1C236.4 91.1 238.2 91.3 240 91.9L418.1 151.3L416.5 152.1L244 93.4C240.9 92.4 237.8 91.6 234.6 91.1zM256 148.2L384 191.7L384 298.4C359.1 327.2 344 364.7 344 405.8C344 433.3 351.1 460.1 360.9 484.3L256 449.3L256 148.2zM432 198L528 150.6L528 240.7C522.7 240.2 517.4 240 512 240C483.1 240 455.9 247.2 432 260L432 198z"/><path d="M576 112C576 103.7 571.7 96 564.7 91.6C557.7 87.2 548.8 86.8 541.4 90.5L416.5 152.1L244 93.4C230.3 88.7 215.3 89.6 202.1 95.7L77.8 154.3C69.4 158.2 64 166.7 64 176L64 528C64 536.2 68.2 543.9 75.1 548.3C82 552.7 90.7 553.2 98.2 549.7L225.5 489.8L392.8 545.6C390.9 542.6 389 539.6 387.2 536.5C377.8 520.9 368.4 503.2 360.9 484.4L256 449.4L256 148.3L384 191.8L384 298.5C397.4 282.9 413.7 269.9 432 260.1L432 198.1L528 150.7L528 240.8C544.8 242.4 560.9 246.4 576 252.5L576 112zM208 146.1L208 445.1L112 490.3L112 191.3L208 146.1zM512 288C445.7 288 392 340.8 392 405.9C392 474.8 456.1 556.3 490.6 595.2C502.2 608.2 521.9 608.2 533.5 595.2C568 556.3 632.1 474.8 632.1 405.9C632.1 340.8 578.4 288 512.1 288zM472 408C472 385.9 489.9 368 512 368C534.1 368 552 385.9 552 408C552 430.1 534.1 448 512 448C489.9 448 472 430.1 472 408z"/></svg>
|
||||
{:else if name === 'dns-rp'}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M56.3 576C69.6 576 80.3 565.3 80.3 552L80.3 544C80.3 473.3 137.6 416 208.3 416L304.3 416C375 416 432.3 473.3 432.3 544L432.3 552C432.3 565.3 443 576 456.3 576L56.3 576zM336.3 192C336.3 236.2 300.5 272 256.3 272C212.1 272 176.3 236.2 176.3 192C176.3 147.8 212.1 112 256.3 112C300.5 112 336.3 147.8 336.3 192z"/><path d="M304.3 368C401.5 368 480.3 446.8 480.3 544L480.3 552C480.3 565.3 469.6 576 456.3 576C443 576 432.3 565.3 432.3 552L432.3 544C432.3 473.3 375 416 304.3 416L208.3 416C137.6 416 80.3 473.3 80.3 544L80.3 552C80.3 565.3 69.6 576 56.3 576C43 576 32.3 565.3 32.3 552L32.3 544C32.3 446.8 111.1 368 208.3 368L304.3 368zM585.7 169.9C593.5 159.2 608.5 156.8 619.2 164.6C629.9 172.4 632.3 187.4 624.5 198.1L522.1 338.9C517.9 344.6 511.4 348.2 504.4 348.7C497.4 349.2 490.4 346.5 485.5 341.4L439.1 293.4C429.9 283.9 430.1 268.7 439.7 259.5C449.2 250.3 464.4 250.6 473.6 260.1L500.1 287.5L585.7 169.8zM256.3 320C185.6 320 128.3 262.7 128.3 192C128.3 121.3 185.6 64 256.3 64C327 64 384.3 121.3 384.3 192C384.3 262.7 327 320 256.3 320zM256.3 112C212.1 112 176.3 147.8 176.3 192C176.3 236.2 212.1 272 256.3 272C300.5 272 336.3 236.2 336.3 192C336.3 147.8 300.5 112 256.3 112z"/></svg>
|
||||
{:else if name === 'dns-tlsa'}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M144 152L144 422.7C153.8 418.4 164.6 416 176 416L472 416C485.3 416 496 405.3 496 392L496 136C496 122.7 485.3 112 472 112L184 112C161.9 112 144 129.9 144 152zM440 264C440 330.3 386.3 384 320 384C253.7 384 200 330.3 200 264C200 197.7 253.7 144 320 144C386.3 144 440 197.7 440 264z"/><path d="M96 152C96 103.4 135.4 64 184 64L472 64C511.8 64 544 96.2 544 136L544 392C544 417 531.3 439 512 451.9L512 528L520 528C533.3 528 544 538.7 544 552C544 565.3 533.3 576 520 576L176 576C131.8 576 96 540.2 96 496L96 152zM144 496C144 513.7 158.3 528 176 528L464 528L464 464L176 464C158.3 464 144 478.3 144 496zM144 422.7C153.8 418.4 164.6 416 176 416L472 416C485.3 416 496 405.3 496 392L496 136C496 122.7 485.3 112 472 112L184 112C161.9 112 144 129.9 144 152L144 422.7zM398.4 280L371.5 280C370.2 299.7 366.5 317.7 361.1 332.7C380 321.3 393.9 302.4 398.4 280zM241.6 280C246.1 302.3 260 321.3 278.9 332.7C273.5 317.7 269.8 299.7 268.5 280L241.6 280zM312.3 329.7C315.5 336.6 318.2 340.3 320 342.3C321.8 340.4 324.5 336.7 327.7 329.7C333.3 317.6 337.8 300.4 339.3 280L300.5 280C302.1 300.4 306.5 317.6 312.1 329.7zM312.3 198.3C306.7 210.4 302.2 227.6 300.7 248L339.5 248C337.9 227.6 333.5 210.4 327.9 198.3C324.7 191.4 322 187.7 320.2 185.7C318.4 187.6 315.7 191.3 312.5 198.3zM398.4 248C393.9 225.7 380 206.7 361.1 195.3C366.5 210.3 370.2 228.3 371.5 248L398.4 248zM268.5 248C269.8 228.3 273.5 210.3 278.9 195.3C260 206.7 246.1 225.6 241.6 248L268.5 248zM200 264C200 197.7 253.7 144 320 144C386.3 144 440 197.7 440 264C440 330.3 386.3 384 320 384C253.7 384 200 330.3 200 264z"/></svg>
|
||||
{:else if name === 'alias'}
|
||||
<svg fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M7.5 5.6L10 7 8.6 4.5C8.2 3.85 7.4 3.85 7 4.5L5.6 7 8 5.6C8.65 5.2 8.65 4.4 7.5 5.6zM19.5 15.4L22 14 20.6 16.5C20.2 17.15 19.4 17.15 19 16.5L17.6 14 20 15.4C20.65 15.8 20.65 16.6 19.5 15.4zM22 2L2 22l1.41 1.41L22 4.41 22 2zM3.9 12.1L8 8l1.1 1.1L5.1 13.1 3.9 12.1zM12.1 20.1L16 16.1l1.1 1.1-3.9 3.9-1.1-1.1z"/>
|
||||
@@ -171,6 +177,10 @@
|
||||
<svg fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6-2.69-6-6-6zm0 10c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/>
|
||||
</svg>
|
||||
{:else if name === 'file'}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M176 128L176 512C176 520.8 183.2 528 192 528L448 528C456.8 528 464 520.8 464 512L464 272L376 272C336.2 272 304 239.8 304 200L304 112L192 112C183.2 112 176 119.2 176 128zM224 344C224 330.7 234.7 320 248 320L392 320C405.3 320 416 330.7 416 344C416 357.3 405.3 368 392 368L248 368C234.7 368 224 357.3 224 344zM224 440C224 426.7 234.7 416 248 416L392 416C405.3 416 416 426.7 416 440C416 453.3 405.3 464 392 464L248 464C234.7 464 224 453.3 224 440z"/><path d="M192 112L304 112L304 200C304 239.8 336.2 272 376 272L464 272L464 512C464 520.8 456.8 528 448 528L192 528C183.2 528 176 520.8 176 512L176 128C176 119.2 183.2 112 192 112zM352 131.9L444.1 224L376 224C362.7 224 352 213.3 352 200L352 131.9zM192 64C156.7 64 128 92.7 128 128L128 512C128 547.3 156.7 576 192 576L448 576C483.3 576 512 547.3 512 512L512 250.5C512 233.5 505.3 217.2 493.3 205.2L370.7 82.7C358.7 70.7 342.5 64 325.5 64L192 64zM248 320C234.7 320 224 330.7 224 344C224 357.3 234.7 368 248 368L392 368C405.3 368 416 357.3 416 344C416 330.7 405.3 320 392 320L248 320zM248 416C234.7 416 224 426.7 224 440C224 453.3 234.7 464 248 464L392 464C405.3 464 416 453.3 416 440C416 426.7 405.3 416 392 416L248 416z"/></svg>
|
||||
{:else if name === 'map-pin'}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><!--!Font Awesome Pro v7.0.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2025 Fonticons, Inc.--><path opacity=".4" d="M224 208C224 261 267 304 320 304C373 304 416 261 416 208C416 155 373 112 320 112C267 112 224 155 224 208z"/><path d="M224 208C224 155 267 112 320 112C373 112 416 155 416 208C416 261 373 304 320 304C267 304 224 261 224 208zM344 350C412.1 338.6 464 279.3 464 208C464 128.5 399.5 64 320 64C240.5 64 176 128.5 176 208C176 279.4 227.9 338.6 296 350L296 552C296 565.3 306.7 576 320 576C333.3 576 344 565.3 344 552L344 350z"/></svg>
|
||||
{:else if name === 'arrow-up-down'}
|
||||
<svg fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M7 14l5-5 5 5z"/>
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,679 @@
|
||||
<script>
|
||||
import Icon from '$lib/components/global/Icon.svelte';
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
|
||||
let domain = $state('');
|
||||
let latitude = $state('37.7749');
|
||||
let longitude = $state('-122.4194');
|
||||
let altitude = $state('10');
|
||||
let size = $state('1');
|
||||
let horizontalPrecision = $state('10000');
|
||||
let verticalPrecision = $state('10');
|
||||
|
||||
let locString = $state('');
|
||||
let parseMode = $state(false);
|
||||
let showExamples = $state(false);
|
||||
|
||||
let buttonStates = $state({});
|
||||
|
||||
const cityExamples = [
|
||||
{ name: 'San Francisco', lat: 37.7749, lng: -122.4194, alt: 10 },
|
||||
{ name: 'New York', lat: 40.7128, lng: -74.0060, alt: 10 },
|
||||
{ name: 'London', lat: 51.5074, lng: -0.1278, alt: 11 },
|
||||
{ name: 'Tokyo', lat: 35.6762, lng: 139.6503, alt: 40 },
|
||||
{ name: 'Sydney', lat: -33.8688, lng: 151.2093, alt: 58 }
|
||||
];
|
||||
|
||||
function degreesToLOC(degrees, isLongitude = false) {
|
||||
const hemisphere = isLongitude
|
||||
? (degrees >= 0 ? 'E' : 'W')
|
||||
: (degrees >= 0 ? 'N' : 'S');
|
||||
|
||||
const absDegrees = Math.abs(degrees);
|
||||
const deg = Math.floor(absDegrees);
|
||||
const minFloat = (absDegrees - deg) * 60;
|
||||
const min = Math.floor(minFloat);
|
||||
const sec = Math.round((minFloat - min) * 60 * 1000);
|
||||
|
||||
return `${deg.toString().padStart(isLongitude ? 3 : 2, '0')} ${min.toString().padStart(2, '0')} ${sec.toString().padStart(5, '0')}.000 ${hemisphere}`;
|
||||
}
|
||||
|
||||
function altitudeToLOC(altMeters) {
|
||||
const altCm = Math.round((altMeters + 100000) * 100);
|
||||
return altCm.toString().padStart(8, '0');
|
||||
}
|
||||
|
||||
function sizeToLOC(sizeMeters) {
|
||||
if (sizeMeters === 0) return '00';
|
||||
|
||||
let mantissa = 0;
|
||||
let exponent = 0;
|
||||
let value = sizeMeters * 100; // Convert to centimeters
|
||||
|
||||
while (value >= 10) {
|
||||
value /= 10;
|
||||
exponent++;
|
||||
}
|
||||
|
||||
mantissa = Math.round(value);
|
||||
if (mantissa >= 10) {
|
||||
mantissa = Math.round(mantissa / 10);
|
||||
exponent++;
|
||||
}
|
||||
|
||||
return (mantissa * 16 + exponent).toString(16).padStart(2, '0');
|
||||
}
|
||||
|
||||
let locRecord = $derived.by(() => {
|
||||
if (parseMode) {
|
||||
return parseLocString();
|
||||
} else {
|
||||
return generateLocRecord();
|
||||
}
|
||||
});
|
||||
|
||||
function generateLocRecord() {
|
||||
if (!domain.trim()) return '';
|
||||
|
||||
const latLoc = degreesToLOC(parseFloat(latitude));
|
||||
const lngLoc = degreesToLOC(parseFloat(longitude), true);
|
||||
const altLoc = altitudeToLOC(parseFloat(altitude));
|
||||
const sizeLoc = sizeToLOC(parseFloat(size));
|
||||
const hpLoc = sizeToLOC(parseFloat(horizontalPrecision));
|
||||
const vpLoc = sizeToLOC(parseFloat(verticalPrecision));
|
||||
|
||||
return `${domain.trim()}. IN LOC ${latLoc} ${lngLoc} ${altLoc}m ${sizeLoc} ${hpLoc} ${vpLoc}`;
|
||||
}
|
||||
|
||||
function parseLocString() {
|
||||
if (!locString.trim()) return '';
|
||||
return `Parsed: ${locString}`;
|
||||
}
|
||||
|
||||
function locToData(locRecord) {
|
||||
// Simplified parsing for demo
|
||||
const parts = locRecord.split(' ');
|
||||
if (parts.length < 8) return null;
|
||||
|
||||
return {
|
||||
lat: 'Parsed latitude',
|
||||
lng: 'Parsed longitude',
|
||||
alt: 'Parsed altitude',
|
||||
size: 'Parsed size'
|
||||
};
|
||||
}
|
||||
|
||||
let isValid = $derived.by(() => {
|
||||
if (parseMode) {
|
||||
return locString.trim() !== '';
|
||||
} else {
|
||||
return domain.trim() !== '' &&
|
||||
!isNaN(parseFloat(latitude)) &&
|
||||
!isNaN(parseFloat(longitude)) &&
|
||||
!isNaN(parseFloat(altitude));
|
||||
}
|
||||
});
|
||||
|
||||
function showButtonSuccess(buttonId) {
|
||||
buttonStates[buttonId] = true;
|
||||
setTimeout(() => {
|
||||
buttonStates[buttonId] = false;
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
function copyToClipboard() {
|
||||
navigator.clipboard.writeText(locRecord);
|
||||
showButtonSuccess('copy');
|
||||
}
|
||||
|
||||
function downloadRecord() {
|
||||
const blob = new Blob([locRecord], { type: 'text/plain' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `${domain.replace(/\.$/, '') || 'loc'}-record.txt`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
showButtonSuccess('download');
|
||||
}
|
||||
|
||||
function loadCity(city) {
|
||||
latitude = city.lat.toString();
|
||||
longitude = city.lng.toString();
|
||||
altitude = city.alt.toString();
|
||||
parseMode = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h1>LOC Record Builder</h1>
|
||||
<p>Convert latitude/longitude coordinates ↔ DNS LOC records for geographic positioning</p>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<!-- Mode Toggle -->
|
||||
<div class="mode-toggle">
|
||||
<button
|
||||
class="mode-btn"
|
||||
class:active={!parseMode}
|
||||
onclick={() => parseMode = false}
|
||||
>
|
||||
<Icon name="map-pin" size="sm" />
|
||||
Coordinates → LOC
|
||||
</button>
|
||||
<button
|
||||
class="mode-btn"
|
||||
class:active={parseMode}
|
||||
onclick={() => parseMode = true}
|
||||
>
|
||||
<Icon name="file" size="sm" />
|
||||
LOC → Coordinates
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Examples -->
|
||||
<div class="examples-card">
|
||||
<details bind:open={showExamples}>
|
||||
<summary class="examples-summary">
|
||||
<Icon name="lightbulb" size="sm" />
|
||||
City Examples
|
||||
<Icon name="chevron-down" size="sm" />
|
||||
</summary>
|
||||
<div class="examples-grid">
|
||||
{#each cityExamples as city}
|
||||
<button class="example-btn" onclick={() => loadCity(city)}>
|
||||
{city.name}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
<div class="main-grid">
|
||||
<!-- Input Form -->
|
||||
<div class="input-section card">
|
||||
<div class="input-group">
|
||||
<label for="domain" use:tooltip={"Domain name for the LOC record"}>Domain Name *</label>
|
||||
<input
|
||||
id="domain"
|
||||
type="text"
|
||||
bind:value={domain}
|
||||
placeholder="example.com"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{#if parseMode}
|
||||
<div class="input-group">
|
||||
<label for="locString" use:tooltip={"Paste existing LOC record to parse"}>LOC Record String</label>
|
||||
<textarea
|
||||
id="locString"
|
||||
bind:value={locString}
|
||||
placeholder="example.com. IN LOC 37 46 29.000 N 122 25 10.000 W 10.00m 1m 10000m 10m"
|
||||
rows="3"
|
||||
></textarea>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="coord-grid">
|
||||
<div class="input-group">
|
||||
<label for="latitude" use:tooltip={"Latitude in decimal degrees (-90 to 90)"}>Latitude *</label>
|
||||
<input
|
||||
id="latitude"
|
||||
type="number"
|
||||
bind:value={latitude}
|
||||
step="0.000001"
|
||||
min="-90"
|
||||
max="90"
|
||||
placeholder="37.7749"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="longitude" use:tooltip={"Longitude in decimal degrees (-180 to 180)"}>Longitude *</label>
|
||||
<input
|
||||
id="longitude"
|
||||
type="number"
|
||||
bind:value={longitude}
|
||||
step="0.000001"
|
||||
min="-180"
|
||||
max="180"
|
||||
placeholder="-122.4194"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="altitude" use:tooltip={"Altitude in meters above sea level"}>Altitude (m) *</label>
|
||||
<input
|
||||
id="altitude"
|
||||
type="number"
|
||||
bind:value={altitude}
|
||||
step="0.1"
|
||||
placeholder="10"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="precision-grid">
|
||||
<div class="input-group">
|
||||
<label for="size" use:tooltip={"Size/diameter of the location in meters"}>Size (m)</label>
|
||||
<input
|
||||
id="size"
|
||||
type="number"
|
||||
bind:value={size}
|
||||
step="0.1"
|
||||
min="0"
|
||||
placeholder="1"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="horizontalPrecision" use:tooltip={"Horizontal precision in meters"}>H. Precision (m)</label>
|
||||
<input
|
||||
id="horizontalPrecision"
|
||||
type="number"
|
||||
bind:value={horizontalPrecision}
|
||||
step="1"
|
||||
min="0"
|
||||
placeholder="10000"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="verticalPrecision" use:tooltip={"Vertical precision in meters"}>V. Precision (m)</label>
|
||||
<input
|
||||
id="verticalPrecision"
|
||||
type="number"
|
||||
bind:value={verticalPrecision}
|
||||
step="0.1"
|
||||
min="0"
|
||||
placeholder="10"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Output -->
|
||||
<div class="output-section">
|
||||
<div class="card">
|
||||
<h3 class="section-title">
|
||||
{parseMode ? 'Parsed Coordinates' : 'Generated LOC Record'}
|
||||
</h3>
|
||||
<div class="code-block">
|
||||
{#if isValid}
|
||||
<code>{locRecord}</code>
|
||||
{:else}
|
||||
<p class="placeholder">Fill in the required fields to generate the LOC record</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if isValid}
|
||||
<div class="actions">
|
||||
<button
|
||||
onclick={copyToClipboard}
|
||||
class="btn btn-primary"
|
||||
class:success={buttonStates.copy}
|
||||
>
|
||||
<Icon name={buttonStates.copy ? "check" : "copy"} size="sm" />
|
||||
{buttonStates.copy ? 'Copied!' : 'Copy Record'}
|
||||
</button>
|
||||
<button
|
||||
onclick={downloadRecord}
|
||||
class="btn btn-success"
|
||||
class:success={buttonStates.download}
|
||||
>
|
||||
<Icon name={buttonStates.download ? "check" : "download"} size="sm" />
|
||||
{buttonStates.download ? 'Downloaded!' : 'Download'}
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Information Section -->
|
||||
<div class="info-section">
|
||||
<div class="card info-card">
|
||||
<h3>About LOC Records</h3>
|
||||
<p>
|
||||
LOC (Location) records store geographic location information in DNS. They specify latitude, longitude, altitude, and precision values, allowing applications to discover the physical location associated with a domain name.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="info-grid">
|
||||
<div class="card info-card">
|
||||
<h4>Record Format</h4>
|
||||
<ul class="format-list">
|
||||
<li><strong>Latitude/Longitude:</strong> Degrees, minutes, seconds</li>
|
||||
<li><strong>Altitude:</strong> Meters above/below sea level</li>
|
||||
<li><strong>Size:</strong> Diameter of the location sphere</li>
|
||||
<li><strong>Precision:</strong> Horizontal and vertical accuracy</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="card info-card">
|
||||
<h4>Use Cases</h4>
|
||||
<ul class="use-case-list">
|
||||
<li>Geographic service discovery</li>
|
||||
<li>Network topology mapping</li>
|
||||
<li>Emergency services location</li>
|
||||
<li>Content delivery optimization</li>
|
||||
<li>Legal jurisdiction identification</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.card {
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.mode-toggle {
|
||||
display: inline-flex;
|
||||
width: fit-content;
|
||||
background: var(--bg-tertiary);
|
||||
padding: var(--spacing-xs);
|
||||
border-radius: var(--radius-md);
|
||||
gap: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.mode-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
padding: var(--spacing-sm) var(--spacing-md);
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-secondary);
|
||||
transition: all var(--transition-fast);
|
||||
}
|
||||
|
||||
.mode-btn.active {
|
||||
background: var(--color-primary);
|
||||
color: var(--bg-primary);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
.mode-btn:not(.active):hover {
|
||||
background: var(--surface-hover);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.examples-card {
|
||||
padding: var(--spacing-md);
|
||||
}
|
||||
|
||||
.examples-summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
cursor: pointer;
|
||||
color: var(--text-primary);
|
||||
font-weight: 600;
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.examples-summary:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.chevron {
|
||||
margin-left: auto;
|
||||
transform: rotate(0deg);
|
||||
transition: transform var(--transition-normal);
|
||||
}
|
||||
|
||||
details[open] .chevron {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.examples-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
||||
margin-top: var(--spacing-md);
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.example-btn {
|
||||
padding: var(--spacing-sm) var(--spacing-md);
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid var(--color-primary);
|
||||
color: var(--text-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
font-size: var(--font-size-sm);
|
||||
transition: all var(--transition-fast);
|
||||
&:hover {
|
||||
background: var(--bg-primary);
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.main-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: var(--spacing-lg);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.main-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.input-section, .output-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
.input-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.input-group label {
|
||||
color: var(--text-primary);
|
||||
font-size: var(--font-size-sm);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.input-group input, .input-group textarea {
|
||||
padding: var(--spacing-sm);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.input-group input:focus, .input-group textarea:focus {
|
||||
outline: none;
|
||||
border-color: var(--color-primary);
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 20%, transparent);
|
||||
}
|
||||
|
||||
.input-group textarea {
|
||||
resize: vertical;
|
||||
min-height: 80px;
|
||||
}
|
||||
|
||||
.coord-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
.precision-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
color: var(--text-primary);
|
||||
font-size: var(--font-size-lg);
|
||||
margin: 0 0 var(--spacing-md) 0;
|
||||
}
|
||||
|
||||
.code-block {
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
padding: var(--spacing-md);
|
||||
}
|
||||
|
||||
.code-block code {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-primary);
|
||||
word-break: break-all;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.code-block .placeholder {
|
||||
color: var(--text-secondary);
|
||||
font-style: italic;
|
||||
font-size: var(--font-size-sm);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
padding: var(--spacing-sm) var(--spacing-md);
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
font-size: var(--font-size-sm);
|
||||
transition: all var(--transition-normal);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--color-primary);
|
||||
color: var(--bg-primary);
|
||||
}
|
||||
|
||||
.btn-primary:hover:not(.success) {
|
||||
background: var(--color-primary-hover);
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
background: var(--color-success);
|
||||
color: var(--bg-primary);
|
||||
}
|
||||
|
||||
.btn-success:hover:not(.success) {
|
||||
background: var(--color-success-light);
|
||||
}
|
||||
|
||||
.btn.success {
|
||||
background: var(--color-success) !important;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.info-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-md);
|
||||
margin-top: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.info-card {
|
||||
padding: var(--spacing-md);
|
||||
flex-direction: column;
|
||||
align-items: normal;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.info-card h3, .info-card h4 {
|
||||
color: var(--text-primary);
|
||||
font-size: var(--font-size-md);
|
||||
margin: 0 0 var(--spacing-sm) 0;
|
||||
}
|
||||
|
||||
.info-card p {
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--font-size-sm);
|
||||
line-height: 1.5;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.info-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.format-list, .use-case-list {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.format-list li, .use-case-list li {
|
||||
position: relative;
|
||||
padding-left: var(--spacing-md);
|
||||
margin-bottom: var(--spacing-xs);
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.format-list li::before, .use-case-list li::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0.5em;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
background: var(--color-primary);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.format-list strong {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,745 @@
|
||||
<script>
|
||||
import Icon from '$lib/components/global/Icon.svelte';
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
|
||||
let domain = $state('');
|
||||
let order = $state('100');
|
||||
let preference = $state('10');
|
||||
let flags = $state('U');
|
||||
let service = $state('E2U+sip');
|
||||
let regexp = $state('!^.*$!sip:info@example.com!');
|
||||
let replacement = $state('.');
|
||||
|
||||
let buttonStates = $state({});
|
||||
let showExamples = $state(false);
|
||||
|
||||
const flagOptions = [
|
||||
{ value: 'U', label: 'U - Terminal rule (URI)', description: 'The Rule is terminal and the result is a URI' },
|
||||
{ value: 'S', label: 'S - Terminal rule (SRV)', description: 'The Rule is terminal and the result is for SRV lookup' },
|
||||
{ value: 'A', label: 'A - Terminal rule (Address)', description: 'The Rule is terminal and the result is an address record' },
|
||||
{ value: 'P', label: 'P - Protocol specific', description: 'Protocol-specific flags' },
|
||||
{ value: '', label: 'Empty - Non-terminal', description: 'The Rule is not terminal (continue processing)' }
|
||||
];
|
||||
|
||||
const serviceExamples = [
|
||||
{ value: 'E2U+sip', label: 'SIP Service', description: 'Session Initiation Protocol' },
|
||||
{ value: 'E2U+email', label: 'Email Service', description: 'Electronic mail service' },
|
||||
{ value: 'E2U+web+http', label: 'HTTP Web Service', description: 'Web service over HTTP' },
|
||||
{ value: 'E2U+web+https', label: 'HTTPS Web Service', description: 'Secure web service over HTTPS' },
|
||||
{ value: 'E2U+tel', label: 'Telephone Service', description: 'Telephone number mapping' },
|
||||
{ value: 'E2U+fax', label: 'Fax Service', description: 'Facsimile service' },
|
||||
{ value: 'E2U+h323', label: 'H.323 Service', description: 'H.323 multimedia protocol' },
|
||||
{ value: 'E2U+im', label: 'Instant Messaging', description: 'Instant messaging service' }
|
||||
];
|
||||
|
||||
let naptrRecord = $derived.by(() => {
|
||||
if (!domain.trim()) return '';
|
||||
|
||||
const cleanDomain = domain.trim().replace(/\.$/, '');
|
||||
return `${cleanDomain}. IN NAPTR ${order} ${preference} "${flags}" "${service}" "${regexp}" ${replacement}`;
|
||||
});
|
||||
|
||||
let isValid = $derived.by(() => {
|
||||
return domain.trim() !== '' &&
|
||||
order !== '' &&
|
||||
preference !== '' &&
|
||||
parseInt(order) >= 0 && parseInt(order) <= 65535 &&
|
||||
parseInt(preference) >= 0 && parseInt(preference) <= 65535;
|
||||
});
|
||||
|
||||
let warnings = $derived.by(() => {
|
||||
const warns = [];
|
||||
|
||||
if (flags === 'U' && !regexp.includes('!')) {
|
||||
warns.push('URI flag requires a valid substitution expression with delimiters');
|
||||
}
|
||||
|
||||
if (flags === 'S' && replacement === '.') {
|
||||
warns.push('SRV flag typically requires a replacement domain, not "."');
|
||||
}
|
||||
|
||||
if (flags === '' && replacement === '.') {
|
||||
warns.push('Non-terminal rules should have a replacement domain for continued processing');
|
||||
}
|
||||
|
||||
if (regexp && !regexp.match(/^!.*!.*!$/)) {
|
||||
warns.push('Regular expressions should follow the format: !pattern!replacement!');
|
||||
}
|
||||
|
||||
if (parseInt(order) === parseInt(preference)) {
|
||||
warns.push('Order and Preference should typically be different values');
|
||||
}
|
||||
|
||||
return warns;
|
||||
});
|
||||
|
||||
/**
|
||||
* @param {string} buttonId
|
||||
*/
|
||||
function showButtonSuccess(buttonId) {
|
||||
buttonStates[buttonId] = true;
|
||||
setTimeout(() => {
|
||||
buttonStates[buttonId] = false;
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
function copyToClipboard() {
|
||||
navigator.clipboard.writeText(naptrRecord);
|
||||
showButtonSuccess('copy');
|
||||
}
|
||||
|
||||
function downloadRecord() {
|
||||
const blob = new Blob([naptrRecord], { type: 'text/plain' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `${domain.replace(/\.$/, '') || 'naptr'}-record.txt`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
showButtonSuccess('download');
|
||||
}
|
||||
|
||||
function loadExample(exampleType) {
|
||||
switch (exampleType) {
|
||||
case 'sip':
|
||||
domain = 'example.com';
|
||||
order = '100';
|
||||
preference = '10';
|
||||
flags = 'U';
|
||||
service = 'E2U+sip';
|
||||
regexp = '!^.*$!sip:info@example.com!';
|
||||
replacement = '.';
|
||||
break;
|
||||
case 'email':
|
||||
domain = 'example.com';
|
||||
order = '100';
|
||||
preference = '10';
|
||||
flags = 'U';
|
||||
service = 'E2U+email';
|
||||
regexp = '!^.*$!mailto:admin@example.com!';
|
||||
replacement = '.';
|
||||
break;
|
||||
case 'web':
|
||||
domain = 'example.com';
|
||||
order = '100';
|
||||
preference = '10';
|
||||
flags = 'U';
|
||||
service = 'E2U+web+https';
|
||||
regexp = '!^.*$!https://www.example.com/!';
|
||||
replacement = '.';
|
||||
break;
|
||||
case 'srv':
|
||||
domain = 'example.com';
|
||||
order = '100';
|
||||
preference = '10';
|
||||
flags = 'S';
|
||||
service = 'SIP+D2T';
|
||||
regexp = '';
|
||||
replacement = '_sip._tcp.example.com.';
|
||||
break;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h1>NAPTR Record Builder</h1>
|
||||
<p>Construct NAPTR (Naming Authority Pointer) records for dynamic delegation and service mapping</p>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<!-- Examples -->
|
||||
<div class="card examples-card">
|
||||
<details bind:open={showExamples}>
|
||||
<summary class="examples-summary">
|
||||
<Icon name="lightbulb" size="sm" />
|
||||
Quick Examples
|
||||
<Icon name="chevron-down" size="sm" class="chevron" />
|
||||
</summary>
|
||||
<div class="examples-grid">
|
||||
<button class="example-btn" onclick={() => loadExample('sip')}>
|
||||
SIP Service
|
||||
</button>
|
||||
<button class="example-btn" onclick={() => loadExample('email')}>
|
||||
Email Service
|
||||
</button>
|
||||
<button class="example-btn" onclick={() => loadExample('web')}>
|
||||
Web Service
|
||||
</button>
|
||||
<button class="example-btn" onclick={() => loadExample('srv')}>
|
||||
SRV Delegation
|
||||
</button>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
<div class="main-grid">
|
||||
<!-- Input Form -->
|
||||
<div class="input-section">
|
||||
<div class="input-group">
|
||||
<label for="domain" use:tooltip={"The domain name for this NAPTR record"}>Domain Name *</label>
|
||||
<input
|
||||
id="domain"
|
||||
type="text"
|
||||
bind:value={domain}
|
||||
placeholder="example.com"
|
||||
/>
|
||||
<p class="description">The domain name for this NAPTR record</p>
|
||||
</div>
|
||||
|
||||
<div class="order-grid">
|
||||
<div class="input-group">
|
||||
<label for="order" use:tooltip={"Processing order - lower values are processed first (0-65535)"}>Order *</label>
|
||||
<input
|
||||
id="order"
|
||||
type="number"
|
||||
bind:value={order}
|
||||
min="0"
|
||||
max="65535"
|
||||
/>
|
||||
<p class="description">Processing order (0-65535)</p>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="preference" use:tooltip={"Preference within the same order value (0-65535)"}>Preference *</label>
|
||||
<input
|
||||
id="preference"
|
||||
type="number"
|
||||
bind:value={preference}
|
||||
min="0"
|
||||
max="65535"
|
||||
/>
|
||||
<p class="description">Preference within order (0-65535)</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="flags" use:tooltip={"Control processing behavior - affects how the result is interpreted"}>Flags</label>
|
||||
<select id="flags" bind:value={flags}>
|
||||
{#each flagOptions as option}
|
||||
<option value={option.value}>{option.label}</option>
|
||||
{/each}
|
||||
</select>
|
||||
<p class="description">
|
||||
{flagOptions.find(opt => opt.value === flags)?.description || 'Select flag type'}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="service" use:tooltip={"Service identifier or protocol (e.g., E2U+sip for SIP services)"}>Service</label>
|
||||
<input
|
||||
id="service"
|
||||
type="text"
|
||||
bind:value={service}
|
||||
placeholder="E2U+sip"
|
||||
/>
|
||||
<details class="service-examples">
|
||||
<summary>Show service examples</summary>
|
||||
<div class="service-list">
|
||||
{#each serviceExamples as example}
|
||||
<button
|
||||
class="service-item"
|
||||
onclick={() => service = example.value}
|
||||
>
|
||||
<strong>{example.value}</strong> - {example.description}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="regexp" use:tooltip={"Regular expression for pattern matching and substitution (format: !pattern!replacement!)"}>Regular Expression</label>
|
||||
<input
|
||||
id="regexp"
|
||||
type="text"
|
||||
bind:value={regexp}
|
||||
placeholder="!^.*$!sip:info@example.com!"
|
||||
class="mono"
|
||||
/>
|
||||
<p class="description">
|
||||
Substitution expression (format: !pattern!replacement!)
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="replacement" use:tooltip={"Next domain to query, or '.' for terminal rules"}>Replacement</label>
|
||||
<input
|
||||
id="replacement"
|
||||
type="text"
|
||||
bind:value={replacement}
|
||||
placeholder="."
|
||||
/>
|
||||
<p class="description">
|
||||
Domain name for next lookup, or "." for terminal rules
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Output -->
|
||||
<div class="output-section">
|
||||
<div class="card">
|
||||
<h3 class="section-title">Generated NAPTR Record</h3>
|
||||
<div class="code-block">
|
||||
{#if isValid}
|
||||
<code>{naptrRecord}</code>
|
||||
{:else}
|
||||
<p class="placeholder">Fill in the required fields to generate the NAPTR record</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if warnings.length > 0}
|
||||
<div class="message warning">
|
||||
<Icon name="alert-triangle" size="sm" />
|
||||
<div>
|
||||
<h4>Configuration Warnings</h4>
|
||||
<ul>
|
||||
{#each warnings as warning}
|
||||
<li>{warning}</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if isValid}
|
||||
<div class="actions">
|
||||
<button
|
||||
onclick={copyToClipboard}
|
||||
class="btn btn-primary"
|
||||
class:success={buttonStates.copy}
|
||||
>
|
||||
<Icon name={buttonStates.copy ? "check" : "copy"} size="sm" />
|
||||
{buttonStates.copy ? 'Copied!' : 'Copy Record'}
|
||||
</button>
|
||||
<button
|
||||
onclick={downloadRecord}
|
||||
class="btn btn-success"
|
||||
class:success={buttonStates.download}
|
||||
>
|
||||
<Icon name={buttonStates.download ? "check" : "download"} size="sm" />
|
||||
{buttonStates.download ? 'Downloaded!' : 'Download'}
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Information Section -->
|
||||
<div class="info-section">
|
||||
<div class="card info-card">
|
||||
<h3 class="section-title">About NAPTR Records</h3>
|
||||
<p>
|
||||
NAPTR (Naming Authority Pointer) records provide a way to map domain names to URIs or other domain names through regular expression-based rewriting. They're commonly used in telecommunications for ENUM (E.164 Number Mapping) and SIP services, allowing dynamic delegation and service discovery.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="info-grid">
|
||||
<div class="card info-card">
|
||||
<h4>Field Descriptions</h4>
|
||||
<dl class="field-list">
|
||||
<dt>Order:</dt>
|
||||
<dd>Processing order (lower values first)</dd>
|
||||
<dt>Preference:</dt>
|
||||
<dd>Preference within same order</dd>
|
||||
<dt>Flags:</dt>
|
||||
<dd>Control processing behavior</dd>
|
||||
<dt>Service:</dt>
|
||||
<dd>Service identifier or protocol</dd>
|
||||
<dt>RegExp:</dt>
|
||||
<dd>Pattern matching and substitution</dd>
|
||||
<dt>Replacement:</dt>
|
||||
<dd>Next domain to query</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div class="card info-card">
|
||||
<h4>Common Use Cases</h4>
|
||||
<ul class="use-case-list">
|
||||
<li>ENUM telephone number mapping</li>
|
||||
<li>SIP service discovery</li>
|
||||
<li>Dynamic delegation</li>
|
||||
<li>Protocol mapping</li>
|
||||
<li>Service location</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.card {
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
padding: var(--spacing-lg);
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
}
|
||||
|
||||
.card-header h1 {
|
||||
color: var(--text-primary);
|
||||
font-size: var(--font-size-2xl);
|
||||
margin: 0 0 var(--spacing-sm) 0;
|
||||
}
|
||||
|
||||
.card-header p {
|
||||
color: var(--text-secondary);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: var(--spacing-lg);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.examples-card {
|
||||
padding: var(--spacing-md);
|
||||
}
|
||||
|
||||
.examples-summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
cursor: pointer;
|
||||
color: var(--text-primary);
|
||||
font-weight: 600;
|
||||
font-size: var(--font-size-lg);
|
||||
margin-bottom: var(--spacing-md);
|
||||
}
|
||||
|
||||
.examples-summary:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.chevron {
|
||||
margin-left: auto;
|
||||
transform: rotate(0deg);
|
||||
transition: transform var(--transition-normal);
|
||||
}
|
||||
|
||||
details[open] .chevron {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
color: var(--text-primary);
|
||||
font-size: var(--font-size-lg);
|
||||
margin: 0 0 var(--spacing-md) 0;
|
||||
}
|
||||
|
||||
.examples-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.example-btn {
|
||||
padding: var(--spacing-sm) var(--spacing-md);
|
||||
background: var(--color-primary);
|
||||
color: var(--bg-primary);
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
font-size: var(--font-size-sm);
|
||||
transition: all var(--transition-fast);
|
||||
}
|
||||
|
||||
.example-btn:hover {
|
||||
background: var(--color-primary-hover);
|
||||
}
|
||||
|
||||
.main-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: var(--spacing-lg);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.main-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.input-section, .output-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
.input-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.input-group label {
|
||||
color: var(--text-primary);
|
||||
font-size: var(--font-size-sm);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.input-group input, .input-group select {
|
||||
padding: var(--spacing-sm);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.input-group input:focus, .input-group select:focus {
|
||||
outline: none;
|
||||
border-color: var(--color-primary);
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 20%, transparent);
|
||||
}
|
||||
|
||||
.input-group input.mono {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.description {
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--text-secondary);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.order-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
.service-examples {
|
||||
margin-top: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.service-examples summary {
|
||||
color: var(--color-primary);
|
||||
cursor: pointer;
|
||||
font-size: var(--font-size-xs);
|
||||
transition: color var(--transition-fast);
|
||||
}
|
||||
|
||||
.service-examples summary:hover {
|
||||
color: var(--color-primary-hover);
|
||||
}
|
||||
|
||||
.service-list {
|
||||
margin-top: var(--spacing-sm);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.service-item {
|
||||
padding: var(--spacing-xs) var(--spacing-sm);
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--text-secondary);
|
||||
transition: all var(--transition-fast);
|
||||
}
|
||||
|
||||
.service-item:hover {
|
||||
background: var(--surface-hover);
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
|
||||
.service-item strong {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.code-block {
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
padding: var(--spacing-md);
|
||||
}
|
||||
|
||||
.code-block code {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-primary);
|
||||
word-break: break-all;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.code-block .placeholder {
|
||||
color: var(--text-secondary);
|
||||
font-style: italic;
|
||||
font-size: var(--font-size-sm);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.message {
|
||||
display: flex;
|
||||
gap: var(--spacing-xs);
|
||||
padding: var(--spacing-sm);
|
||||
border-radius: var(--radius-md);
|
||||
margin-bottom: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.message.warning {
|
||||
background: color-mix(in srgb, var(--color-warning) 10%, transparent);
|
||||
border: 1px solid color-mix(in srgb, var(--color-warning) 30%, transparent);
|
||||
color: var(--color-warning);
|
||||
}
|
||||
|
||||
.message h4 {
|
||||
margin: 0 0 var(--spacing-xs) 0;
|
||||
font-size: var(--font-size-sm);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.message ul {
|
||||
margin: 0;
|
||||
padding-left: var(--spacing-md);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.message li {
|
||||
margin-bottom: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
padding: var(--spacing-sm) var(--spacing-md);
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
font-size: var(--font-size-sm);
|
||||
transition: all var(--transition-normal);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--color-primary);
|
||||
color: var(--bg-primary);
|
||||
}
|
||||
|
||||
.btn-primary:hover:not(.success) {
|
||||
background: var(--color-primary-hover);
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
background: var(--color-success);
|
||||
color: var(--bg-primary);
|
||||
}
|
||||
|
||||
.btn-success:hover:not(.success) {
|
||||
background: var(--color-success-light);
|
||||
}
|
||||
|
||||
.btn.success {
|
||||
background: var(--color-success) !important;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.info-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-md);
|
||||
margin-top: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.info-card {
|
||||
padding: var(--spacing-md);
|
||||
}
|
||||
|
||||
.info-card h3, .info-card h4 {
|
||||
color: var(--text-primary);
|
||||
font-size: var(--font-size-md);
|
||||
margin: 0 0 var(--spacing-sm) 0;
|
||||
}
|
||||
|
||||
.info-card p {
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--font-size-sm);
|
||||
line-height: 1.5;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.info-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.field-list {
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.field-list dt {
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
margin-bottom: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.field-list dd {
|
||||
color: var(--text-secondary);
|
||||
margin: 0 0 var(--spacing-sm) var(--spacing-md);
|
||||
}
|
||||
|
||||
.use-case-list {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.use-case-list li {
|
||||
position: relative;
|
||||
padding-left: var(--spacing-md);
|
||||
margin-bottom: var(--spacing-xs);
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.use-case-list li::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0.5em;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
background: var(--color-primary);
|
||||
border-radius: 50%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,873 @@
|
||||
<script>
|
||||
import { Copy, Download, Check, User, Mail } from 'lucide-svelte';
|
||||
import { tooltip } from '$lib/actions/tooltip.js';
|
||||
|
||||
let domain = $state('');
|
||||
let mailboxDname = $state('admin.example.com.');
|
||||
let txtDname = $state('admin-info.example.com.');
|
||||
let showExamples = $state(false);
|
||||
|
||||
let buttonStates = $state({});
|
||||
|
||||
const roleExamples = [
|
||||
{
|
||||
name: 'System Administrator',
|
||||
mbox: 'admin.example.com.',
|
||||
txt: 'admin-info.example.com.',
|
||||
description: 'Primary system administrator contact'
|
||||
},
|
||||
{
|
||||
name: 'Webmaster',
|
||||
mbox: 'webmaster.example.com.',
|
||||
txt: 'webmaster-info.example.com.',
|
||||
description: 'Website administrator contact'
|
||||
},
|
||||
{
|
||||
name: 'Security Contact',
|
||||
mbox: 'security.example.com.',
|
||||
txt: 'security-info.example.com.',
|
||||
description: 'Security incident response contact'
|
||||
},
|
||||
{
|
||||
name: 'DNS Administrator',
|
||||
mbox: 'dns-admin.example.com.',
|
||||
txt: 'dns-admin-info.example.com.',
|
||||
description: 'DNS zone administrator'
|
||||
}
|
||||
];
|
||||
|
||||
let rpRecord = $derived.by(() => {
|
||||
if (!domain.trim()) return '';
|
||||
|
||||
const cleanDomain = domain.trim().replace(/\.$/, '');
|
||||
const mbox = mailboxDname.trim() || '.';
|
||||
const txt = txtDname.trim() || '.';
|
||||
|
||||
return `${cleanDomain}. IN RP ${mbox} ${txt}`;
|
||||
});
|
||||
|
||||
let txtRecord = $derived.by(() => {
|
||||
if (!txtDname.trim() || txtDname === '.') return '';
|
||||
|
||||
const txt = txtDname.trim().replace(/\.$/, '');
|
||||
return `${txt}. IN TXT "Administrative contact for ${domain.trim().replace(/\.$/, '') || 'this domain'}. Please use the mailbox specified in the RP record for contact."`;
|
||||
});
|
||||
|
||||
let isValid = $derived.by(() => {
|
||||
return domain.trim() !== '' && mailboxDname.trim() !== '';
|
||||
});
|
||||
|
||||
let warnings = $derived.by(() => {
|
||||
const warns = [];
|
||||
|
||||
if (mailboxDname && !mailboxDname.includes('.')) {
|
||||
warns.push('Mailbox domain name should be a fully qualified domain name');
|
||||
}
|
||||
|
||||
if (txtDname && txtDname !== '.' && !txtDname.includes('.')) {
|
||||
warns.push('TXT domain name should be a fully qualified domain name or "."');
|
||||
}
|
||||
|
||||
if (mailboxDname && mailboxDname.endsWith('.')) {
|
||||
// This is correct
|
||||
} else if (mailboxDname && mailboxDname !== '.') {
|
||||
warns.push('Domain names in RP records should end with a dot (.) for absolute names');
|
||||
}
|
||||
|
||||
if (txtDname && txtDname.endsWith('.')) {
|
||||
// This is correct
|
||||
} else if (txtDname && txtDname !== '.') {
|
||||
warns.push('TXT domain name should end with a dot (.) for absolute names');
|
||||
}
|
||||
|
||||
return warns;
|
||||
});
|
||||
|
||||
let info = $derived.by(() => {
|
||||
const infos = [];
|
||||
|
||||
if (mailboxDname === '.') {
|
||||
infos.push('Using "." for mailbox means no mailbox is specified');
|
||||
}
|
||||
|
||||
if (txtDname === '.') {
|
||||
infos.push('Using "." for TXT means no additional text information is provided');
|
||||
}
|
||||
|
||||
if (txtDname && txtDname !== '.') {
|
||||
infos.push(`Remember to create the TXT record at ${txtDname} with contact information`);
|
||||
}
|
||||
|
||||
return infos;
|
||||
});
|
||||
|
||||
function showButtonSuccess(buttonId) {
|
||||
buttonStates[buttonId] = true;
|
||||
setTimeout(() => {
|
||||
buttonStates[buttonId] = false;
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
function copyToClipboard() {
|
||||
let content = rpRecord;
|
||||
if (txtRecord) {
|
||||
content += '\n\n; Suggested TXT record:\n' + txtRecord;
|
||||
}
|
||||
navigator.clipboard.writeText(content);
|
||||
showButtonSuccess('copy');
|
||||
}
|
||||
|
||||
function downloadRecord() {
|
||||
let content = rpRecord;
|
||||
if (txtRecord) {
|
||||
content += '\n\n; Suggested TXT record:\n' + txtRecord;
|
||||
}
|
||||
content += '\n\n; RP Record Format:\n; domain IN RP mailbox-dname txt-dname\n; mailbox-dname: domain name that encodes the email address\n; txt-dname: domain name where TXT record with contact info can be found';
|
||||
|
||||
const blob = new Blob([content], { type: 'text/plain' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `${domain.replace(/\.$/, '') || 'rp'}-record.txt`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
showButtonSuccess('download');
|
||||
}
|
||||
|
||||
function loadRoleExample(role) {
|
||||
mailboxDname = role.mbox;
|
||||
txtDname = role.txt;
|
||||
if (!domain) domain = 'example.com';
|
||||
}
|
||||
|
||||
function emailToDname(email) {
|
||||
if (!email.includes('@')) return email;
|
||||
const [local, domain] = email.split('@');
|
||||
return `${local.replace(/\./g, '\\.')}.${domain}.`;
|
||||
}
|
||||
|
||||
function dnameToEmail(dname) {
|
||||
if (!dname.includes('.') || dname === '.') return '';
|
||||
const parts = dname.replace(/\.$/, '').split('.');
|
||||
if (parts.length < 2) return '';
|
||||
const domain = parts.slice(-2).join('.');
|
||||
const local = parts.slice(0, -2).join('.').replace(/\\\./g, '.');
|
||||
return `${local}@${domain}`;
|
||||
}
|
||||
|
||||
let emailInput = $state('');
|
||||
|
||||
function convertEmailToDname() {
|
||||
if (emailInput.trim()) {
|
||||
mailboxDname = emailToDname(emailInput.trim());
|
||||
emailInput = '';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="rp-builder">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h1>RP Record Builder</h1>
|
||||
<p>
|
||||
Create RP (Responsible Person) records to specify administrative contacts for your domains
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="card-content">
|
||||
<!-- Role Examples -->
|
||||
<details bind:open={showExamples} class="examples-section">
|
||||
<summary>
|
||||
<span>Common Role Examples</span>
|
||||
<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||
<polyline points="6,9 12,15 18,9"></polyline>
|
||||
</svg>
|
||||
</summary>
|
||||
<div class="examples-grid">
|
||||
{#each roleExamples as role}
|
||||
<button class="example-btn" onclick={() => loadRoleExample(role)}>
|
||||
<div class="example-name">{role.name}</div>
|
||||
<div class="example-desc">{role.description}</div>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<div class="form-grid">
|
||||
<!-- Input Form -->
|
||||
<div class="input-section">
|
||||
<div class="field-group">
|
||||
<label for="domain" use:tooltip={"The domain name for which this RP record will be created"}>
|
||||
Domain Name *
|
||||
</label>
|
||||
<input
|
||||
id="domain"
|
||||
type="text"
|
||||
bind:value={domain}
|
||||
placeholder="example.com"
|
||||
/>
|
||||
<small>The domain name for this RP record</small>
|
||||
</div>
|
||||
|
||||
<!-- Email to Domain Name Converter -->
|
||||
<div class="converter-section">
|
||||
<h4>Email to Domain Name Converter</h4>
|
||||
<div class="converter-input">
|
||||
<input
|
||||
type="email"
|
||||
bind:value={emailInput}
|
||||
placeholder="admin@example.com"
|
||||
/>
|
||||
<button
|
||||
onclick={convertEmailToDname}
|
||||
class="btn-success"
|
||||
disabled={!emailInput.trim()}
|
||||
>
|
||||
Convert
|
||||
</button>
|
||||
</div>
|
||||
<small>Enter an email to automatically convert to domain name format</small>
|
||||
</div>
|
||||
|
||||
<div class="field-group">
|
||||
<label for="mailbox" use:tooltip={"Domain name encoding the email address. Use '.' for no contact specified."}>
|
||||
Mailbox Domain Name *
|
||||
</label>
|
||||
<input
|
||||
id="mailbox"
|
||||
type="text"
|
||||
bind:value={mailboxDname}
|
||||
placeholder="admin.example.com."
|
||||
class="mono-input"
|
||||
/>
|
||||
<small>
|
||||
Domain name encoding the email address (use "." for no contact)
|
||||
</small>
|
||||
{#if mailboxDname && mailboxDname !== '.'}
|
||||
<div class="email-preview">
|
||||
<Mail size="12" />
|
||||
Email: {dnameToEmail(mailboxDname) || 'Invalid format'}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="field-group">
|
||||
<label for="txt" use:tooltip={"Domain name where TXT record with additional contact information can be found. Use '.' for no additional info."}>
|
||||
TXT Domain Name
|
||||
</label>
|
||||
<input
|
||||
id="txt"
|
||||
type="text"
|
||||
bind:value={txtDname}
|
||||
placeholder="admin-info.example.com."
|
||||
class="mono-input"
|
||||
/>
|
||||
<small>
|
||||
Domain name where TXT record with contact info can be found (use "." for none)
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Output -->
|
||||
<div class="output-section">
|
||||
<div class="output-group">
|
||||
<label>Generated RP Record</label>
|
||||
<div class="code-output">
|
||||
{#if isValid}
|
||||
<pre>{rpRecord}</pre>
|
||||
{:else}
|
||||
<p class="placeholder-text">Fill in the required fields to generate the RP record</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if txtRecord}
|
||||
<div class="output-group">
|
||||
<label>Suggested TXT Record</label>
|
||||
<div class="code-output txt-output">
|
||||
<pre>{txtRecord}</pre>
|
||||
<small>This TXT record should be created at the specified domain</small>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if info.length > 0}
|
||||
<div class="alert alert-info">
|
||||
<h4>Information</h4>
|
||||
<ul>
|
||||
{#each info as infoItem}
|
||||
<li>{infoItem}</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if warnings.length > 0}
|
||||
<div class="alert alert-warning">
|
||||
<h4>Configuration Warnings</h4>
|
||||
<ul>
|
||||
{#each warnings as warning}
|
||||
<li>{warning}</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if isValid}
|
||||
<div class="button-group">
|
||||
<button
|
||||
onclick={copyToClipboard}
|
||||
class="btn-secondary"
|
||||
class:success={buttonStates.copy}
|
||||
style="transform: {buttonStates.copy ? 'scale(1.05)' : 'scale(1)'}"
|
||||
>
|
||||
{#if buttonStates.copy}
|
||||
<Check size="16" />
|
||||
Copied!
|
||||
{:else}
|
||||
<Copy size="16" />
|
||||
Copy Records
|
||||
{/if}
|
||||
</button>
|
||||
<button
|
||||
onclick={downloadRecord}
|
||||
class="btn-primary"
|
||||
class:success={buttonStates.download}
|
||||
style="transform: {buttonStates.download ? 'scale(1.05)' : 'scale(1)'}"
|
||||
>
|
||||
{#if buttonStates.download}
|
||||
<Check size="16" />
|
||||
Downloaded!
|
||||
{:else}
|
||||
<Download size="16" />
|
||||
Download
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Information Section -->
|
||||
<div class="info-section">
|
||||
<div class="card info-card">
|
||||
<h3>About RP Records</h3>
|
||||
<p>
|
||||
RP (Responsible Person) records identify the responsible person for a domain or host. They specify both a mailbox (encoded as a domain name) and optionally point to a TXT record with additional contact information. This allows automated discovery of administrative contacts.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="info-grid">
|
||||
<div class="card">
|
||||
<h4>Email Encoding</h4>
|
||||
<div class="encoding-examples">
|
||||
<p>Email addresses are encoded as domain names:</p>
|
||||
<div class="code-example">
|
||||
<div><strong>Email:</strong> admin@example.com</div>
|
||||
<div><strong>Encoded:</strong> admin.example.com.</div>
|
||||
</div>
|
||||
<div class="code-example">
|
||||
<div><strong>Email:</strong> user.name@example.com</div>
|
||||
<div><strong>Encoded:</strong> user\.name.example.com.</div>
|
||||
</div>
|
||||
<small>Dots in the local part are escaped with backslashes</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h4>Common Use Cases</h4>
|
||||
<ul class="use-cases">
|
||||
<li>Zone administrator contact</li>
|
||||
<li>Server administrator contact</li>
|
||||
<li>Security incident response</li>
|
||||
<li>Automated contact discovery</li>
|
||||
<li>Compliance requirements</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card best-practices-card">
|
||||
<h4>Best Practices</h4>
|
||||
<ul class="best-practices">
|
||||
<li>Always use fully qualified domain names ending with a dot</li>
|
||||
<li>Create corresponding TXT records with detailed contact information</li>
|
||||
<li>Keep contact information up to date and monitored</li>
|
||||
<li>Consider creating role-based contacts rather than personal ones</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
|
||||
.card {
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-sm);
|
||||
|
||||
.card-header {
|
||||
h1 {
|
||||
color: var(--text-primary);
|
||||
font-size: var(--font-size-2xl);
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
color: var(--text-secondary);
|
||||
margin: var(--spacing-xs) 0 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.examples-section {
|
||||
margin-bottom: var(--spacing-lg);
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: var(--radius-md);
|
||||
border: 1px solid var(--border-primary);
|
||||
|
||||
summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: var(--spacing-md) var(--spacing-sm);
|
||||
border-radius: var(--radius-md);
|
||||
cursor: pointer;
|
||||
color: var(--text-primary);
|
||||
font-weight: 600;
|
||||
transition: var(--transition-fast);
|
||||
|
||||
&:hover {
|
||||
background: var(--surface-hover);
|
||||
}
|
||||
|
||||
.chevron {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
transition: transform var(--transition-fast);
|
||||
}
|
||||
}
|
||||
|
||||
&[open] summary .chevron {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.examples-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: var(--spacing-sm);
|
||||
padding: var(--spacing-md);
|
||||
border-radius: 0 0 var(--radius-md) var(--radius-md);
|
||||
}
|
||||
|
||||
.example-btn {
|
||||
text-align: left;
|
||||
padding: var(--spacing-sm);
|
||||
border: none;
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
transition: var(--transition-fast);
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--color-primary);
|
||||
}
|
||||
|
||||
.example-name {
|
||||
font-weight: 600;
|
||||
margin-bottom: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.example-desc {
|
||||
font-size: var(--font-size-xs);
|
||||
opacity: 0.9;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: var(--spacing-xl);
|
||||
|
||||
@media (max-width: 768px) {
|
||||
grid-template-columns: 1fr;
|
||||
gap: var(--spacing-lg);
|
||||
}
|
||||
}
|
||||
|
||||
.input-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-md);
|
||||
|
||||
.field-group {
|
||||
label {
|
||||
display: block;
|
||||
color: var(--text-primary);
|
||||
font-weight: 500;
|
||||
margin-bottom: var(--spacing-xs);
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: var(--spacing-sm);
|
||||
background: var(--bg-primary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
color: var(--text-primary);
|
||||
transition: var(--transition-fast);
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--color-primary);
|
||||
box-shadow: 0 0 0 2px var(--color-primary-dark);
|
||||
}
|
||||
}
|
||||
|
||||
.mono-input {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
small {
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--font-size-xs);
|
||||
margin-top: var(--spacing-xs);
|
||||
display: block;
|
||||
}
|
||||
|
||||
.email-preview {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
color: var(--color-info);
|
||||
font-size: var(--font-size-xs);
|
||||
margin-top: var(--spacing-xs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.converter-section {
|
||||
padding: var(--spacing-sm);
|
||||
background: color-mix(in srgb, var(--color-success) 8%, transparent);
|
||||
border: 1px solid var(--color-success);
|
||||
border-radius: var(--radius-md);
|
||||
|
||||
h4 {
|
||||
color: var(--color-success);
|
||||
font-weight: 600;
|
||||
margin: 0 0 var(--spacing-sm);
|
||||
}
|
||||
|
||||
.converter-input {
|
||||
display: flex;
|
||||
gap: var(--spacing-sm);
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
padding: var(--spacing-xs);
|
||||
border: 1px solid var(--color-success);
|
||||
border-radius: var(--radius-sm);
|
||||
background: white;
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 2px var(--color-success-light);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
small {
|
||||
color: var(--color-success);
|
||||
font-size: var(--font-size-xs);
|
||||
margin-top: var(--spacing-xs);
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.output-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-md);
|
||||
|
||||
.output-group {
|
||||
label {
|
||||
display: block;
|
||||
color: var(--text-primary);
|
||||
font-weight: 500;
|
||||
margin-bottom: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.code-output {
|
||||
padding: var(--spacing-md);
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
|
||||
pre {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-primary);
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.placeholder-text {
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--font-size-sm);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
small {
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--font-size-xs);
|
||||
margin-top: var(--spacing-sm);
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.txt-output {
|
||||
background: color-mix(in srgb, var(--color-info) 8%, transparent);
|
||||
border-color: var(--color-info);
|
||||
|
||||
pre {
|
||||
color: var(--color-info);
|
||||
}
|
||||
|
||||
small {
|
||||
color: var(--color-info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.alert {
|
||||
padding: var(--spacing-sm);
|
||||
border-radius: var(--radius-md);
|
||||
margin-bottom: var(--spacing-md);
|
||||
|
||||
h4 {
|
||||
font-weight: 600;
|
||||
margin: 0 0 var(--spacing-xs);
|
||||
}
|
||||
|
||||
ul {
|
||||
margin: 0;
|
||||
padding-left: var(--spacing-md);
|
||||
|
||||
li {
|
||||
margin-bottom: var(--spacing-xs);
|
||||
}
|
||||
}
|
||||
|
||||
&.alert-info {
|
||||
background: color-mix(in srgb, var(--color-info) 8%, transparent);
|
||||
border: 1px solid var(--color-info);
|
||||
color: var(--color-info);
|
||||
}
|
||||
|
||||
&.alert-warning {
|
||||
background: color-mix(in srgb, var(--color-warning) 8%, transparent);
|
||||
border: 1px solid var(--color-warning);
|
||||
color: var(--color-warning);
|
||||
}
|
||||
}
|
||||
|
||||
.button-group {
|
||||
display: flex;
|
||||
gap: var(--spacing-sm);
|
||||
|
||||
@media (max-width: 480px) {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
padding: var(--spacing-sm) var(--spacing-md);
|
||||
background: var(--bg-secondary);
|
||||
color: var(--text-primary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
cursor: pointer;
|
||||
transition: var(--transition-fast);
|
||||
|
||||
&:hover {
|
||||
background: var(--surface-hover);
|
||||
}
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 2px var(--color-primary-dark);
|
||||
}
|
||||
|
||||
&.success {
|
||||
border-color: var(--color-success);
|
||||
color: var(--color-success);
|
||||
}
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
padding: var(--spacing-sm) var(--spacing-md);
|
||||
background: var(--color-primary);
|
||||
color: var(--bg-primary);
|
||||
border: none;
|
||||
border-radius: var(--radius-md);
|
||||
cursor: pointer;
|
||||
transition: var(--transition-fast);
|
||||
|
||||
&:hover {
|
||||
background: var(--color-primary);
|
||||
color: var(--bg-primary);
|
||||
}
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 2px var(--color-primary-dark);
|
||||
}
|
||||
|
||||
&.success {
|
||||
background: color-mix(in srgb, var(--color-success) 8%, transparent);
|
||||
|
||||
&:hover {
|
||||
background: var(--color-success-light);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
padding: var(--spacing-xs) var(--spacing-sm);
|
||||
background: color-mix(in srgb, var(--color-success) 8%, transparent);
|
||||
color: var(--text-primary);
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
transition: var(--transition-fast);
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: var(--color-success-light);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.info-section {
|
||||
margin-top: var(--spacing-xl);
|
||||
|
||||
.info-card {
|
||||
background: color-mix(in srgb, var(--color-info) 8%, transparent);
|
||||
border-color: var(--color-info);
|
||||
margin-bottom: var(--spacing-lg);
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
|
||||
h3 {
|
||||
color: var(--color-info);
|
||||
font-weight: 600;
|
||||
margin: 0 0 var(--spacing-sm);
|
||||
}
|
||||
|
||||
p {
|
||||
color: var(--text-primary);
|
||||
line-height: 1.6;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: var(--spacing-md);
|
||||
margin-bottom: var(--spacing-lg);
|
||||
|
||||
.card {
|
||||
h4 {
|
||||
color: var(--text-primary);
|
||||
font-weight: 600;
|
||||
margin: 0 0 var(--spacing-sm);
|
||||
}
|
||||
|
||||
.encoding-examples {
|
||||
p {
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.code-example {
|
||||
padding: var(--spacing-xs);
|
||||
background: var(--bg-primary);
|
||||
border: 1px solid var(--border-secondary);
|
||||
border-radius: var(--radius-sm);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-xs);
|
||||
margin-bottom: var(--spacing-xs);
|
||||
|
||||
div {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
}
|
||||
|
||||
small {
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--font-size-xs);
|
||||
}
|
||||
}
|
||||
|
||||
.use-cases {
|
||||
margin: 0;
|
||||
padding-left: var(--spacing-md);
|
||||
|
||||
li {
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: var(--spacing-xs);
|
||||
position: relative;
|
||||
|
||||
&::marker {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.best-practices-card {
|
||||
background: color-mix(in srgb, var(--color-warning) 8%, transparent);
|
||||
border-color: var(--color-warning);
|
||||
|
||||
h4 {
|
||||
color: var(--color-warning);
|
||||
}
|
||||
|
||||
.best-practices {
|
||||
margin: 0;
|
||||
padding-left: var(--spacing-md);
|
||||
|
||||
li {
|
||||
color: var(--color-warning);
|
||||
margin-bottom: var(--spacing-xs);
|
||||
|
||||
&::marker {
|
||||
color: var(--color-warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,937 @@
|
||||
<script lang="ts">
|
||||
import Icon from '$lib/components/global/Icon.svelte';
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
|
||||
interface SSHFPRecord {
|
||||
algorithm: number;
|
||||
fingerprintType: number;
|
||||
fingerprint: string;
|
||||
}
|
||||
|
||||
let domain = $state('example.com');
|
||||
let inputType = $state<'public-key' | 'fingerprint'>('public-key');
|
||||
let publicKeyInput = $state('');
|
||||
let fingerprintInput = $state('');
|
||||
|
||||
let algorithm = $state(1);
|
||||
let fingerprintType = $state(1);
|
||||
|
||||
let showExamples = $state(false);
|
||||
let selectedExample = $state<string | null>(null);
|
||||
|
||||
// Button success states
|
||||
let buttonStates = $state<Record<string, boolean>>({});
|
||||
|
||||
const algorithmDescriptions = {
|
||||
1: 'RSA - Traditional RSA algorithm (most common)',
|
||||
2: 'DSA - Digital Signature Algorithm (deprecated)',
|
||||
3: 'ECDSA - Elliptic Curve Digital Signature Algorithm',
|
||||
4: 'Ed25519 - Edwards-curve Digital Signature Algorithm (modern, recommended)'
|
||||
};
|
||||
|
||||
const fingerprintTypeDescriptions = {
|
||||
1: 'SHA-1 - Legacy hash algorithm (160-bit)',
|
||||
2: 'SHA-256 - Modern hash algorithm (256-bit, recommended)'
|
||||
};
|
||||
|
||||
const sshfpRecord = $derived.by(() => {
|
||||
let fingerprintValue = '';
|
||||
|
||||
if (inputType === 'fingerprint') {
|
||||
// Use provided fingerprint directly
|
||||
fingerprintValue = fingerprintInput.trim().replace(/[^a-fA-F0-9]/g, '').toLowerCase();
|
||||
} else if (inputType === 'public-key') {
|
||||
// For demo purposes, we'll show how it would work
|
||||
// In a real implementation, you'd parse the public key and generate the fingerprint
|
||||
if (publicKeyInput.trim()) {
|
||||
// Generate demo fingerprint based on fingerprint type
|
||||
fingerprintValue = fingerprintType === 1
|
||||
? 'abcd1234567890abcdef1234567890abcdef1234'
|
||||
: 'abcd1234567890abcdef1234567890abcdef1234567890abcdef1234567890ab';
|
||||
}
|
||||
}
|
||||
|
||||
if (!fingerprintValue) return null;
|
||||
|
||||
return {
|
||||
algorithm,
|
||||
fingerprintType,
|
||||
fingerprint: fingerprintValue
|
||||
};
|
||||
});
|
||||
|
||||
const dnsRecord = $derived.by(() => {
|
||||
if (!sshfpRecord) return '';
|
||||
return `${domain}. IN SSHFP ${sshfpRecord.algorithm} ${sshfpRecord.fingerprintType} ${sshfpRecord.fingerprint}`;
|
||||
});
|
||||
|
||||
const validation = $derived.by(() => {
|
||||
const warnings: string[] = [];
|
||||
const errors: string[] = [];
|
||||
|
||||
// Check domain format
|
||||
if (!domain.trim()) {
|
||||
errors.push('Domain is required');
|
||||
} else if (!domain.includes('.')) {
|
||||
warnings.push('Domain should include TLD (e.g., .com, .org)');
|
||||
}
|
||||
|
||||
// Check public key/fingerprint input
|
||||
if (inputType === 'public-key') {
|
||||
if (!publicKeyInput.trim()) {
|
||||
errors.push('SSH public key is required');
|
||||
} else {
|
||||
const key = publicKeyInput.trim();
|
||||
if (!key.startsWith('ssh-') && !key.startsWith('ecdsa-') && !key.includes(' ')) {
|
||||
warnings.push('Public key should be in OpenSSH format (e.g., "ssh-rsa AAAAB3NzaC1...")');
|
||||
}
|
||||
}
|
||||
} else if (inputType === 'fingerprint') {
|
||||
if (!fingerprintInput.trim()) {
|
||||
errors.push('Fingerprint value is required');
|
||||
} else {
|
||||
const cleanFingerprint = fingerprintInput.trim().replace(/[^a-fA-F0-9]/g, '');
|
||||
if (fingerprintType === 1 && cleanFingerprint.length !== 40) {
|
||||
warnings.push('SHA-1 fingerprint should be exactly 40 hexadecimal characters');
|
||||
} else if (fingerprintType === 2 && cleanFingerprint.length !== 64) {
|
||||
warnings.push('SHA-256 fingerprint should be exactly 64 hexadecimal characters');
|
||||
} else if (!/^[a-fA-F0-9]+$/.test(cleanFingerprint)) {
|
||||
errors.push('Fingerprint must contain only hexadecimal characters');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Algorithm recommendations
|
||||
if (algorithm === 2) {
|
||||
warnings.push('DSA algorithm is deprecated and should be avoided');
|
||||
}
|
||||
|
||||
if (fingerprintType === 1) {
|
||||
warnings.push('SHA-1 is deprecated - use SHA-256 for new deployments');
|
||||
}
|
||||
|
||||
return {
|
||||
isValid: errors.length === 0,
|
||||
errors,
|
||||
warnings
|
||||
};
|
||||
});
|
||||
|
||||
function showButtonSuccess(buttonId: string): void {
|
||||
buttonStates[buttonId] = true;
|
||||
setTimeout(() => {
|
||||
buttonStates[buttonId] = false;
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
function copyToClipboard(text: string, buttonId: string): void {
|
||||
navigator.clipboard.writeText(text);
|
||||
showButtonSuccess(buttonId);
|
||||
}
|
||||
|
||||
function exportAsZoneFile(): void {
|
||||
if (!dnsRecord) return;
|
||||
|
||||
const zoneContent = dnsRecord;
|
||||
const blob = new Blob([zoneContent], { type: 'text/plain' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `${domain}-sshfp-record.zone`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
showButtonSuccess('export-sshfp');
|
||||
}
|
||||
|
||||
// Simulate fingerprint generation from public key
|
||||
async function generateFingerprintFromKey(): Promise<void> {
|
||||
if (inputType === 'public-key' && publicKeyInput.trim()) {
|
||||
// This is a placeholder - in a real implementation you would:
|
||||
// 1. Parse the OpenSSH public key format
|
||||
// 2. Extract the key material
|
||||
// 3. Hash it with the chosen algorithm
|
||||
|
||||
const demoFingerprint = fingerprintType === 1
|
||||
? 'abcd1234567890abcdef1234567890abcdef1234'
|
||||
: 'abcd1234567890abcdef1234567890abcdef1234567890abcdef1234567890ab';
|
||||
|
||||
fingerprintInput = demoFingerprint;
|
||||
inputType = 'fingerprint';
|
||||
}
|
||||
}
|
||||
|
||||
const exampleConfigurations = [
|
||||
{
|
||||
name: 'RSA SSH Key',
|
||||
description: 'RSA public key with SHA-256 fingerprint',
|
||||
domain: 'server.example.com',
|
||||
algorithm: 1,
|
||||
fingerprintType: 2,
|
||||
fingerprint: 'a1b2c3d4e5f67890abcdef1234567890abcdef1234567890abcdef1234567890'
|
||||
},
|
||||
{
|
||||
name: 'Ed25519 SSH Key',
|
||||
description: 'Modern Ed25519 key with SHA-256 fingerprint',
|
||||
domain: 'ssh.example.com',
|
||||
algorithm: 4,
|
||||
fingerprintType: 2,
|
||||
fingerprint: 'fedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321'
|
||||
},
|
||||
{
|
||||
name: 'ECDSA SSH Key',
|
||||
description: 'ECDSA key with SHA-256 fingerprint',
|
||||
domain: 'secure.example.com',
|
||||
algorithm: 3,
|
||||
fingerprintType: 2,
|
||||
fingerprint: '123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0'
|
||||
}
|
||||
];
|
||||
|
||||
function loadExample(example: typeof exampleConfigurations[0]): void {
|
||||
domain = example.domain;
|
||||
algorithm = example.algorithm;
|
||||
fingerprintType = example.fingerprintType;
|
||||
fingerprintInput = example.fingerprint;
|
||||
inputType = 'fingerprint';
|
||||
publicKeyInput = '';
|
||||
selectedExample = example.name;
|
||||
}
|
||||
|
||||
const securityTips = [
|
||||
'Use Ed25519 (algorithm 4) for new SSH key deployments',
|
||||
'Prefer SHA-256 (type 2) over SHA-1 (type 1) for fingerprints',
|
||||
'Deploy SSHFP records for all SSH host keys on your servers',
|
||||
'Update SSHFP records when rotating SSH host keys',
|
||||
'Configure SSH clients to verify SSHFP records for enhanced security'
|
||||
];
|
||||
</script>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h1>SSHFP Generator</h1>
|
||||
<p class="card-subtitle">
|
||||
Generate SSHFP (SSH Fingerprint) records to enable DNS-based SSH host key verification and authentication.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="grid-layout">
|
||||
<div class="input-section">
|
||||
<div class="domain-section">
|
||||
<div class="section-header">
|
||||
<h3>
|
||||
<Icon name="globe" size="sm" />
|
||||
Domain Configuration
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="domain" use:tooltip={"Domain name for the SSHFP record"}>
|
||||
Domain:
|
||||
</label>
|
||||
<input
|
||||
id="domain"
|
||||
type="text"
|
||||
bind:value={domain}
|
||||
placeholder="example.com"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sshfp-parameters-section">
|
||||
<div class="section-header">
|
||||
<h3>
|
||||
<Icon name="settings" size="sm" />
|
||||
SSHFP Parameters
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="parameters-grid">
|
||||
<div class="input-group">
|
||||
<label for="algorithm" use:tooltip={"SSH key algorithm used by the server"}>
|
||||
Algorithm:
|
||||
</label>
|
||||
<select id="algorithm" bind:value={algorithm}>
|
||||
<option value={1}>1 - RSA</option>
|
||||
<option value={2}>2 - DSA (deprecated)</option>
|
||||
<option value={3}>3 - ECDSA</option>
|
||||
<option value={4}>4 - Ed25519</option>
|
||||
</select>
|
||||
<div class="parameter-description">
|
||||
{algorithmDescriptions[algorithm]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="fingerprintType" use:tooltip={"Hash algorithm used to generate the fingerprint"}>
|
||||
Fingerprint Type:
|
||||
</label>
|
||||
<select id="fingerprintType" bind:value={fingerprintType}>
|
||||
<option value={1}>1 - SHA-1</option>
|
||||
<option value={2}>2 - SHA-256</option>
|
||||
</select>
|
||||
<div class="parameter-description">
|
||||
{fingerprintTypeDescriptions[fingerprintType]}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-data-section">
|
||||
<div class="section-header">
|
||||
<h3>
|
||||
<Icon name="key" size="sm" />
|
||||
SSH Key Data
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="input-type-selector">
|
||||
<label class="input-type-option">
|
||||
<input type="radio" bind:group={inputType} value="public-key" />
|
||||
<span>SSH Public Key</span>
|
||||
</label>
|
||||
<label class="input-type-option">
|
||||
<input type="radio" bind:group={inputType} value="fingerprint" />
|
||||
<span>Fingerprint Value</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{#if inputType === 'public-key'}
|
||||
<div class="input-group">
|
||||
<label for="publicKey" use:tooltip={"Paste the SSH public key from ~/.ssh/id_rsa.pub or similar"}>
|
||||
SSH Public Key:
|
||||
</label>
|
||||
<textarea
|
||||
id="publicKey"
|
||||
bind:value={publicKeyInput}
|
||||
placeholder="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC... user@hostname ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... user@hostname"
|
||||
rows="4"
|
||||
class="public-key-input"
|
||||
></textarea>
|
||||
<button
|
||||
type="button"
|
||||
class="generate-fingerprint-btn"
|
||||
onclick={generateFingerprintFromKey}
|
||||
disabled={!publicKeyInput.trim()}
|
||||
use:tooltip={"Generate fingerprint from public key (demo mode)"}
|
||||
>
|
||||
<Icon name="arrow-right" size="sm" />
|
||||
Generate Fingerprint
|
||||
</button>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="input-group">
|
||||
<label for="fingerprint" use:tooltip={`Enter the ${fingerprintType === 1 ? 'SHA-1' : 'SHA-256'} fingerprint value`}>
|
||||
Fingerprint Value:
|
||||
</label>
|
||||
<textarea
|
||||
id="fingerprint"
|
||||
bind:value={fingerprintInput}
|
||||
placeholder={fingerprintType === 1 ?
|
||||
'abcd1234567890abcdef1234567890abcdef1234' :
|
||||
'abcd1234567890abcdef1234567890abcdef1234567890abcdef1234567890ab'
|
||||
}
|
||||
rows="2"
|
||||
class="fingerprint-input"
|
||||
></textarea>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="results-section">
|
||||
{#if sshfpRecord}
|
||||
<div class="sshfp-record-section">
|
||||
<div class="section-header">
|
||||
<h3>Generated SSHFP Record</h3>
|
||||
<div class="actions">
|
||||
<button
|
||||
type="button"
|
||||
class="copy-btn"
|
||||
class:success={buttonStates['copy-sshfp']}
|
||||
onclick={() => copyToClipboard(dnsRecord, 'copy-sshfp')}
|
||||
use:tooltip={"Copy SSHFP record to clipboard"}
|
||||
>
|
||||
<Icon name={buttonStates['copy-sshfp'] ? "check" : "copy"} size="sm" />
|
||||
{buttonStates['copy-sshfp'] ? 'Copied!' : 'Copy'}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="export-btn"
|
||||
class:success={buttonStates['export-sshfp']}
|
||||
onclick={exportAsZoneFile}
|
||||
use:tooltip={"Download as zone file"}
|
||||
>
|
||||
<Icon name={buttonStates['export-sshfp'] ? "check" : "download"} size="sm" />
|
||||
{buttonStates['export-sshfp'] ? 'Downloaded!' : 'Export'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="record-output">
|
||||
<div class="code-block">
|
||||
<code>{dnsRecord}</code>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="record-breakdown">
|
||||
<h4>Record Breakdown:</h4>
|
||||
<div class="breakdown-grid">
|
||||
<div class="breakdown-item">
|
||||
<strong>Algorithm:</strong> {algorithm} ({Object.values(algorithmDescriptions)[algorithm - 1].split(' - ')[1].split(' (')[0]})
|
||||
</div>
|
||||
<div class="breakdown-item">
|
||||
<strong>Fingerprint Type:</strong> {fingerprintType} ({Object.values(fingerprintTypeDescriptions)[fingerprintType - 1].split(' - ')[1].split(' (')[0]})
|
||||
</div>
|
||||
<div class="breakdown-item">
|
||||
<strong>Fingerprint Length:</strong> {sshfpRecord.fingerprint.length} chars
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="validation-section">
|
||||
<div class="section-header">
|
||||
<h3>
|
||||
<Icon name="bar-chart" size="sm" />
|
||||
Validation
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="validation-status">
|
||||
<div class="status-item">
|
||||
<span class="status-label">Status:</span>
|
||||
<span class="status-value" class:success={validation.isValid} class:error={!validation.isValid}>
|
||||
{validation.isValid ? 'Valid' : 'Invalid'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if validation.errors.length > 0}
|
||||
<div class="validation-messages error">
|
||||
<Icon name="x-circle" size="sm" />
|
||||
<div class="messages">
|
||||
{#each validation.errors as error}
|
||||
<div class="message">{error}</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if validation.warnings.length > 0}
|
||||
<div class="validation-messages warning">
|
||||
<Icon name="alert-triangle" size="sm" />
|
||||
<div class="messages">
|
||||
{#each validation.warnings as warning}
|
||||
<div class="message">{warning}</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if validation.isValid && validation.errors.length === 0 && validation.warnings.length === 0}
|
||||
<div class="validation-messages success">
|
||||
<Icon name="check-circle" size="sm" />
|
||||
<div class="message">SSHFP record is valid and ready to deploy!</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="usage-guide">
|
||||
<div class="section-header">
|
||||
<h3>
|
||||
<Icon name="info" size="sm" />
|
||||
SSH Client Configuration
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="usage-instructions">
|
||||
<h4>To enable SSHFP verification in SSH clients:</h4>
|
||||
<div class="code-block">
|
||||
<code>ssh -o "VerifyHostKeyDNS=yes" user@{domain}</code>
|
||||
</div>
|
||||
|
||||
<h4>Or add to ~/.ssh/config:</h4>
|
||||
<div class="code-block">
|
||||
<code>Host {domain}<br> VerifyHostKeyDNS yes</code>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="security-guide">
|
||||
<div class="section-header">
|
||||
<h3>
|
||||
<Icon name="shield" size="sm" />
|
||||
Security Best Practices
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="security-tips">
|
||||
<ul>
|
||||
{#each securityTips as tip}
|
||||
<li>{tip}</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="examples-section">
|
||||
<details class="examples-toggle" bind:open={showExamples}>
|
||||
<summary>
|
||||
<Icon name="lightbulb" size="sm" />
|
||||
Example Configurations
|
||||
</summary>
|
||||
<div class="examples-grid">
|
||||
{#each exampleConfigurations as example}
|
||||
<button
|
||||
type="button"
|
||||
class="example-card"
|
||||
class:selected={selectedExample === example.name}
|
||||
onclick={() => loadExample(example)}
|
||||
>
|
||||
<div class="example-header">
|
||||
<strong>{example.name}</strong>
|
||||
</div>
|
||||
<p class="example-description">{example.description}</p>
|
||||
<div class="example-config">
|
||||
<div>Algorithm: <code>{example.algorithm}</code>, Type: <code>{example.fingerprintType}</code></div>
|
||||
<div class="fingerprint-preview">
|
||||
Hash: <code>{example.fingerprint.substring(0, 16)}...</code>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
.domain-section, .sshfp-parameters-section, .input-data-section {
|
||||
margin-bottom: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: var(--spacing-md);
|
||||
|
||||
h3, h4 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
margin: 0;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
}
|
||||
|
||||
.parameters-grid {
|
||||
display: grid;
|
||||
gap: var(--spacing-md);
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.input-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xs);
|
||||
|
||||
label {
|
||||
font-weight: 600;
|
||||
color: var(--color-text);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
input, select, textarea {
|
||||
padding: var(--spacing-sm);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-sm);
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--color-primary);
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 20%, transparent);
|
||||
}
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: vertical;
|
||||
min-height: 60px;
|
||||
}
|
||||
}
|
||||
|
||||
.parameter-description {
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--color-text-secondary);
|
||||
font-style: italic;
|
||||
margin-top: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.input-type-selector {
|
||||
display: flex;
|
||||
gap: var(--spacing-md);
|
||||
margin-bottom: var(--spacing-md);
|
||||
|
||||
@media (max-width: 768px) {
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
}
|
||||
|
||||
.input-type-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
cursor: pointer;
|
||||
padding: var(--spacing-xs);
|
||||
border-radius: var(--radius-sm);
|
||||
transition: background-color 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: color-mix(in srgb, var(--color-primary) 5%, transparent);
|
||||
}
|
||||
|
||||
input[type="radio"] {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
accent-color: var(--color-primary);
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-text);
|
||||
}
|
||||
}
|
||||
|
||||
.public-key-input, .fingerprint-input {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-xs);
|
||||
background: var(--bg-primary);
|
||||
}
|
||||
|
||||
.generate-fingerprint-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
padding: var(--spacing-sm);
|
||||
background: var(--color-secondary);
|
||||
color: var(--bg-secondary);
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
font-size: var(--font-size-sm);
|
||||
margin-top: var(--spacing-sm);
|
||||
transition: all 0.2s ease;
|
||||
align-self: flex-start;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: var(--color-secondary-hover);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.record-breakdown {
|
||||
margin-top: var(--spacing-md);
|
||||
|
||||
h4 {
|
||||
margin: 0 0 var(--spacing-sm) 0;
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.breakdown-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: var(--spacing-sm);
|
||||
|
||||
@media (max-width: 768px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.breakdown-item {
|
||||
padding: var(--spacing-xs) var(--spacing-sm);
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: var(--font-size-sm);
|
||||
|
||||
strong {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.code-block {
|
||||
background: var(--bg-primary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
padding: var(--spacing-sm);
|
||||
margin-bottom: var(--spacing-sm);
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-sm);
|
||||
word-break: break-all;
|
||||
display: block;
|
||||
white-space: pre-line;
|
||||
}
|
||||
}
|
||||
|
||||
.validation-status {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-bottom: var(--spacing-md);
|
||||
}
|
||||
|
||||
.status-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-sm);
|
||||
padding: var(--spacing-sm);
|
||||
background: var(--bg-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.status-label {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.status-value {
|
||||
font-weight: 600;
|
||||
font-family: var(--font-mono);
|
||||
|
||||
&.success {
|
||||
color: var(--color-success);
|
||||
}
|
||||
|
||||
&.error {
|
||||
color: var(--color-error);
|
||||
}
|
||||
}
|
||||
|
||||
.validation-messages {
|
||||
display: flex;
|
||||
gap: var(--spacing-xs);
|
||||
padding: var(--spacing-sm);
|
||||
border-radius: var(--radius-md);
|
||||
margin-bottom: var(--spacing-sm);
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&.success {
|
||||
background: color-mix(in srgb, var(--color-success) 10%, transparent);
|
||||
border: 1px solid color-mix(in srgb, var(--color-success) 30%, transparent);
|
||||
color: var(--color-success);
|
||||
}
|
||||
|
||||
&.warning {
|
||||
background: color-mix(in srgb, var(--color-warning) 10%, transparent);
|
||||
border: 1px solid color-mix(in srgb, var(--color-warning) 30%, transparent);
|
||||
color: var(--color-warning);
|
||||
}
|
||||
|
||||
&.error {
|
||||
background: color-mix(in srgb, var(--color-error) 10%, transparent);
|
||||
border: 1px solid color-mix(in srgb, var(--color-error) 30%, transparent);
|
||||
color: var(--color-error);
|
||||
}
|
||||
|
||||
.messages {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.message {
|
||||
font-size: var(--font-size-sm);
|
||||
margin-bottom: var(--spacing-xs);
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.usage-instructions {
|
||||
h4 {
|
||||
margin: 0 0 var(--spacing-sm) 0;
|
||||
color: var(--color-text);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
}
|
||||
|
||||
.security-tips {
|
||||
ul {
|
||||
margin: 0;
|
||||
padding-left: var(--spacing-md);
|
||||
color: var(--color-text-secondary);
|
||||
font-size: var(--font-size-sm);
|
||||
|
||||
li {
|
||||
margin-bottom: var(--spacing-sm);
|
||||
line-height: 1.5;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.examples-section {
|
||||
margin-top: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.examples-toggle {
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: var(--radius-md);
|
||||
padding: var(--spacing-sm);
|
||||
|
||||
summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
cursor: pointer;
|
||||
color: var(--color-text);
|
||||
font-weight: 600;
|
||||
|
||||
&:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.examples-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: var(--spacing-md);
|
||||
margin-top: var(--spacing-md);
|
||||
|
||||
@media (max-width: 768px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.example-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: var(--spacing-sm);
|
||||
padding: var(--spacing-md);
|
||||
background: var(--bg-primary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
text-align: left;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--color-primary);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px color-mix(in srgb, var(--color-primary) 20%, transparent);
|
||||
}
|
||||
|
||||
&.selected {
|
||||
border-color: var(--color-primary);
|
||||
background: color-mix(in srgb, var(--color-primary) 5%, transparent);
|
||||
}
|
||||
|
||||
.example-header strong {
|
||||
color: var(--color-primary);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.example-description {
|
||||
margin: 0;
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--color-text-secondary);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.example-config {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xs);
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--color-text-secondary);
|
||||
width: 100%;
|
||||
|
||||
code {
|
||||
font-family: var(--font-mono);
|
||||
background: var(--bg-tertiary);
|
||||
padding: 2px var(--spacing-xs);
|
||||
border-radius: var(--radius-xs);
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.fingerprint-preview {
|
||||
word-break: break-all;
|
||||
}
|
||||
}
|
||||
|
||||
.copy-btn, .export-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
padding: var(--spacing-xs) var(--spacing-sm);
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
font-size: var(--font-size-sm);
|
||||
transition: all 0.3s ease;
|
||||
transform: scale(1);
|
||||
|
||||
&.success {
|
||||
background: var(--color-success) !important;
|
||||
color: var(--bg-secondary) !important;
|
||||
transform: scale(1.05);
|
||||
|
||||
&:hover {
|
||||
background: var(--color-success) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.copy-btn {
|
||||
background: var(--color-primary);
|
||||
color: var(--bg-secondary);
|
||||
|
||||
&:hover:not(.success) {
|
||||
background: var(--color-primary-hover);
|
||||
}
|
||||
}
|
||||
|
||||
.export-btn {
|
||||
background: var(--color-success);
|
||||
color: var(--bg-secondary);
|
||||
|
||||
&:hover:not(.success) {
|
||||
background: var(--color-success-hover);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,971 @@
|
||||
<script lang="ts">
|
||||
import Icon from '$lib/components/global/Icon.svelte';
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
|
||||
interface ServiceParameter {
|
||||
key: string;
|
||||
value: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
interface ServiceRecord {
|
||||
recordType: 'SVCB' | 'HTTPS';
|
||||
priority: number;
|
||||
targetName: string;
|
||||
parameters: ServiceParameter[];
|
||||
}
|
||||
|
||||
let domain = $state('example.com');
|
||||
let recordType = $state<'SVCB' | 'HTTPS'>('HTTPS');
|
||||
let priority = $state(1);
|
||||
let targetName = $state('.');
|
||||
|
||||
let parameters = $state<ServiceParameter[]>([
|
||||
{ key: 'mandatory', value: '', enabled: false },
|
||||
{ key: 'alpn', value: '', enabled: false },
|
||||
{ key: 'no-default-alpn', value: '', enabled: false },
|
||||
{ key: 'port', value: '', enabled: false },
|
||||
{ key: 'ipv4hint', value: '', enabled: false },
|
||||
{ key: 'ech', value: '', enabled: false },
|
||||
{ key: 'ipv6hint', value: '', enabled: false }
|
||||
]);
|
||||
|
||||
let showExamples = $state(false);
|
||||
let selectedExample = $state<string | null>(null);
|
||||
|
||||
// Button success states
|
||||
let buttonStates = $state<Record<string, boolean>>({});
|
||||
|
||||
const parameterDescriptions = {
|
||||
mandatory: 'Mandatory parameters that must be understood by the client',
|
||||
alpn: 'Application-Layer Protocol Negotiation identifiers (e.g., h2, h3)',
|
||||
'no-default-alpn': 'Indicates that no default ALPN should be assumed',
|
||||
port: 'Alternative port number for the service',
|
||||
ipv4hint: 'IPv4 address hints to avoid additional DNS lookups',
|
||||
ech: 'Encrypted Client Hello configuration',
|
||||
ipv6hint: 'IPv6 address hints to avoid additional DNS lookups'
|
||||
};
|
||||
|
||||
const parameterKeyMap: Record<string, number> = {
|
||||
mandatory: 0,
|
||||
alpn: 1,
|
||||
'no-default-alpn': 2,
|
||||
port: 3,
|
||||
ipv4hint: 4,
|
||||
ech: 5,
|
||||
ipv6hint: 6
|
||||
};
|
||||
|
||||
const serviceRecord = $derived.by((): ServiceRecord => {
|
||||
const enabledParams = parameters.filter(p => p.enabled && (p.value.trim() || p.key === 'no-default-alpn'));
|
||||
|
||||
return {
|
||||
recordType,
|
||||
priority,
|
||||
targetName: targetName.trim() || '.',
|
||||
parameters: enabledParams
|
||||
};
|
||||
});
|
||||
|
||||
const dnsRecord = $derived.by(() => {
|
||||
const record = serviceRecord;
|
||||
const target = record.targetName === '.' ? '.' : record.targetName;
|
||||
|
||||
let recordString = `${domain}. IN ${record.recordType} ${record.priority} ${target}`;
|
||||
|
||||
if (record.parameters.length > 0) {
|
||||
const paramStrings = record.parameters.map(param => {
|
||||
const keyNum = parameterKeyMap[param.key];
|
||||
if (param.key === 'no-default-alpn') {
|
||||
return `${param.key}`;
|
||||
} else if (param.key === 'alpn') {
|
||||
// Format ALPN values as comma-separated quoted strings
|
||||
const alpnValues = param.value.split(',').map(v => v.trim()).filter(v => v);
|
||||
return `${param.key}=${alpnValues.join(',')}`;
|
||||
} else if (param.key === 'ipv4hint' || param.key === 'ipv6hint') {
|
||||
// Format IP hints as comma-separated values
|
||||
const ipValues = param.value.split(',').map(v => v.trim()).filter(v => v);
|
||||
return `${param.key}=${ipValues.join(',')}`;
|
||||
} else {
|
||||
return `${param.key}=${param.value.trim()}`;
|
||||
}
|
||||
});
|
||||
|
||||
recordString += ` ${paramStrings.join(' ')}`;
|
||||
}
|
||||
|
||||
return recordString;
|
||||
});
|
||||
|
||||
const validation = $derived.by(() => {
|
||||
const warnings: string[] = [];
|
||||
const errors: string[] = [];
|
||||
|
||||
// Check domain format
|
||||
if (!domain.trim()) {
|
||||
errors.push('Domain is required');
|
||||
} else if (!domain.includes('.')) {
|
||||
warnings.push('Domain should include TLD (e.g., .com, .org)');
|
||||
}
|
||||
|
||||
// Check priority
|
||||
if (priority < 0 || priority > 65535) {
|
||||
errors.push('Priority must be between 0 and 65535');
|
||||
}
|
||||
|
||||
if (priority === 0 && targetName !== '.') {
|
||||
warnings.push('Priority 0 should typically use "." as target (alias mode)');
|
||||
}
|
||||
|
||||
// Check target name
|
||||
if (targetName && targetName !== '.' && !targetName.includes('.')) {
|
||||
warnings.push('Target name should be a FQDN or "." for same domain');
|
||||
}
|
||||
|
||||
// Validate parameters
|
||||
const enabledParams = parameters.filter(p => p.enabled);
|
||||
|
||||
for (const param of enabledParams) {
|
||||
if (param.key === 'port') {
|
||||
const port = parseInt(param.value);
|
||||
if (isNaN(port) || port < 1 || port > 65535) {
|
||||
errors.push('Port must be a number between 1 and 65535');
|
||||
}
|
||||
}
|
||||
|
||||
if (param.key === 'alpn' && !param.value.trim()) {
|
||||
errors.push('ALPN parameter requires at least one protocol identifier');
|
||||
}
|
||||
|
||||
if (param.key === 'ipv4hint') {
|
||||
const ips = param.value.split(',').map(ip => ip.trim());
|
||||
for (const ip of ips) {
|
||||
if (ip && !/^(\d{1,3}\.){3}\d{1,3}$/.test(ip)) {
|
||||
errors.push(`Invalid IPv4 address in ipv4hint: ${ip}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (param.key === 'ipv6hint') {
|
||||
const ips = param.value.split(',').map(ip => ip.trim());
|
||||
for (const ip of ips) {
|
||||
if (ip && !ip.includes(':')) {
|
||||
errors.push(`Invalid IPv6 address in ipv6hint: ${ip}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for conflicting parameters
|
||||
const hasAlpn = enabledParams.some(p => p.key === 'alpn');
|
||||
const hasNoDefaultAlpn = enabledParams.some(p => p.key === 'no-default-alpn');
|
||||
|
||||
if (hasAlpn && hasNoDefaultAlpn) {
|
||||
warnings.push('Using both alpn and no-default-alpn may cause conflicts');
|
||||
}
|
||||
|
||||
// Check record type specific recommendations
|
||||
if (recordType === 'HTTPS' && priority > 0) {
|
||||
const hasPort = enabledParams.some(p => p.key === 'port');
|
||||
if (!hasPort) {
|
||||
warnings.push('HTTPS records typically benefit from port parameter');
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
isValid: errors.length === 0,
|
||||
errors,
|
||||
warnings,
|
||||
parameterCount: enabledParams.length
|
||||
};
|
||||
});
|
||||
|
||||
function showButtonSuccess(buttonId: string): void {
|
||||
buttonStates[buttonId] = true;
|
||||
setTimeout(() => {
|
||||
buttonStates[buttonId] = false;
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
function copyToClipboard(text: string, buttonId: string): void {
|
||||
navigator.clipboard.writeText(text);
|
||||
showButtonSuccess(buttonId);
|
||||
}
|
||||
|
||||
function exportAsZoneFile(): void {
|
||||
if (!dnsRecord) return;
|
||||
|
||||
const zoneContent = dnsRecord;
|
||||
const blob = new Blob([zoneContent], { type: 'text/plain' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `${domain}-${recordType.toLowerCase()}-record.zone`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
showButtonSuccess('export-svcb');
|
||||
}
|
||||
|
||||
function addParameter(key: string): void {
|
||||
const param = parameters.find(p => p.key === key);
|
||||
if (param) {
|
||||
param.enabled = true;
|
||||
parameters = parameters;
|
||||
}
|
||||
}
|
||||
|
||||
const exampleConfigurations = [
|
||||
{
|
||||
name: 'HTTPS with HTTP/2',
|
||||
description: 'Basic HTTPS service with HTTP/2 support',
|
||||
recordType: 'HTTPS' as const,
|
||||
domain: 'example.com',
|
||||
priority: 1,
|
||||
targetName: '.',
|
||||
parameters: [
|
||||
{ key: 'alpn', value: 'h2,h3', enabled: true },
|
||||
{ key: 'port', value: '443', enabled: true }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'CDN Endpoint',
|
||||
description: 'HTTPS service pointing to CDN with IP hints',
|
||||
recordType: 'HTTPS' as const,
|
||||
domain: 'www.example.com',
|
||||
priority: 1,
|
||||
targetName: 'cdn.example.com',
|
||||
parameters: [
|
||||
{ key: 'alpn', value: 'h2', enabled: true },
|
||||
{ key: 'ipv4hint', value: '203.0.113.1,203.0.113.2', enabled: true },
|
||||
{ key: 'port', value: '443', enabled: true }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'Alternative Service',
|
||||
description: 'Alternative HTTPS service on different port',
|
||||
recordType: 'HTTPS' as const,
|
||||
domain: 'api.example.com',
|
||||
priority: 2,
|
||||
targetName: 'api-alt.example.com',
|
||||
parameters: [
|
||||
{ key: 'alpn', value: 'h2', enabled: true },
|
||||
{ key: 'port', value: '8443', enabled: true },
|
||||
{ key: 'ipv4hint', value: '203.0.113.10', enabled: true }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
function loadExample(example: typeof exampleConfigurations[0]): void {
|
||||
domain = example.domain;
|
||||
recordType = example.recordType;
|
||||
priority = example.priority;
|
||||
targetName = example.targetName;
|
||||
|
||||
// Reset all parameters
|
||||
parameters = parameters.map(p => ({ ...p, enabled: false, value: '' }));
|
||||
|
||||
// Set example parameters
|
||||
for (const exampleParam of example.parameters) {
|
||||
const param = parameters.find(p => p.key === exampleParam.key);
|
||||
if (param) {
|
||||
param.enabled = exampleParam.enabled;
|
||||
param.value = exampleParam.value;
|
||||
}
|
||||
}
|
||||
parameters = parameters;
|
||||
selectedExample = example.name;
|
||||
}
|
||||
|
||||
const usageNotes = [
|
||||
'Priority 0 creates an alias record (AliasMode), priority >0 creates a service record (ServiceMode)',
|
||||
'Use "." as target name to indicate the same domain as the owner name',
|
||||
'ALPN values should match the protocols actually supported by the service',
|
||||
'IP hints can improve connection performance by avoiding additional DNS lookups',
|
||||
'ECH parameter enables Encrypted Client Hello for enhanced privacy'
|
||||
];
|
||||
</script>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h1>SVCB/HTTPS Builder</h1>
|
||||
<p class="card-subtitle">
|
||||
Build SVCB and HTTPS resource records with service parameters for enhanced service discovery and connection optimization.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="grid-layout">
|
||||
<div class="input-section">
|
||||
<div class="service-config-section">
|
||||
<div class="section-header">
|
||||
<h3>
|
||||
<Icon name="globe" size="sm" />
|
||||
Service Configuration
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="service-config-grid">
|
||||
<div class="input-group">
|
||||
<label for="domain" use:tooltip={"Domain name for the SVCB/HTTPS record"}>
|
||||
Domain:
|
||||
</label>
|
||||
<input
|
||||
id="domain"
|
||||
type="text"
|
||||
bind:value={domain}
|
||||
placeholder="example.com"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="recordType" use:tooltip={"Record type: HTTPS for HTTP services, SVCB for general services"}>
|
||||
Record Type:
|
||||
</label>
|
||||
<select id="recordType" bind:value={recordType}>
|
||||
<option value="HTTPS">HTTPS</option>
|
||||
<option value="SVCB">SVCB</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="priority" use:tooltip={"Priority: 0 for alias mode, >0 for service mode"}>
|
||||
Priority:
|
||||
</label>
|
||||
<input
|
||||
id="priority"
|
||||
type="number"
|
||||
bind:value={priority}
|
||||
min="0"
|
||||
max="65535"
|
||||
placeholder="1"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="targetName" use:tooltip={"Target domain name or '.' for same domain"}>
|
||||
Target Name:
|
||||
</label>
|
||||
<input
|
||||
id="targetName"
|
||||
type="text"
|
||||
bind:value={targetName}
|
||||
placeholder=". (same domain)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="parameters-section">
|
||||
<div class="section-header">
|
||||
<h3>
|
||||
<Icon name="settings" size="sm" />
|
||||
Service Parameters
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="parameters-list">
|
||||
{#each parameters as parameter}
|
||||
<div class="parameter-item" class:enabled={parameter.enabled}>
|
||||
<div class="parameter-header">
|
||||
<label class="parameter-toggle">
|
||||
<input type="checkbox" bind:checked={parameter.enabled} />
|
||||
<span class="parameter-name">{parameter.key}</span>
|
||||
<span class="parameter-description" use:tooltip={parameterDescriptions[parameter.key]}>
|
||||
{parameterDescriptions[parameter.key]}
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{#if parameter.key !== 'no-default-alpn'}
|
||||
<div class="parameter-value">
|
||||
<input
|
||||
type="text"
|
||||
bind:value={parameter.value}
|
||||
disabled={!parameter.enabled}
|
||||
placeholder={parameter.key === 'alpn' ? 'h2,h3' :
|
||||
parameter.key === 'port' ? '443' :
|
||||
parameter.key === 'ipv4hint' ? '203.0.113.1,203.0.113.2' :
|
||||
parameter.key === 'ipv6hint' ? '2001:db8::1,2001:db8::2' :
|
||||
parameter.key === 'ech' ? 'base64-encoded-config' :
|
||||
parameter.key === 'mandatory' ? '1,3' : 'value'}
|
||||
class="parameter-input"
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="results-section">
|
||||
<div class="record-section">
|
||||
<div class="section-header">
|
||||
<h3>Generated {recordType} Record</h3>
|
||||
<div class="actions">
|
||||
<button
|
||||
type="button"
|
||||
class="copy-btn"
|
||||
class:success={buttonStates['copy-svcb']}
|
||||
onclick={() => copyToClipboard(dnsRecord, 'copy-svcb')}
|
||||
use:tooltip={"Copy record to clipboard"}
|
||||
>
|
||||
<Icon name={buttonStates['copy-svcb'] ? "check" : "copy"} size="sm" />
|
||||
{buttonStates['copy-svcb'] ? 'Copied!' : 'Copy'}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="export-btn"
|
||||
class:success={buttonStates['export-svcb']}
|
||||
onclick={exportAsZoneFile}
|
||||
use:tooltip={"Download as zone file"}
|
||||
>
|
||||
<Icon name={buttonStates['export-svcb'] ? "check" : "download"} size="sm" />
|
||||
{buttonStates['export-svcb'] ? 'Downloaded!' : 'Export'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="record-output">
|
||||
<div class="code-block">
|
||||
<code>{dnsRecord}</code>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="record-breakdown">
|
||||
<h4>Record Breakdown:</h4>
|
||||
<div class="breakdown-grid">
|
||||
<div class="breakdown-item">
|
||||
<strong>Type:</strong> {recordType}
|
||||
</div>
|
||||
<div class="breakdown-item">
|
||||
<strong>Priority:</strong> {priority} ({priority === 0 ? 'Alias Mode' : 'Service Mode'})
|
||||
</div>
|
||||
<div class="breakdown-item">
|
||||
<strong>Target:</strong> {serviceRecord.targetName}
|
||||
</div>
|
||||
<div class="breakdown-item">
|
||||
<strong>Parameters:</strong> {validation.parameterCount}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="validation-section">
|
||||
<div class="section-header">
|
||||
<h3>
|
||||
<Icon name="bar-chart" size="sm" />
|
||||
Validation
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="validation-status">
|
||||
<div class="status-item">
|
||||
<span class="status-label">Status:</span>
|
||||
<span class="status-value" class:success={validation.isValid} class:error={!validation.isValid}>
|
||||
{validation.isValid ? 'Valid' : 'Invalid'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if validation.errors.length > 0}
|
||||
<div class="validation-messages error">
|
||||
<Icon name="x-circle" size="sm" />
|
||||
<div class="messages">
|
||||
{#each validation.errors as error}
|
||||
<div class="message">{error}</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if validation.warnings.length > 0}
|
||||
<div class="validation-messages warning">
|
||||
<Icon name="alert-triangle" size="sm" />
|
||||
<div class="messages">
|
||||
{#each validation.warnings as warning}
|
||||
<div class="message">{warning}</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if validation.isValid && validation.errors.length === 0 && validation.warnings.length === 0}
|
||||
<div class="validation-messages success">
|
||||
<Icon name="check-circle" size="sm" />
|
||||
<div class="message">{recordType} record is valid and ready to deploy!</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="usage-guide">
|
||||
<div class="section-header">
|
||||
<h3>
|
||||
<Icon name="info" size="sm" />
|
||||
Usage Notes
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="usage-tips">
|
||||
<ul>
|
||||
{#each usageNotes as note}
|
||||
<li>{note}</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="examples-section">
|
||||
<details class="examples-toggle" bind:open={showExamples}>
|
||||
<summary>
|
||||
<Icon name="lightbulb" size="sm" />
|
||||
Example Configurations
|
||||
</summary>
|
||||
<div class="examples-grid">
|
||||
{#each exampleConfigurations as example}
|
||||
<button
|
||||
type="button"
|
||||
class="example-card"
|
||||
class:selected={selectedExample === example.name}
|
||||
onclick={() => loadExample(example)}
|
||||
>
|
||||
<div class="example-header">
|
||||
<strong>{example.name}</strong>
|
||||
</div>
|
||||
<p class="example-description">{example.description}</p>
|
||||
<div class="example-config">
|
||||
<div>Type: <code>{example.recordType}</code>, Priority: <code>{example.priority}</code></div>
|
||||
<div>Target: <code>{example.targetName}</code></div>
|
||||
<div class="example-params">
|
||||
Params: {example.parameters.map(p => `${p.key}=${p.value}`).join(', ')}
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
.service-config-section, .parameters-section {
|
||||
margin-bottom: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: var(--spacing-md);
|
||||
|
||||
h3, h4 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
margin: 0;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
}
|
||||
|
||||
.service-config-grid {
|
||||
display: grid;
|
||||
gap: var(--spacing-md);
|
||||
|
||||
@media (min-width: 768px) {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.input-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xs);
|
||||
|
||||
label {
|
||||
font-weight: 600;
|
||||
color: var(--color-text);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
input, select {
|
||||
padding: var(--spacing-sm);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-sm);
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--color-primary);
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 20%, transparent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.parameters-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.parameter-item {
|
||||
padding: var(--spacing-sm);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--bg-tertiary);
|
||||
opacity: 0.7;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&.enabled {
|
||||
opacity: 1;
|
||||
border-color: color-mix(in srgb, var(--color-primary) 30%, transparent);
|
||||
filter: brightness(1.1);
|
||||
}
|
||||
}
|
||||
|
||||
.parameter-header {
|
||||
margin-bottom: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.parameter-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
|
||||
input[type="checkbox"] {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
accent-color: var(--color-primary);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.parameter-name {
|
||||
font-weight: 600;
|
||||
font-family: var(--font-mono);
|
||||
color: var(--color-primary);
|
||||
min-width: 120px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.parameter-description {
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--color-text-secondary);
|
||||
font-style: italic;
|
||||
margin-left: var(--spacing-xs);
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.parameter-value {
|
||||
margin-left: calc(16px + var(--spacing-xs));
|
||||
}
|
||||
|
||||
.parameter-input {
|
||||
width: 100%;
|
||||
padding: var(--spacing-xs);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-sm);
|
||||
|
||||
&:disabled {
|
||||
background: var(--color-surface-disabled);
|
||||
color: var(--color-text-disabled);
|
||||
}
|
||||
|
||||
&:focus {
|
||||
outline: none;
|
||||
border-color: var(--color-primary);
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 20%, transparent);
|
||||
}
|
||||
}
|
||||
|
||||
.record-breakdown {
|
||||
margin-top: var(--spacing-md);
|
||||
|
||||
h4 {
|
||||
margin: 0 0 var(--spacing-sm) 0;
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.breakdown-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||
gap: var(--spacing-sm);
|
||||
|
||||
@media (max-width: 768px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.breakdown-item {
|
||||
padding: var(--spacing-xs) var(--spacing-sm);
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: var(--font-size-sm);
|
||||
|
||||
strong {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.code-block {
|
||||
background: var(--bg-primary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
padding: var(--spacing-sm);
|
||||
margin-bottom: var(--spacing-sm);
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-sm);
|
||||
word-break: break-all;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.validation-status {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-bottom: var(--spacing-md);
|
||||
}
|
||||
|
||||
.status-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-sm);
|
||||
padding: var(--spacing-sm);
|
||||
background: var(--bg-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.status-label {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.status-value {
|
||||
font-weight: 600;
|
||||
font-family: var(--font-mono);
|
||||
|
||||
&.success {
|
||||
color: var(--color-success);
|
||||
}
|
||||
|
||||
&.error {
|
||||
color: var(--color-error);
|
||||
}
|
||||
}
|
||||
|
||||
.validation-messages {
|
||||
display: flex;
|
||||
gap: var(--spacing-xs);
|
||||
padding: var(--spacing-sm);
|
||||
border-radius: var(--radius-md);
|
||||
margin-bottom: var(--spacing-sm);
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&.success {
|
||||
background: color-mix(in srgb, var(--color-success) 10%, transparent);
|
||||
border: 1px solid color-mix(in srgb, var(--color-success) 30%, transparent);
|
||||
color: var(--color-success);
|
||||
}
|
||||
|
||||
&.warning {
|
||||
background: color-mix(in srgb, var(--color-warning) 10%, transparent);
|
||||
border: 1px solid color-mix(in srgb, var(--color-warning) 30%, transparent);
|
||||
color: var(--color-warning);
|
||||
}
|
||||
|
||||
&.error {
|
||||
background: color-mix(in srgb, var(--color-error) 10%, transparent);
|
||||
border: 1px solid color-mix(in srgb, var(--color-error) 30%, transparent);
|
||||
color: var(--color-error);
|
||||
}
|
||||
|
||||
.messages {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.message {
|
||||
font-size: var(--font-size-sm);
|
||||
margin-bottom: var(--spacing-xs);
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.usage-tips {
|
||||
ul {
|
||||
margin: 0;
|
||||
padding-left: var(--spacing-md);
|
||||
color: var(--color-text-secondary);
|
||||
font-size: var(--font-size-sm);
|
||||
|
||||
li {
|
||||
margin-bottom: var(--spacing-sm);
|
||||
line-height: 1.5;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.examples-section {
|
||||
margin-top: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.examples-toggle {
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: var(--radius-md);
|
||||
padding: var(--spacing-sm);
|
||||
|
||||
summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
cursor: pointer;
|
||||
color: var(--color-text);
|
||||
font-weight: 600;
|
||||
|
||||
&:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.examples-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
|
||||
gap: var(--spacing-md);
|
||||
margin-top: var(--spacing-md);
|
||||
|
||||
@media (max-width: 768px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.example-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: var(--spacing-sm);
|
||||
padding: var(--spacing-md);
|
||||
background: var(--bg-primary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
text-align: left;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--color-primary);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px color-mix(in srgb, var(--color-primary) 20%, transparent);
|
||||
}
|
||||
|
||||
&.selected {
|
||||
border-color: var(--color-primary);
|
||||
background: color-mix(in srgb, var(--color-primary) 5%, transparent);
|
||||
}
|
||||
|
||||
.example-header strong {
|
||||
color: var(--color-primary);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.example-description {
|
||||
margin: 0;
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--color-text-secondary);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.example-config {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xs);
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--color-text-secondary);
|
||||
width: 100%;
|
||||
|
||||
code {
|
||||
font-family: var(--font-mono);
|
||||
background: var(--bg-tertiary);
|
||||
padding: 2px var(--spacing-xs);
|
||||
border-radius: var(--radius-xs);
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.example-params {
|
||||
word-break: break-all;
|
||||
font-size: var(--font-size-xs);
|
||||
}
|
||||
}
|
||||
|
||||
.copy-btn, .export-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
padding: var(--spacing-xs) var(--spacing-sm);
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
font-size: var(--font-size-sm);
|
||||
transition: all 0.3s ease;
|
||||
transform: scale(1);
|
||||
|
||||
&.success {
|
||||
background: var(--color-success) !important;
|
||||
color: var(--bg-secondary) !important;
|
||||
transform: scale(1.05);
|
||||
|
||||
&:hover {
|
||||
background: var(--color-success) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.copy-btn {
|
||||
background: var(--color-primary);
|
||||
color: var(--bg-secondary);
|
||||
|
||||
&:hover:not(.success) {
|
||||
background: var(--color-primary-hover);
|
||||
}
|
||||
}
|
||||
|
||||
.export-btn {
|
||||
background: var(--color-success);
|
||||
color: var(--bg-secondary);
|
||||
|
||||
&:hover:not(.success) {
|
||||
background: var(--color-success-hover);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,930 @@
|
||||
<script>
|
||||
import Icon from '$lib/components/global/Icon.svelte';
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
|
||||
let domain = $state('example.com');
|
||||
let port = $state(443);
|
||||
let protocol = $state('tcp');
|
||||
let inputType = $state('certificate');
|
||||
let certificateInput = $state('');
|
||||
let hashInput = $state('');
|
||||
|
||||
let usage = $state(3);
|
||||
let selector = $state(1);
|
||||
let matchingType = $state(1);
|
||||
|
||||
let showExamples = $state(false);
|
||||
let selectedExample = $state(null);
|
||||
let buttonStates = $state({});
|
||||
|
||||
const usageDescriptions = {
|
||||
0: 'CA Constraint - Certificate must be issued by the CA represented in the TLSA record',
|
||||
1: 'Service Certificate Constraint - Certificate must match the one in the TLSA record',
|
||||
2: 'Trust Anchor Assertion - Certificate must chain to the CA in the TLSA record',
|
||||
3: 'Domain-Issued Certificate - Certificate must match the one specified (most common)'
|
||||
};
|
||||
|
||||
const selectorDescriptions = {
|
||||
0: 'Full Certificate - Use the entire certificate',
|
||||
1: 'Subject Public Key Info - Use only the public key portion (recommended)'
|
||||
};
|
||||
|
||||
const matchingTypeDescriptions = {
|
||||
0: 'Exact Match - Use the certificate/key data as-is (not recommended)',
|
||||
1: 'SHA-256 Hash - Use SHA-256 hash of the certificate/key (recommended)',
|
||||
2: 'SHA-512 Hash - Use SHA-512 hash of the certificate/key'
|
||||
};
|
||||
|
||||
const tlsaRecord = $derived.by(() => {
|
||||
let associationData = '';
|
||||
|
||||
if (inputType === 'hash') {
|
||||
associationData = hashInput.trim().replace(/[^a-fA-F0-9]/g, '').toLowerCase();
|
||||
} else if (inputType === 'certificate') {
|
||||
if (certificateInput.trim()) {
|
||||
associationData = 'Generated hash would appear here (requires certificate parsing)';
|
||||
}
|
||||
}
|
||||
|
||||
if (!associationData) return null;
|
||||
|
||||
return {
|
||||
usage,
|
||||
selector,
|
||||
matchingType,
|
||||
certificateAssociation: associationData
|
||||
};
|
||||
});
|
||||
|
||||
const dnsRecord = $derived.by(() => {
|
||||
if (!tlsaRecord) return '';
|
||||
return `_${port}._${protocol}.${domain}. IN TLSA ${tlsaRecord.usage} ${tlsaRecord.selector} ${tlsaRecord.matchingType} ${tlsaRecord.certificateAssociation}`;
|
||||
});
|
||||
|
||||
const validation = $derived.by(() => {
|
||||
const warnings = [];
|
||||
const errors = [];
|
||||
|
||||
if (!domain.trim()) {
|
||||
errors.push('Domain is required');
|
||||
} else if (!domain.includes('.')) {
|
||||
warnings.push('Domain should include TLD (e.g., .com, .org)');
|
||||
}
|
||||
|
||||
if (port < 1 || port > 65535) {
|
||||
errors.push('Port must be between 1 and 65535');
|
||||
}
|
||||
|
||||
if (inputType === 'certificate') {
|
||||
if (!certificateInput.trim()) {
|
||||
errors.push('Certificate data is required');
|
||||
} else if (!certificateInput.includes('BEGIN CERTIFICATE') && !certificateInput.includes('BEGIN PUBLIC KEY')) {
|
||||
warnings.push('Certificate should be in PEM format');
|
||||
}
|
||||
} else if (inputType === 'hash') {
|
||||
if (!hashInput.trim()) {
|
||||
errors.push('Hash value is required');
|
||||
} else {
|
||||
const cleanHash = hashInput.trim().replace(/[^a-fA-F0-9]/g, '');
|
||||
if (matchingType === 1 && cleanHash.length !== 64) {
|
||||
warnings.push('SHA-256 hash should be exactly 64 hexadecimal characters');
|
||||
} else if (matchingType === 2 && cleanHash.length !== 128) {
|
||||
warnings.push('SHA-512 hash should be exactly 128 hexadecimal characters');
|
||||
} else if (!/^[a-fA-F0-9]+$/.test(cleanHash)) {
|
||||
errors.push('Hash must contain only hexadecimal characters');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (usage === 0 || usage === 2) {
|
||||
warnings.push('Usage types 0 and 2 require careful CA certificate management');
|
||||
}
|
||||
|
||||
if (selector === 0) {
|
||||
warnings.push('Full certificate selector (0) is less flexible than SPKI selector (1)');
|
||||
}
|
||||
|
||||
if (matchingType === 0) {
|
||||
warnings.push('Exact match (0) is not recommended - use SHA-256 (1) or SHA-512 (2)');
|
||||
}
|
||||
|
||||
return {
|
||||
isValid: errors.length === 0,
|
||||
errors,
|
||||
warnings
|
||||
};
|
||||
});
|
||||
|
||||
function showButtonSuccess(buttonId) {
|
||||
buttonStates[buttonId] = true;
|
||||
setTimeout(() => {
|
||||
buttonStates[buttonId] = false;
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
function copyToClipboard(text, buttonId) {
|
||||
navigator.clipboard.writeText(text);
|
||||
showButtonSuccess(buttonId);
|
||||
}
|
||||
|
||||
function exportAsZoneFile() {
|
||||
if (!dnsRecord) return;
|
||||
|
||||
const zoneContent = dnsRecord;
|
||||
const blob = new Blob([zoneContent], { type: 'text/plain' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `${domain}-tlsa-record.zone`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
showButtonSuccess('export-tlsa');
|
||||
}
|
||||
|
||||
async function generateHashFromInput() {
|
||||
if (inputType === 'certificate' && certificateInput.trim()) {
|
||||
const demoHash = matchingType === 1
|
||||
? 'abcd1234567890abcdef1234567890abcdef1234567890abcdef1234567890ab'
|
||||
: 'abcd1234567890abcdef1234567890abcdef1234567890abcdef1234567890ab1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef';
|
||||
|
||||
hashInput = demoHash;
|
||||
inputType = 'hash';
|
||||
}
|
||||
}
|
||||
|
||||
const exampleConfigurations = [
|
||||
{
|
||||
name: 'HTTPS Certificate Pin',
|
||||
description: 'Pin a specific certificate for HTTPS',
|
||||
domain: 'example.com',
|
||||
port: 443,
|
||||
protocol: 'tcp',
|
||||
usage: 3,
|
||||
selector: 1,
|
||||
matchingType: 1,
|
||||
hash: 'a1b2c3d4e5f67890abcdef1234567890abcdef1234567890abcdef1234567890'
|
||||
},
|
||||
{
|
||||
name: 'SMTP TLS Certificate',
|
||||
description: 'DANE for email server TLS',
|
||||
domain: 'mail.example.com',
|
||||
port: 587,
|
||||
protocol: 'tcp',
|
||||
usage: 3,
|
||||
selector: 1,
|
||||
matchingType: 1,
|
||||
hash: 'fedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321'
|
||||
},
|
||||
{
|
||||
name: 'CA Trust Anchor',
|
||||
description: 'Trust anchor for certificate authority',
|
||||
domain: 'secure.example.com',
|
||||
port: 443,
|
||||
protocol: 'tcp',
|
||||
usage: 2,
|
||||
selector: 1,
|
||||
matchingType: 2,
|
||||
hash: 'abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890'
|
||||
}
|
||||
];
|
||||
|
||||
function loadExample(example) {
|
||||
domain = example.domain;
|
||||
port = example.port;
|
||||
protocol = example.protocol;
|
||||
usage = example.usage;
|
||||
selector = example.selector;
|
||||
matchingType = example.matchingType;
|
||||
hashInput = example.hash;
|
||||
inputType = 'hash';
|
||||
certificateInput = '';
|
||||
selectedExample = example.name;
|
||||
}
|
||||
|
||||
const securityTips = [
|
||||
'Use usage type 3 (Domain-Issued Certificate) for most scenarios',
|
||||
'Prefer selector 1 (SPKI) over selector 0 (full certificate) for flexibility',
|
||||
'Use SHA-256 (1) or SHA-512 (2) matching types, avoid exact match (0)',
|
||||
'Pin multiple certificates to avoid service disruption during certificate rotation',
|
||||
'Test TLSA records with DANE validation tools before deployment'
|
||||
];
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h1>TLSA Generator</h1>
|
||||
<p>Create TLSA (DNS-based Authentication of Named Entities) records for certificate pinning and DANE implementation.</p>
|
||||
</div>
|
||||
|
||||
<div class="main-grid">
|
||||
<div class="input-section">
|
||||
<!-- Service Configuration -->
|
||||
<div class="card sub-card">
|
||||
<h3 class="section-title">
|
||||
<Icon name="globe" size="sm" />
|
||||
Service Configuration
|
||||
</h3>
|
||||
|
||||
<div class="service-grid">
|
||||
<div class="input-group">
|
||||
<label for="domain" use:tooltip={"Domain name for the TLSA record"}>Domain:</label>
|
||||
<input id="domain" type="text" bind:value={domain} placeholder="example.com" />
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="port" use:tooltip={"Port number for the service (e.g., 443 for HTTPS, 25 for SMTP)"}>Port:</label>
|
||||
<input id="port" type="number" bind:value={port} min="1" max="65535" placeholder="443" />
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="protocol" use:tooltip={"Protocol type (tcp or udp)"}>Protocol:</label>
|
||||
<select id="protocol" bind:value={protocol}>
|
||||
<option value="tcp">TCP</option>
|
||||
<option value="udp">UDP</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- TLSA Parameters -->
|
||||
<div class="card sub-card">
|
||||
<h3 class="section-title">
|
||||
<Icon name="settings" size="sm" />
|
||||
TLSA Parameters
|
||||
</h3>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="usage" use:tooltip={"Certificate usage - how the certificate should be used for authentication"}>Certificate Usage:</label>
|
||||
<select id="usage" bind:value={usage}>
|
||||
<option value={0}>0 - CA Constraint</option>
|
||||
<option value={1}>1 - Service Certificate Constraint</option>
|
||||
<option value={2}>2 - Trust Anchor Assertion</option>
|
||||
<option value={3}>3 - Domain-Issued Certificate</option>
|
||||
</select>
|
||||
<p class="description">{usageDescriptions[usage]}</p>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="selector" use:tooltip={"Which part of the certificate to use"}>Selector:</label>
|
||||
<select id="selector" bind:value={selector}>
|
||||
<option value={0}>0 - Full Certificate</option>
|
||||
<option value={1}>1 - Subject Public Key Info</option>
|
||||
</select>
|
||||
<p class="description">{selectorDescriptions[selector]}</p>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="matchingType" use:tooltip={"How to process the certificate data"}>Matching Type:</label>
|
||||
<select id="matchingType" bind:value={matchingType}>
|
||||
<option value={0}>0 - Exact Match</option>
|
||||
<option value={1}>1 - SHA-256 Hash</option>
|
||||
<option value={2}>2 - SHA-512 Hash</option>
|
||||
</select>
|
||||
<p class="description">{matchingTypeDescriptions[matchingType]}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Certificate Data -->
|
||||
<div class="card sub-card">
|
||||
<h3 class="section-title">
|
||||
<Icon name="key" size="sm" />
|
||||
Certificate Data
|
||||
</h3>
|
||||
|
||||
<div class="radio-group">
|
||||
<label class="radio-option">
|
||||
<input type="radio" bind:group={inputType} value="certificate" />
|
||||
<span>Certificate/Public Key (PEM)</span>
|
||||
</label>
|
||||
<label class="radio-option">
|
||||
<input type="radio" bind:group={inputType} value="hash" />
|
||||
<span>Hash Value</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{#if inputType === 'certificate'}
|
||||
<div class="input-group">
|
||||
<label for="certificate" use:tooltip={"Paste the PEM-encoded certificate or public key"}>Certificate/Public Key:</label>
|
||||
<textarea
|
||||
id="certificate"
|
||||
bind:value={certificateInput}
|
||||
placeholder="-----BEGIN CERTIFICATE----- MIIFXzCCA0egAwIBAgIJAKZ5QeHxw... -----END CERTIFICATE-----"
|
||||
rows="8"
|
||||
></textarea>
|
||||
<button
|
||||
type="button"
|
||||
onclick={generateHashFromInput}
|
||||
disabled={!certificateInput.trim()}
|
||||
class="btn btn-secondary"
|
||||
use:tooltip={"Generate hash from certificate (demo mode)"}
|
||||
>
|
||||
<Icon name="arrow-right" size="sm" />
|
||||
Generate Hash
|
||||
</button>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="input-group">
|
||||
<label for="hash" use:tooltip={`Enter the ${matchingType === 1 ? 'SHA-256' : matchingType === 2 ? 'SHA-512' : 'exact'} hash value`}>Hash Value:</label>
|
||||
<textarea
|
||||
id="hash"
|
||||
bind:value={hashInput}
|
||||
placeholder={matchingType === 1 ?
|
||||
'abcd1234567890abcdef1234567890abcdef1234567890abcdef1234567890ab' :
|
||||
matchingType === 2 ?
|
||||
'abcd1234567890abcdef1234567890abcdef1234567890abcdef1234567890ab1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef' :
|
||||
'Certificate or key data'
|
||||
}
|
||||
rows="3"
|
||||
></textarea>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="output-section">
|
||||
{#if tlsaRecord}
|
||||
<!-- Generated Record -->
|
||||
<div class="card">
|
||||
<div class="card-header-with-actions">
|
||||
<h3>Generated TLSA Record</h3>
|
||||
<div class="actions">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary"
|
||||
class:success={buttonStates['copy-tlsa']}
|
||||
onclick={() => copyToClipboard(dnsRecord, 'copy-tlsa')}
|
||||
use:tooltip={"Copy TLSA record to clipboard"}
|
||||
>
|
||||
<Icon name={buttonStates['copy-tlsa'] ? "check" : "copy"} size="sm" />
|
||||
{buttonStates['copy-tlsa'] ? 'Copied!' : 'Copy'}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-success"
|
||||
class:success={buttonStates['export-tlsa']}
|
||||
onclick={exportAsZoneFile}
|
||||
use:tooltip={"Download as zone file"}
|
||||
>
|
||||
<Icon name={buttonStates['export-tlsa'] ? "check" : "download"} size="sm" />
|
||||
{buttonStates['export-tlsa'] ? 'Downloaded!' : 'Export'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="code-block">
|
||||
<code>{dnsRecord}</code>
|
||||
</div>
|
||||
|
||||
<div class="breakdown">
|
||||
<h4>Record Breakdown:</h4>
|
||||
<div class="breakdown-grid">
|
||||
<div class="breakdown-item">
|
||||
<strong>Service:</strong> _{port}._{protocol}
|
||||
</div>
|
||||
<div class="breakdown-item">
|
||||
<strong>Usage:</strong> {usage} ({Object.values(usageDescriptions)[usage].split(' - ')[0]})
|
||||
</div>
|
||||
<div class="breakdown-item">
|
||||
<strong>Selector:</strong> {selector} ({Object.values(selectorDescriptions)[selector].split(' - ')[0]})
|
||||
</div>
|
||||
<div class="breakdown-item">
|
||||
<strong>Matching:</strong> {matchingType} ({Object.values(matchingTypeDescriptions)[matchingType].split(' - ')[0]})
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Validation -->
|
||||
<div class="card">
|
||||
<h3 class="section-title">
|
||||
<Icon name="bar-chart" size="sm" />
|
||||
Validation
|
||||
</h3>
|
||||
|
||||
<div class="status-center">
|
||||
<div class="status-item">
|
||||
<span>Status:</span>
|
||||
<span class="status" class:valid={validation.isValid} class:invalid={!validation.isValid}>
|
||||
{validation.isValid ? 'Valid' : 'Invalid'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if validation.errors.length > 0}
|
||||
<div class="message error">
|
||||
<Icon name="x-circle" size="sm" />
|
||||
<div>
|
||||
{#each validation.errors as error}
|
||||
<div>{error}</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if validation.warnings.length > 0}
|
||||
<div class="message warning">
|
||||
<Icon name="alert-triangle" size="sm" />
|
||||
<div>
|
||||
{#each validation.warnings as warning}
|
||||
<div>{warning}</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if validation.isValid && validation.errors.length === 0 && validation.warnings.length === 0}
|
||||
<div class="message success">
|
||||
<Icon name="check-circle" size="sm" />
|
||||
<div>TLSA record is valid and ready to deploy!</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Security Best Practices -->
|
||||
<div class="card">
|
||||
<h3 class="section-title">
|
||||
<Icon name="shield" size="sm" />
|
||||
Security Best Practices
|
||||
</h3>
|
||||
|
||||
<ul class="tips-list">
|
||||
{#each securityTips as tip}
|
||||
<li>{tip}</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Examples -->
|
||||
<div class="card examples-card">
|
||||
<details bind:open={showExamples}>
|
||||
<summary class="examples-summary">
|
||||
<Icon name="lightbulb" size="sm" />
|
||||
Example Configurations
|
||||
<Icon name="chevron-down" size="sm" class="chevron" />
|
||||
</summary>
|
||||
<div class="examples-grid">
|
||||
{#each exampleConfigurations as example}
|
||||
<button
|
||||
type="button"
|
||||
class="example-card"
|
||||
class:selected={selectedExample === example.name}
|
||||
onclick={() => loadExample(example)}
|
||||
>
|
||||
<div class="example-name">{example.name}</div>
|
||||
<p class="example-description">{example.description}</p>
|
||||
<div class="example-config">
|
||||
<div>Port: <code>{example.port}/{example.protocol}</code></div>
|
||||
<div>Usage: <code>{example.usage}</code>, Selector: <code>{example.selector}</code>, Type: <code>{example.matchingType}</code></div>
|
||||
</div>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.card {
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
padding: var(--spacing-lg);
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
}
|
||||
|
||||
.card-header h1 {
|
||||
color: var(--text-primary);
|
||||
font-size: var(--font-size-2xl);
|
||||
margin: 0 0 var(--spacing-sm) 0;
|
||||
}
|
||||
|
||||
.card-header p {
|
||||
color: var(--text-secondary);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.main-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: var(--spacing-lg);
|
||||
padding: var(--spacing-lg);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.main-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.input-section, .output-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
.sub-card {
|
||||
padding: var(--spacing-md);
|
||||
}
|
||||
|
||||
.section-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
color: var(--text-primary);
|
||||
font-size: var(--font-size-lg);
|
||||
margin: 0 0 var(--spacing-md) 0;
|
||||
}
|
||||
|
||||
.service-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
.input-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.input-group label {
|
||||
color: var(--text-primary);
|
||||
font-size: var(--font-size-sm);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.input-group input, .input-group select, .input-group textarea {
|
||||
padding: var(--spacing-sm);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.input-group input:focus, .input-group select:focus, .input-group textarea:focus {
|
||||
outline: none;
|
||||
border-color: var(--color-primary);
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 20%, transparent);
|
||||
}
|
||||
|
||||
.input-group textarea {
|
||||
resize: vertical;
|
||||
min-height: 80px;
|
||||
}
|
||||
|
||||
.description {
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--text-secondary);
|
||||
font-style: italic;
|
||||
margin-top: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.radio-group {
|
||||
display: flex;
|
||||
gap: var(--spacing-md);
|
||||
margin-bottom: var(--spacing-md);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.radio-group {
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
}
|
||||
|
||||
.radio-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
cursor: pointer;
|
||||
padding: var(--spacing-xs);
|
||||
border-radius: var(--radius-sm);
|
||||
transition: background-color var(--transition-fast);
|
||||
}
|
||||
|
||||
.radio-option:hover {
|
||||
background: var(--surface-hover);
|
||||
}
|
||||
|
||||
.radio-option input[type="radio"] {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.radio-option span {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
padding: var(--spacing-sm) var(--spacing-md);
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
font-size: var(--font-size-sm);
|
||||
transition: all var(--transition-normal);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.btn:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--color-primary);
|
||||
color: var(--bg-primary);
|
||||
}
|
||||
|
||||
.btn-primary:hover:not(:disabled) {
|
||||
background: var(--color-primary-hover);
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: var(--color-info);
|
||||
color: var(--bg-primary);
|
||||
}
|
||||
|
||||
.btn-secondary:hover:not(:disabled) {
|
||||
background: var(--color-info-light);
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
background: var(--color-success);
|
||||
color: var(--bg-primary);
|
||||
}
|
||||
|
||||
.btn-success:hover:not(:disabled) {
|
||||
background: var(--color-success-light);
|
||||
}
|
||||
|
||||
.btn.success {
|
||||
background: var(--color-success) !important;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.card-header-with-actions {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: var(--spacing-md);
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
}
|
||||
|
||||
.card-header-with-actions h3 {
|
||||
color: var(--text-primary);
|
||||
font-size: var(--font-size-lg);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.code-block {
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
padding: var(--spacing-md);
|
||||
margin: var(--spacing-md);
|
||||
}
|
||||
|
||||
.code-block code {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-primary);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.breakdown {
|
||||
padding: var(--spacing-md);
|
||||
}
|
||||
|
||||
.breakdown h4 {
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--font-size-sm);
|
||||
margin: 0 0 var(--spacing-sm) 0;
|
||||
}
|
||||
|
||||
.breakdown-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.breakdown-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.breakdown-item {
|
||||
padding: var(--spacing-xs) var(--spacing-sm);
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.breakdown-item strong {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.status-center {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-bottom: var(--spacing-md);
|
||||
}
|
||||
|
||||
.status-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-sm);
|
||||
padding: var(--spacing-sm);
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.status-item span:first-child {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.status {
|
||||
font-weight: 600;
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.status.valid {
|
||||
color: var(--color-success);
|
||||
}
|
||||
|
||||
.status.invalid {
|
||||
color: var(--color-error);
|
||||
}
|
||||
|
||||
.message {
|
||||
display: flex;
|
||||
gap: var(--spacing-xs);
|
||||
padding: var(--spacing-sm);
|
||||
border-radius: var(--radius-md);
|
||||
margin-bottom: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.message:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.message.success {
|
||||
background: color-mix(in srgb, var(--color-success) 10%, transparent);
|
||||
border: 1px solid color-mix(in srgb, var(--color-success) 30%, transparent);
|
||||
color: var(--color-success);
|
||||
}
|
||||
|
||||
.message.warning {
|
||||
background: color-mix(in srgb, var(--color-warning) 10%, transparent);
|
||||
border: 1px solid color-mix(in srgb, var(--color-warning) 30%, transparent);
|
||||
color: var(--color-warning);
|
||||
}
|
||||
|
||||
.message.error {
|
||||
background: color-mix(in srgb, var(--color-error) 10%, transparent);
|
||||
border: 1px solid color-mix(in srgb, var(--color-error) 30%, transparent);
|
||||
color: var(--color-error);
|
||||
}
|
||||
|
||||
.message div {
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.tips-list {
|
||||
margin: 0;
|
||||
padding-left: var(--spacing-md);
|
||||
color: var(--text-secondary);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
.tips-list li {
|
||||
margin-bottom: var(--spacing-sm);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.tips-list li:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.examples-card {
|
||||
margin-top: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.examples-summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
cursor: pointer;
|
||||
color: var(--text-primary);
|
||||
font-weight: 600;
|
||||
padding: var(--spacing-md);
|
||||
}
|
||||
|
||||
.examples-summary:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.chevron {
|
||||
margin-left: auto;
|
||||
transform: rotate(0deg);
|
||||
transition: transform var(--transition-normal);
|
||||
}
|
||||
|
||||
details[open] .chevron {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.examples-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: var(--spacing-md);
|
||||
padding: 0 var(--spacing-md) var(--spacing-md);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.examples-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.example-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-sm);
|
||||
padding: var(--spacing-md);
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
cursor: pointer;
|
||||
transition: all var(--transition-normal);
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.example-card:hover {
|
||||
border-color: var(--color-primary);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: var(--shadow-md);
|
||||
}
|
||||
|
||||
.example-card.selected {
|
||||
border-color: var(--color-primary);
|
||||
background: color-mix(in srgb, var(--color-primary) 5%, transparent);
|
||||
}
|
||||
|
||||
.example-name {
|
||||
color: var(--color-primary);
|
||||
font-size: var(--font-size-sm);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.example-description {
|
||||
margin: 0;
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.example-config {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xs);
|
||||
font-size: var(--font-size-xs);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.example-config code {
|
||||
font-family: var(--font-mono);
|
||||
background: var(--bg-primary);
|
||||
padding: 2px var(--spacing-xs);
|
||||
border-radius: var(--radius-xs);
|
||||
color: var(--color-primary);
|
||||
}
|
||||
</style>
|
||||
@@ -371,25 +371,74 @@ export const SUB_NAV: Record<string, (NavItem | NavGroup)[]> = {
|
||||
keywords: ['dns', 'spf', 'policy', 'sender', 'framework', 'mechanisms', 'qualifiers', 'validation']
|
||||
},
|
||||
{
|
||||
href: '/dns/dkim-keygen',
|
||||
href: '/dns/generators/dkim-keygen',
|
||||
label: 'DKIM Key Generator',
|
||||
description: 'Generate DKIM RSA keypairs (1024/2048-bit) with selectors and DNS TXT records',
|
||||
icon: 'dns-dkim',
|
||||
keywords: ['dns', 'dkim', 'keys', 'rsa', 'domainkeys', 'selector', 'txt', 'records', 'generator']
|
||||
},
|
||||
{
|
||||
href: '/dns/dmarc-builder',
|
||||
href: '/dns/generators/dmarc-builder',
|
||||
label: 'DMARC Policy Builder',
|
||||
description: 'Create DMARC policies with alignment options, reporting addresses, and failure handling',
|
||||
icon: 'dns-dmarc',
|
||||
keywords: ['dns', 'dmarc', 'policy', 'alignment', 'reporting', 'quarantine', 'reject', 'builder']
|
||||
},
|
||||
{
|
||||
href: '/dns/caa-builder',
|
||||
href: '/dns/generators/caa-builder',
|
||||
label: 'CAA Record Builder',
|
||||
description: 'Build CAA records for certificate authority authorization with misconfiguration warnings',
|
||||
icon: 'dns-caa',
|
||||
keywords: ['dns', 'caa', 'certificate', 'authority', 'authorization', 'ssl', 'tls', 'builder']
|
||||
},
|
||||
{
|
||||
href: '/dns/generators/tlsa-generator',
|
||||
label: 'TLSA Generator',
|
||||
description: 'Create TLSA (DANE) records from certificates or hashes with usage, selector, and matching type options',
|
||||
icon: 'dns-tlsa',
|
||||
keywords: ['dns', 'tlsa', 'dane', 'certificate', 'hash', 'usage', 'selector', 'matching', 'tls', 'ssl']
|
||||
},
|
||||
{
|
||||
href: '/dns/generators/sshfp-generator',
|
||||
label: 'SSHFP Generator',
|
||||
description: 'Generate SSHFP records from SSH public keys or fingerprints with algorithm and fingerprint type selection',
|
||||
icon: 'dns-sshfp',
|
||||
keywords: ['dns', 'sshfp', 'ssh', 'public', 'key', 'fingerprint', 'algorithm', 'security']
|
||||
},
|
||||
{
|
||||
href: '/dns/generators/svcb-https-builder',
|
||||
label: 'SVCB/HTTPS Builder',
|
||||
description: 'Build SVCB and HTTPS resource records with service parameters like ALPN, port, and ECH configuration',
|
||||
icon: 'dns-svcb',
|
||||
keywords: ['dns', 'svcb', 'https', 'service', 'binding', 'alpn', 'port', 'ech', 'parameters']
|
||||
},
|
||||
{
|
||||
href: '/dns/generators/naptr-builder',
|
||||
label: 'NAPTR Builder',
|
||||
description: 'Construct NAPTR records for service discovery with order, preference, flags, service, regexp, and replacement fields',
|
||||
icon: 'dns-naptr',
|
||||
keywords: ['dns', 'naptr', 'service', 'discovery', 'order', 'preference', 'flags', 'regexp', 'replacement']
|
||||
},
|
||||
{
|
||||
href: '/dns/generators/loc-builder',
|
||||
label: 'LOC Builder',
|
||||
description: 'Create LOC records from coordinates and convert between latitude/longitude and DNS LOC format',
|
||||
icon: 'dns-loc',
|
||||
keywords: ['dns', 'loc', 'location', 'coordinates', 'latitude', 'longitude', 'altitude', 'precision']
|
||||
},
|
||||
{
|
||||
href: '/dns/generators/rp-builder',
|
||||
label: 'RP Builder',
|
||||
description: 'Generate RP (Responsible Person) records with mailbox and TXT domain name references',
|
||||
icon: 'dns-rp',
|
||||
keywords: ['dns', 'rp', 'responsible', 'person', 'mailbox', 'contact', 'txt', 'domain']
|
||||
},
|
||||
{
|
||||
href: '/dns/generators/idn-punycode',
|
||||
label: 'IDN Punycode Converter',
|
||||
description: 'Convert Unicode domain names to Punycode and back with IDNA2008 normalization support',
|
||||
icon: 'dns-idn',
|
||||
keywords: ['dns', 'idn', 'punycode', 'unicode', 'domain', 'international', 'idna2008', 'normalization']
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,5 @@
|
||||
<script>
|
||||
import IDNPunycodeConverter from '$lib/components/tools/IDNPunycodeConverter.svelte';
|
||||
</script>
|
||||
|
||||
<IDNPunycodeConverter />
|
||||
@@ -0,0 +1,5 @@
|
||||
<script>
|
||||
import LOCBuilder from '$lib/components/tools/LOCBuilder.svelte';
|
||||
</script>
|
||||
|
||||
<LOCBuilder />
|
||||
@@ -0,0 +1,5 @@
|
||||
<script>
|
||||
import NAPTRBuilder from '$lib/components/tools/NAPTRBuilder.svelte';
|
||||
</script>
|
||||
|
||||
<NAPTRBuilder />
|
||||
File renamed without changes.
@@ -0,0 +1,5 @@
|
||||
<script>
|
||||
import RPBuilder from '$lib/components/tools/RPBuilder.svelte';
|
||||
</script>
|
||||
|
||||
<RPBuilder />
|
||||
@@ -0,0 +1,5 @@
|
||||
<script>
|
||||
import SSHFPGenerator from '$lib/components/tools/SSHFPGenerator.svelte';
|
||||
</script>
|
||||
|
||||
<SSHFPGenerator />
|
||||
@@ -0,0 +1,5 @@
|
||||
<script>
|
||||
import SVCBHTTPSBuilder from '$lib/components/tools/SVCBHTTPSBuilder.svelte';
|
||||
</script>
|
||||
|
||||
<SVCBHTTPSBuilder />
|
||||
@@ -0,0 +1,5 @@
|
||||
<script>
|
||||
import TLSAGenerator from '$lib/components/tools/TLSAGenerator.svelte';
|
||||
</script>
|
||||
|
||||
<TLSAGenerator />
|
||||
@@ -142,18 +142,18 @@
|
||||
}
|
||||
|
||||
// Shared component cards
|
||||
.reference-card, .explainer-card {
|
||||
.reference-card, .explainer-card, .info-card {
|
||||
background-color: var(--bg-secondary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
padding: var(--spacing-md);
|
||||
transition: all var(--transition-fast);
|
||||
|
||||
&:not(.no-hover) {
|
||||
&:not(.no-hover):not(.info-card) {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
&:not(.no-hover):hover {
|
||||
&:not(.no-hover):not(.info-card):hover {
|
||||
box-shadow: var(--shadow-md);
|
||||
border-color: color-mix(in srgb, var(--color-primary) 33%, transparent);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user