server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package server implements the Penne server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Context context.Context `yaml:"-" toml:"-" json:"-"`
	Logger  slog.Logger     `yaml:"-" toml:"-" json:"-"`

	Name    string `default:"localhost"`
	Version string `default:"unspecified"`
	Authors string `default:"JPI Technologies <oss@jpi.io>"`

	// DisableCHAOS makes the DNS server respond with an empty success instead of giving
	// away software information.
	DisableCHAOS bool `yaml:"disable_chaos,omitempty" toml:",omitempty" json:",omitempty"`

	// ExchangeTimeout indicates the deadline to be used on DNS requests
	ExchangeTimeout time.Duration `yaml:"exchange_timeout" default:"5s"`

	// Supervision provides details for graceful upgrades and restarts
	Supervision sidecar.SupervisionConfig `yaml:"supervision,omitempty" toml:",omitempty" json:",omitempty"`

	// Listen provides details on the addresses and ports to handle
	Listen ListenConfig `yaml:",omitempty" toml:",omitempty" json:",omitempty"`

	// TLS contains instructions to assemble the TLS store.
	// TODO: allow ACME
	TLS store.Config `yaml:",omitempty" toml:",omitempty" json:",omitempty"`

	Horizons  []horizon.Config  `yaml:",omitempty" toml:",omitempty" json:",omitempty"`
	Resolvers []resolver.Config `yaml:",omitempty" toml:",omitempty" json:",omitempty"`
}

Config describes how the Application will be assembled

func (*Config) SetDefaults

func (cfg *Config) SetDefaults() error

SetDefaults fills gaps in the Config

type ListenConfig added in v0.0.3

type ListenConfig struct {
	Interfaces []string     `yaml:",omitempty" toml:",omitempty" json:",omitempty"`
	Addresses  []netip.Addr `yaml:",omitempty"  toml:",omitempty" json:",omitempty"`

	DNS   uint16 `yaml:"dns_port"   default:"53"`
	DoT   uint16 `yaml:"dot_port"   default:"853"`
	HTTP  uint16 `yaml:"http_port"  default:"80"`
	HTTPS uint16 `yaml:"https_port" default:"443"`

	// DisableHTTP disables support for plain/unencrypted HTTP of the monitoring interface
	DisableHTTP bool `yaml:"disable_http,omitempty" toml:",omitempty" json:",omitempty"`
}

ListenConfig describes the addresses and ports this Server will listen

type Server

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

Server is a Penne server

func New

func New(cfg *Config) (*Server, error)

New creates a new Server based on the given Config

func (*Server) ExchangeCHAOS

func (srv *Server) ExchangeCHAOS(_ context.Context, req *dns.Msg) (*dns.Msg, error)

ExchangeCHAOS handles only CHAOS requests

func (*Server) Listen

func (srv *Server) Listen() error

Listen listens all ports.

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe() error

ListenAndServe listens all ports and runs the service.

func (*Server) Serve

func (srv *Server) Serve() error

Serve runs the service

func (*Server) ServeDNS

func (srv *Server) ServeDNS(rw dns.ResponseWriter, req *dns.Msg)

ServeDNS handles dns requests based on the IP address of the client

func (*Server) ServeHTTP

func (srv *Server) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP handles HTTP requests based on the IP address of the client

Jump to

Keyboard shortcuts

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