import { RepoForkedIcon } from '@primer/octicons-react'; import { useState } from 'react'; import { useSubmit } from 'react-router'; import Dialog from '~/components/Dialog'; import Input from '~/components/Input'; import Switch from '~/components/Switch'; import Tooltip from '~/components/Tooltip'; import { cn } from '~/utils/cn'; interface Props { nameservers: Record; } export default function AddNameserver({ nameservers }: Props) { const submit = useSubmit(); const [split, setSplit] = useState(false); const [ns, setNs] = useState(''); const [domain, setDomain] = useState(''); return ( Add nameserver { event.preventDefault(); if (!ns) return; if (split) { const splitNs: Record = {}; for (const [key, value] of Object.entries(nameservers)) { if (key === 'global') continue; splitNs[key] = value; } if (Object.keys(splitNs).includes(domain)) { splitNs[domain].push(ns); } else { splitNs[domain] = [ns]; } submit( { 'dns.nameservers.split': splitNs, }, { method: 'PATCH', encType: 'application/json', }, ); } else { const globalNs = nameservers.global; globalNs.push(ns); submit( { 'dns.nameservers.global': globalNs, }, { method: 'PATCH', encType: 'application/json', }, ); } setNs(''); setDomain(''); setSplit(false); }} > Add nameserver
Restrict to domain Split DNS Only clients that support split DNS (Tailscale v1.8 or later for most platforms) will use this nameserver. Older clients will ignore it.
This nameserver will only be used for some domains.
{ setSplit(!split); }} />
{split ? ( <> Domain Only single-label or fully-qualified queries matching this suffix should use the nameserver. ) : undefined}
); }