Native DNS TXT resolver module for React Native (iOS + Android).
This package is used by the DNSChat app to perform direct DNS TXT lookups from native code and return raw TXT records to the TypeScript layer for parsing.
Status:
- This module currently ships as part of this repo (under
modules/dns-native/). - It is not published to npm in the default workflow; the app imports it via a repo-local path.
- iOS: uses Apple's Network framework (
NWConnection) for DNS resolution. - Android: attempts a raw UDP TXT query first; if that fails, it falls back to
DNS-over-HTTPS only when the selected resolver is Cloudflare (
1.1.1.1), then to a legacy resolver (dnsjava).
Note: In the DNSChat app, the TypeScript layer controls the overall transport order (native -> UDP -> TCP -> mock). The Android native module also has its own internal fallback chain inside the native "native" step.
Native UDP responses are validated before TXT parsing (transaction ID, header flags, QDCOUNT, and question name/type/class matching) to reduce spoofing risk.
import { nativeDNS } from "../../modules/dns-native";
const capabilities = await nativeDNS.isAvailable();
if (!capabilities.available) {
throw new Error("Native DNS not available on this platform");
}
// queryName must be the fully-qualified name you want to look up (already
// sanitized/validated by the caller).
const queryName = "hello-world.llm.pieter.com";
const txtRecords = await nativeDNS.queryTXT("llm.pieter.com", queryName, 53);
const response = nativeDNS.parseMultiPartResponse(txtRecords);nativeDNS.isAvailable(): Promise<DNSCapabilities>nativeDNS.queryTXT(dnsServer: string, queryName: string, port?: number): Promise<string[]>nativeDNS.parseMultiPartResponse(records: string[]): string
cd modules/dns-native
npm ci
npm test