checker

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2019 License: MIT Imports: 2 Imported by: 0

README

Build Status Go Report Card License MIT GoDoc Domain Checker

Domain Checker

The purpose of this repository is to setup a list of domains you would like to own. The program will check the domain with the providers available and to which you have an account to register it on availability and will register it when it becomes available.

Howto

How to use the server

Use the .env.dist and the docker-compose.yml.example.dist to set up a running server. You can add, remove and list domains that are being checked with the internal CLI command, the server container gets packed with the CLI program as well. You can use them by calling the program from inside the container with $ docker-compose exec checker cli list. You should also set the AUTH_TOKEN environment variable. New client connections need to authenticate with this token before any actions can be performed.

TLS

When you provide the server with a TLS cert and key the server will start a TLS server to handle incoming connections. When no TLS vars are set or the vars are invalid the server will try to fallback on a regular TCP server if the environment variable TLS_ALLOW_INSECURE allows it.

Redis

You can add a Redis connection string to the server environment variables, this will make sure the list of domains gets persisted into Redis so it can resume where it was after a restart. If no Redis parameters are provided the server application will just keep the list in memory.

How to use the CLI program

The CLI program is packed with the server program into one Docker container. However it is also possible to use the CLI program standalone on a different computer. You can download this repository and make build all programs inside, the CLI program will be located in ./bin/cli.

Arguments

The client needs multile input arguments to setup a connection with the Checker service, but it is also possible to set these values with the program so they are used automatically at each command. The arguments available are:

Name Workings Required
host The hostname to connect to True
port The port on the host to connect to True
token The token to authenticate to the server with True
allowUnsafe Allow TLS connections with an invalid root certificate (dev mode) False
forceUnsafe Use a regular TCP connection, this should be used internally only and only works if the server isn't using TLS False

All these variables can be persisted to the client app as well, use $ cli set host example.org, or $ cli set forceUnsafe true to set the variable with the client. The next time the client program is called you no longer need to provide the flag to the cli command itself.

Commands

The application accepts 3 commands, add, remove and list. You can use them as follows $ cli [arguments] add host.com. Or $ cli [arguments] list.

Roadmap

  • It would be nice if the server and CLI command do some domain name validation before adding/removing them.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

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

Error defines a structured error this package will use

func NewError

func NewError(client Registrar, err error) Error

NewError returns an structured error

func (Error) Error

func (e Error) Error() string

func (Error) Unwrap added in v0.3.0

func (e Error) Unwrap() error

Unwrap fills the go 1.13 error interface for chaining

type MultipleError added in v0.3.0

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

MultipleError holds a set of errors

func NewMultipleError added in v0.3.0

func NewMultipleError(msg string, cap int) *MultipleError

NewMultipleError returns a new instance of a multiple error object. Any procedures that run in batch should use this error to represent problems somewhere down the chain. The parameter 'cap' lets you set the capacity of the internal slice beforehand to prevent memory allocations during filling.

func (*MultipleError) Add added in v0.3.0

func (me *MultipleError) Add(e Error) int

Add adds an Error instance to the MultipleErrors error set

func (*MultipleError) As added in v0.3.0

func (me *MultipleError) As(target interface{}) (matches bool)

As implements the interface the errors package can use to check for errors.As

func (*MultipleError) Error added in v0.3.0

func (me *MultipleError) Error() string

func (*MultipleError) Errors added in v0.3.0

func (me *MultipleError) Errors() []Error

Errors returns all the internal errors contained by this multiple error bucket

func (*MultipleError) Is added in v0.3.0

func (me *MultipleError) Is(target error) (matches bool)

Is implements the interface the errors package can use to match the MultipleError to an error that should be tested.

func (*MultipleError) Len added in v0.3.0

func (me *MultipleError) Len() int

Len gets the size of the internal error set

type Registrar added in v0.3.0

type Registrar interface {
	// CheckDomain returns a status about the requested domain.
	CheckDomain(string) (Status, error)
	// Register domain will try and register the domain name
	RegisterDomain(string) (Status, error)
}

Registrar interface defines some methods we want external services to present to us such as but not limited to domain availability checks and registration

type RegistrarStatus added in v0.3.0

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

ClientStatus tells the status for a domain for a specific domain

func CheckDomain

func CheckDomain(name string, clients []Registrar) ([]RegistrarStatus, error)

CheckDomain will walk though the provided domainRegistrars and check on all of them if a specific domain is available. The domainClients will be checked in order of appearance. The returning error does not mean domain checking completely failed. It just states somewhere during checking an error occured at some registrar in the chain.

func RegisterDomain

func RegisterDomain(name string, clients []Registrar) (RegistrarStatus, error)

RegisterDomain will try to register a domain at a slice of given domainRegistrars. The first one to return a valid response will own the domain. Please sort the domainClients in order of preference. Please check the RegistarStatus to see if the registration was a success. The error will contain any error that occured with any registrar during registration attempts.

func (*RegistrarStatus) Domain added in v0.3.0

func (cs *RegistrarStatus) Domain() string

Domain reports the domain name requested

func (*RegistrarStatus) Registrar added in v0.3.0

func (cs *RegistrarStatus) Registrar() Registrar

Registrar reports the registrar to which this status applies

func (*RegistrarStatus) Status added in v0.3.0

func (cs *RegistrarStatus) Status() Status

Status reports the actual status for this domain with this client

type Status

type Status uint8

Status wraps statuses this package will act upon

var (
	// Unavailable status notes the domain name is not available to us in any feasible way
	Unavailable Status = 0x00
	// Owned status tells us the domain name is already in out possession
	Owned Status = 0x01
	// Available status is the mark that we can try to claim the domain name
	Available Status = 0x02
	// Processing is a special status that indicates we are already trying to get the domain
	Processing Status = 0x04
)

Directories

Path Synopsis
cmd
checker command
cli command

Jump to

Keyboard shortcuts

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