rind

package module
v0.0.0-...-89b17e0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2019 License: BSD-3-Clause Imports: 15 Imported by: 5

README

UNMAINTAINED, PLEASE SEE OTHER ALTERNATIVES BELOW

Rind

GoDoc Build Status

Rind is a DNS server with REST interface for records management, best use is for your local service discovery, DNS forwarding and caching.

Examples

See complete example here

Start DNS server:

import github.com/owlwalks/rind

rind.Start("rw-dirpath", []net.UDPAddr{{IP: net.IP{1, 1, 1, 1}, Port: 53}})

Manage records

// Add a SRV record
curl -X POST \
  http://localhost/dns \
  -H 'Content-Type: application/json' \
  -d '{
	"Host": "_sip._tcp.example.com.",
	"TTL": 300,
	"Type": "SRV",
	"SRV": {
		"Priority": 0,
		"Weight": 5,
		"Port": 5060,
		"Target": "sipserver.example.com."
	}
}'

// Update an A record from 124.108.115.87 to 127.0.0.1
curl -X PUT \
  http://localhost/dns \
  -H 'Content-Type: application/json' \
  -d '{
	"Host": "example.com.",
	"TTL": 600,
	"Type": "A",
	"OldData": "124.108.115.87",
	"Data": "127.0.0.1"
}'

// Delete a record
curl -X DELETE \
  http://localhost/dns \
  -H 'Content-Type: application/json' \
  -d '{
	"Host": "example.com.",
	"Type": "A"
}'

Features:

  • DNS server
    • DNS forwarding
    • DNS caching
    • A record
    • NS record
    • CNAME record
    • SOA record
    • PTR record
    • MX record
    • AAAA record
    • SRV record
  • REST server
    • Create records
    • Read records
    • Update records
    • Delete records

Todo:

  • Primary, secondary model

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DNSServer

type DNSServer interface {
	Listen()
	Query(Packet)
}

DNSServer will do Listen, Query and Send.

type DNSService

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

DNSService is an implementation of DNSServer interface.

func New

func New(rwDirPath string, forwarders []net.UDPAddr) DNSService

New setups a DNSService, rwDirPath is read-writable directory path for storing dns records.

func Start

func Start(rwDirPath string, forwarders []net.UDPAddr) *DNSService

Start conveniently init every parts of DNS service.

func (*DNSService) Listen

func (s *DNSService) Listen()

Listen starts a DNS server on port 53

func (*DNSService) Query

func (s *DNSService) Query(p Packet)

Query lookup answers for DNS message.

type Packet

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

Packet carries DNS packet payload and sender address.

type RestServer

type RestServer interface {
	Create() http.HandlerFunc
	Read() http.HandlerFunc
	Update() http.HandlerFunc
	Delete() http.HandlerFunc
}

RestServer will do CRUD on DNS records

type RestService

type RestService struct {
	Dn *DNSService
}

RestService is an implementation of RestServer interface.

func (*RestService) Create

func (s *RestService) Create(w http.ResponseWriter, r *http.Request)

Create is HTTP handler of POST request. Use for adding new record to DNS server.

func (*RestService) Delete

func (s *RestService) Delete(w http.ResponseWriter, r *http.Request)

Delete is HTTP handler of DELETE request. Use for removing records on DNS server.

func (*RestService) Read

func (s *RestService) Read(w http.ResponseWriter, r *http.Request)

Read is HTTP handler of GET request. Use for reading existed records on DNS server.

func (*RestService) Update

func (s *RestService) Update(w http.ResponseWriter, r *http.Request)

Update is HTTP handler of PUT request. Use for updating existed records on DNS server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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