diff --git a/app/routes/_data.dns._index/rename.tsx b/app/routes/_data.dns._index/rename.tsx index b3be339..0367b12 100644 --- a/app/routes/_data.dns._index/rename.tsx +++ b/app/routes/_data.dns._index/rename.tsx @@ -28,7 +28,7 @@ export default function Modal({ name, disabled }: Properties) { Devices are accessible at {' '} - [device].[user].{name} + [device].{name} {' '} when Magic DNS is enabled. diff --git a/app/routes/_data.dns._index/route.tsx b/app/routes/_data.dns._index/route.tsx index c09be2b..8c7a92a 100644 --- a/app/routes/_data.dns._index/route.tsx +++ b/app/routes/_data.dns._index/route.tsx @@ -25,7 +25,9 @@ export async function loader() { const dns = { prefixes: config.prefixes, magicDns: config.dns.magic_dns, - baseDomain: config.dns.base_domain, + baseDomain: config.dns.use_username_in_magic_dns + ? `[user].${config.dns.base_domain}` + : config.dns.base_domain, nameservers: config.dns.nameservers.global, splitDns: config.dns.nameservers.split, searchDomains: config.dns.search_domains, @@ -107,7 +109,7 @@ export default function Page() { on the tailnet. Devices will be accessible at {' '} - [device].[user]. + [device]. {data.baseDomain} {' '} diff --git a/app/routes/_data.machines._index/machine.tsx b/app/routes/_data.machines._index/machine.tsx index d8ffdd2..7be5a02 100644 --- a/app/routes/_data.machines._index/machine.tsx +++ b/app/routes/_data.machines._index/machine.tsx @@ -31,6 +31,10 @@ export default function MachineRow({ machine, routes, magic, users }: Props) { tags.unshift('Expired') } + let prefix = magic?.startsWith('[user]') + ? magic.replace('[user]', machine.user.name) + : magic + return ( { - const ip = `${machine.givenName}.${machine.user.name}.${magic}` + const ip = `${machine.givenName}.${prefix}` await navigator.clipboard.writeText(ip) toast('Copied hostname to clipboard') }} > {machine.givenName} . - {machine.user.name} - . - {magic} + {prefix} ) diff --git a/app/routes/_data.machines._index/route.tsx b/app/routes/_data.machines._index/route.tsx index 4eb3aad..cd7dbac 100644 --- a/app/routes/_data.machines._index/route.tsx +++ b/app/routes/_data.machines._index/route.tsx @@ -32,6 +32,10 @@ export async function loader({ request }: LoaderFunctionArgs) { if (config.dns.magic_dns) { magic = config.dns.base_domain } + + if (config.dns.use_username_in_magic_dns) { + magic = `[user].${magic}` + } } return { @@ -76,7 +80,7 @@ export default function Page() { based on their name and also at {' '} - [name].[user]. + [name]. {data.magic} diff --git a/app/routes/_data.users._index/add.tsx b/app/routes/_data.users._index/add.tsx index 05b9781..d693e3d 100644 --- a/app/routes/_data.users._index/add.tsx +++ b/app/routes/_data.users._index/add.tsx @@ -36,7 +36,6 @@ export default function Add({ magic }: Props) { {' '} [machine]. - {username.length > 0 ? username : '[username]'} . {magic} diff --git a/app/routes/_data.users._index/rename.tsx b/app/routes/_data.users._index/rename.tsx index 286d5b7..8191c03 100644 --- a/app/routes/_data.users._index/rename.tsx +++ b/app/routes/_data.users._index/rename.tsx @@ -59,7 +59,6 @@ export default function Rename({ username, magic }: Props) { {' '} [machine]. - {newName.length > 0 ? newName : '[new-username]'} . {magic}