xip

package
v0.0.0-...-db357c7 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2020 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package xip provides functions to create a DNS server which, when queried with a hostname with an embedded IP address, returns that IP Address. It was inspired by xip.io, which was created by Sam Stephenson

Index

Constants

View Source
const (
	Hostmaster = "yoyo.nono.io."
	MxHost     = "mail.protonmail.ch."
)

Variables

View Source
var (
	ErrNotFound = errors.New("record not found")
	NameServers = []string{
		"ns-azure.nono.io.",
		"ns-aws.nono.io.",
		"ns-gce.nono.io.",
	}
)

Functions

func MXResource

func MXResource() dnsmessage.MXResource

func NSResources

func NSResources() []dnsmessage.NSResource

func NameToA

func NameToA(fqdnString string) (*dnsmessage.AResource, error)

NameToA returns either an AResource that matched the hostname or ErrNotFound

func NameToAAAA

func NameToAAAA(fqdnString string) (*dnsmessage.AAAAResource, error)

NameToAAAA NameToA returns either an AAAAResource that matched the hostname or ErrNotFound

func QueryResponse

func QueryResponse(queryBytes []byte) (responseBytes []byte, logMessage string, err error)

QueryResponse takes in a raw (packed) DNS query and returns a raw (packed) DNS response, a string (for logging) that describes the query and the response, and an error. It takes in the raw data to offload as much as possible from main(). main() is hard to unit test, but functions like QueryResponse are not as hard.

Examples of log strings returned:

78.46.204.247.33654: TypeA 127-0-0-1.sslip.io ? 127.0.0.1
78.46.204.247.33654: TypeA www.sslip.io ? nil, SOA
78.46.204.247.33654: TypeNS www.example.com ? NS
78.46.204.247.33654: TypeSOA www.example.com ? SOA
2600::.33654: TypeAAAA --1.sslip.io ? ::1

func ResponseHeader

func ResponseHeader(query dnsmessage.Header, rcode dnsmessage.RCode) dnsmessage.Header

ResponseHeader returns a pre-fab DNS response header. Note that we're always authoritative and therefore recursion is never available. We're able to "white label" domains by indiscriminately matching every query that comes our way. Not being recursive has the added benefit of not being usable as an amplifier in a DDOS attack. We pass in the RCODE, which is normally RCodeSuccess but can also be a failure (e.g. ANY type we return RCodeNotImplemented)

func SOAResource

func SOAResource(domain string) dnsmessage.SOAResource

SOAResource returns the hard-coded SOA

Types

type DNSError

type DNSError struct {
	RCode dnsmessage.RCode
}

DNSError sets the RCode for failed queries, currently only the ANY query

func (*DNSError) Error

func (e *DNSError) Error() string

Jump to

Keyboard shortcuts

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