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
- Variables
- func MXResource() dnsmessage.MXResource
- func NSResources() []dnsmessage.NSResource
- func NameToA(fqdnString string) (*dnsmessage.AResource, error)
- func NameToAAAA(fqdnString string) (*dnsmessage.AAAAResource, error)
- func QueryResponse(queryBytes []byte) (responseBytes []byte, logMessage string, err error)
- func ResponseHeader(query dnsmessage.Header, rcode dnsmessage.RCode) dnsmessage.Header
- func SOAResource(domain string) dnsmessage.SOAResource
- type DNSError
Constants ¶
const ( Hostmaster = "yoyo.nono.io." MxHost = "mail.protonmail.ch." )
Variables ¶
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 ¶
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