androiddns

package
v0.1.5739 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package androiddns makes Go's own resolver work on Android, which has no /etc/resolv.conf (#2872).

A build without cgo, as every magpie terminal build is, resolves names with Go's own resolver. It reads /etc/resolv.conf and, finding none, asks 127.0.0.1:53 and [::1]:53, where nothing listens on Android: every lookup failed with "connection refused", in Termux and in any other Android process, so magpie reached no vendor.

Android's own lookups go to netd, through its dnsproxyd socket, which follows the network the device is on: its DNS servers, a VPN's, Private DNS. Install sends a query Go aimed at those two made-up addresses to netd first, and to the servers Termux's resolv.conf names after it, so a network that drops plain DNS to a public server still resolves as every app on the phone does. A query for any other address is dialled as Go asked it, so a machine with a resolv.conf of its own resolves as before.

Index

Constants

View Source
const NetdSocket = "/dev/socket/dnsproxyd"

NetdSocket is where Android's netd takes lookups: bionic's getaddrinfo writes every app's there (android_getaddrinfo_proxy).

Variables

This section is empty.

Functions

func Dial

func Dial(netd string, servers []string) func(ctx context.Context, network, address string) (net.Conn, error)

Dial is a net.Resolver.Dial that answers a query Go aimed at one of its fallbacks from what Android resolves with: netd's socket at netd ("" when there is none), then servers, the name servers of a resolv.conf. Go tries its two fallbacks in turn, so the first goes to netd and the second to the first server; with only one of them, both go to it. netd answers a failure it can't explain with SERVFAIL, which sends Go on to the next. A query for any other address is dialled as Go asked it.

func Install

func Install()

Install points net's resolver at what Android resolves with, when Go's resolver would otherwise ask the addresses it made up. The CLI calls it before anything looks a name up. GOOS=linux is here too: the Linux arm64 build runs on Android as well (#2872), and Android's GOOS includes linux. Anywhere /etc/resolv.conf names a server, or that isn't Android, nothing changes.

func Servers

func Servers(paths ...string) []string

Servers is the name servers of the first of paths that names one, in the form Go's resolver asks them (host:port), or none when no file there names one.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL