Help us shape the future of Go! Take the 2026 Go Developer Survey

skydns

package
v1.3.101 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Package skydns pkg/skydns/skydns.go

SkyDNS lets every app on a phone open .dmsg and .skynet names, whatever its proxy support. It sits on a tunnel's packet path and owns Range: apps ask ResolverAddr for names, mesh names get a synthetic IP from the mesh gateway's pool, and every other name goes to an Exchanger. TCP to a synthetic IP is carried over the mesh by the gateway (pkg/vpnrouter/meshgw).

Package skydns pkg/skydns/upstream.go

Index

Constants

View Source
const (
	// Range is RFC 2544 benchmark space, so no real network uses it. Unlike
	// 100.64.0.0/10 it never holds a carrier's CGNAT address for the phone.
	Range = "198.18.0.0/15"
	// PoolCIDR is where mesh names get their synthetic IPs.
	PoolCIDR = "198.18.0.0/16"
	// ResolverAddr is the DNS server apps are pointed at.
	ResolverAddr = "198.19.0.53"
	// LocalAddr is the standalone tunnel's own address.
	LocalAddr = "198.19.0.1"
)

Variables

This section is empty.

Functions

func HasTLS

func HasTLS(server string) bool

HasTLS reports whether server is a public resolver known to answer DNS-over-TLS, where falling back to plain DNS would only help an attacker.

func Owns

func Owns(p []byte) bool

Owns reports whether p is an IPv4 packet for SkyDNS, one addressed to Range.

Types

type Config

type Config struct {
	// Dial carries a connection to a synthetic IP over the mesh.
	Dial meshgw.MeshDial
	// Upstream answers every name that is not a mesh name.
	Upstream Exchanger
	// Aliases maps friendly names to PKs. Optional.
	Aliases map[string]cipher.PubKey
	// Minter, when set, terminates HTTPS to mesh names. Optional.
	Minter skynetca.LeafMinter
	// MTU of the tunnel. Zero means 1500.
	MTU int
	Log logrus.FieldLogger
}

Config is what an Engine needs from its host.

type DialFunc

type DialFunc func(ctx context.Context, network, address string) (net.Conn, error)

DialFunc opens a connection, inside a tunnel or past it.

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is SkyDNS on one tunnel. Write hands it the packets Owns picks out, and Read returns the packets it sends back. Safe for concurrent use.

func New

func New(cfg Config) (*Engine, error)

New starts an engine. Close it to stop.

func (*Engine) Close

func (e *Engine) Close() error

Close stops the resolver and drops every connection the engine carries.

func (*Engine) Read

func (e *Engine) Read(p []byte) (int, error)

Read blocks for one packet the engine sends back into the tunnel. It returns io.EOF once the engine is closed.

func (*Engine) Write

func (e *Engine) Write(p []byte) (int, error)

Write hands the engine one packet from the tunnel.

type Exchanger

type Exchanger interface {
	Exchange(ctx context.Context, m *dns.Msg) (*dns.Msg, error)
}

Exchanger answers a DNS query, as an Upstream does.

type Upstream

type Upstream struct {
	// contains filtered or unexported fields
}

Upstream asks one resolver over DNS-over-TLS (RFC 7858). Unless strict, a resolver with no TLS on 853 is asked in plain DNS, as Android's automatic Private DNS does.

func NewUpstream

func NewUpstream(server string, dial DialFunc, strict bool) *Upstream

NewUpstream returns an Upstream for the resolver at server, an IP address.

func (*Upstream) Exchange

func (u *Upstream) Exchange(ctx context.Context, m *dns.Msg) (*dns.Msg, error)

Exchange implements Exchanger.

func (*Upstream) Server

func (u *Upstream) Server() string

Server is the resolver u asks now.

func (*Upstream) SetServer

func (u *Upstream) SetServer(server string)

SetServer moves u to another resolver, an IP. Pooled connections to the old one are closed, and TLS is tried again from the start.

Jump to

Keyboard shortcuts

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