avvy

package module
v0.0.0-...-9664cbe Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Unlicense Imports: 17 Imported by: 0

README

coredns-avvy

CoreDNS-Avvy is a CoreDNS plugin that resolves DNS information over Avalanche Name Server. It has two primary purposes:

  1. A general-purpose DNS resolver for DNS records stored on the Avalanche blockchain
  2. A specialised resolver for IPFS content hashes and gateways

The second feature provides a mechanism to map DNS domains to ENS domains by removing the relevant suffix, for example the DNS domain tristanh00.eth.link maps to the ENS domain tristanh00.eth, and returning information for IPFS gateways (if an A or AAAA record is requested) as well as IPFS and content hashes (if a TXT record is requested). The result of this is that IPFS content can be obtained from any web browser by simply

Building

The latest build is always available as a docker repository at tristanh00/coredns-avvy. If you want to build a standalone copy of CoreDNS with this plugin enabled run the build-standalone.sh script, which should work on most unix-like systems.

Corefile

The plugin has a number of configuration options. An example annotated Corefile is shown below:

# This section enables DNS lookups for all domains on Avvy
. {
  rewrite stop {
    # This rewrites any requests for *.eth.link domains to *.eth internally
    # prior to being processed by the main ENS resolver.
    name regex (.*)\.eth\.link {1}.eth
    answer name (.*)\.eth {1}.eth.link
  }
  avvy {
    # connection is the connection to an Ethereum node.  It is *highly*
    # recommended that a local node is used, as remote connections can
    # cause DNS requests to time out.
    # This can be either a path to an IPC socket or a URL to a JSON-RPC
    # endpoint.
    connection /home/ethereum/.ethereum/geth.ipc

    # ipfsgatewaya is the address of an ENS-enabled IPFS gateway.
    # This value is returned when a request for an A record of an Ethlink
    # domain is received and the domain has a contenthash record in ENS but
    # no A record.  Multiple values can be supplied, separated by a space,
    # in which case all records will be returned.
    ipfsgatewaya 176.9.154.81

    # ipfsgatewayaaaa is the address of an ENS-enabled IPFS gateway.
    # This value is returned when a request for an AAAA record of an Ethlink
    # domain is received and the domain has a contenthash record in ENS but
    # no A record.  Multiple values can be supplied, separated by a space,
    # in which case all records will be returned.
    ipfsgatewayaaaa 2a01:4f8:160:4069::2
  }

  # This enables DNS forwarding.  It should only be enabled if this DNS server
  # is not exposed to the internet, otherwise it becomes an open DNS server and
  # will be flooded with attack packets.
  forward . 8.8.8.8

  errors
}

It is also possible to run the DNS server over TLS or over HTTPS; details on how to set up certificates the can be found in the CoreDNS documentation.

Running standalone

Running CoreDNS standalone is simply a case of starting the binary. See the CoreDNS documentation for further information.

Running with Docker

Running CoreDNS with Docker requires running the image created in the Building section. A sample command-line might be:

docker run -p 53:53/udp --volume=/home/coredns:/etc/coredns tristanh00/coredns-avvy:latest

where /home/coredns is the directory on the server that contains the Corefile and certificates.

Documentation

Overview

Package ens implements a plugin that returns information held in the Ethereum Name Service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Avvy

type Avvy struct {
	Next             plugin.Handler
	Client           *ethclient.Client
	Registry         *avvy.Registry
	IPFSGatewayAs    []string
	IPFSGatewayAAAAs []string
}

Avvy is a plugin that returns information held in the Avalanche Name Service.

func (Avvy) HasRecords

func (a Avvy) HasRecords(domain string, name string) (bool, error)

HasRecords checks if there are any records for a specific domain and name. This is used for wildcard eligibility

func (Avvy) IsAuthoritative

func (a Avvy) IsAuthoritative(domain string) bool

IsAuthoritative checks if the Avvy plugin is authoritative for a given domain

func (Avvy) Name

func (a Avvy) Name() string

Name implements the Handler interface.

func (Avvy) Query

func (a Avvy) Query(domain string, name string, qtype uint16, do bool) ([]dns.RR, error)

Query queries a given domain/name/resource combination

func (Avvy) Ready

func (a Avvy) Ready() bool

Ready returns true if we're ready to serve DNS records i.e. our chain is synced

func (Avvy) ServeDNS

func (ad Avvy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the plugin.Handler interface.

type Result

type Result int

Result of a lookup

const (
	// Success is a successful lookup.
	Success Result = iota
	// NameError indicates a nameerror
	NameError
	// Delegation indicates the lookup resulted in a delegation.
	Delegation
	// NoData indicates the lookup resulted in a NODATA.
	NoData
	// ServerFailure indicates a server failure during the lookup.
	ServerFailure
)

func Lookup

func Lookup(server Server, state request.Request) ([]dns.RR, []dns.RR, []dns.RR, Result)

Lookup contains the logic required to move through A DNS hierarchy and gather the appropriate records

type Server

type Server interface {
	// Query returns records for a specific domain, name, and resource type
	Query(domain string, qname string, qtype uint16, do bool) ([]dns.RR, error)

	// HasRecords checks if there are any records for a specific domain and name
	// This is used to check for wildcard eligibility
	HasRecords(domain string, qname string) (bool, error)

	// IsAuthoritative returns true if this server is authoritative for the
	// supplied domain
	IsAuthoritative(qdomain string) bool
}

Server is an interface defined by any plugin that wishes to serve authoritative records

Jump to

Keyboard shortcuts

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