Documentation ¶
Index ¶
- Constants
- Variables
- func AuthHandler(db CoolDB, res http.ResponseWriter, req *http.Request)
- func ReCaptcha(remoteip, challenge, response, privKey string) (bool, error)
- func Register(db CoolDB, r render.Render, reg Registration, errors binding.Errors)
- func Run(config *Config)
- func RunDns(config *DnsServerConfig, db CoolDB, metric MetricsHandle)
- func SetupWeb(config *WebConfig, db CoolDB, metric MetricsHandle) http.Handler
- func ValidateDomain(subdomain, domain string) (fqdn string, valid bool)
- type Auth
- type Config
- type CoolDB
- type DnsDB
- type DnsServerConfig
- type DummyMHandle
- type Entry
- type InfluxConfig
- type InfluxMHandle
- type MetricsHandle
- type MxEntry
- type Registration
- type SqliteCoolDB
- type Web
- func (w *Web) FormApiDomainNew(db CoolDB, r render.Render, n WebNewDomain, errors binding.Errors, ...)
- func (w *Web) FormApiDomainUpdate(db CoolDB, r render.Render, n WebUpdateDomain, errors binding.Errors, ...)
- func (w *Web) Index(db CoolDB, r render.Render)
- func (w *Web) Update(db CoolDB, r render.Render)
- func (w *Web) UpdateDomain(db CoolDB, r render.Render, n WebUpdateDomain, errors binding.Errors, ...)
- type WebConfig
- type WebErrorHandler
- type WebNewDomain
- type WebSuccessHandler
- type WebUpdateDomain
Constants ¶
const ( ScryptN int = 16384 Scryptr int = 8 Scryptp int = 1 ScryptKeyLen int = 32 )
Variables ¶
var (
AuthConstraintsNotMet error = errors.New("Constraints do not apply")
)
Functions ¶
func AuthHandler ¶
func AuthHandler(db CoolDB, res http.ResponseWriter, req *http.Request)
func Run ¶
func Run(config *Config)
The main Server Runner, specify a listen string in the form <net>:<port>, and a database filename.
func RunDns ¶
func RunDns(config *DnsServerConfig, db CoolDB, metric MetricsHandle)
Run DNS Server with given config.
A configuration is sufficient if it contains a Domain name, a db mustbe supplied but the metricsHandle can be nil
func ValidateDomain ¶
Validates a sub domain, if validation fails we try to make it a valid sub fqdn of the subdomain. The following things are checked and mitigated:
- Sub-domain is actually a sub-domain if not we try to append the domain
- multiple dots are deleted
- if not an fqdn a dot is appended
- Everything is lowercased
If the URL has one of the following features we just return false and do not recover
- URL to short (below 2 characters)
- contains illeageal characters.
Types ¶
type Auth ¶
func NewAuth ¶
New Auth takes a name and secret of type string and generated an Auth out of them. An 8 Byte salt is randomly generated and added to the Auth.
Some standard input constraints are applied:
*No Empty strings *Minimum of 8 unicode Runes for the secret (more is recomended)
We use /dev/urandom as a rand source and if you wish to argue about this, argue with a knife because I am not intersted. Oh, and don't trust this on *BSD because they got it all wrong.
type Config ¶
type Config struct { DbFile string Domain string // fqdn of the full Domain name WebConfig *WebConfig DnsConfig *DnsServerConfig // Server Configuration InfluxConfig *InfluxConfig // Influx DB configuration }
Server Confiuration object holds instance specific variables
If all values for a specific feature are set, the corrensponding feature is activated, These shall not be changed during server Runtime.
func LoadConfig ¶
func LoadConfig() *Config
type CoolDB ¶
type CoolDB interface { GetEntry(string) *Entry SaveEntry(*Entry) error GetAuth(string) *Auth SaveAuth(*Auth) error Close() error }
Specifies the four methods that are needed from a DB All methods shall be callable from sevferal goroutines at a time.
type DnsServerConfig ¶
type DnsServerConfig struct { Domain string // fqdn of the full Domain name Listen string // Dns server listener Interface <interface>:<port>. default is ":8053" // Tsig Key according to the tsig spec (base64 string) // If not set, tsig will not be activated. TsigKey string }
Configuration for the DNS server
type DummyMHandle ¶
type DummyMHandle struct { }
func NewDummyMetrics ¶
func NewDummyMetrics() *DummyMHandle
func (*DummyMHandle) DatabaseEvent ¶
func (m *DummyMHandle) DatabaseEvent()
func (*DummyMHandle) DnsEvent ¶
func (m *DummyMHandle) DnsEvent()
func (*DummyMHandle) HttpEvent ¶
func (m *DummyMHandle) HttpEvent()
func (*DummyMHandle) HttpTime ¶
func (m *DummyMHandle) HttpTime(f func())
type Entry ¶
type InfluxConfig ¶
type InfluxConfig struct { Host string // Hostname:port of the Database Database string // Database name Username string Password string }
Configuration of the InfluxDB host where all metrics are stored in
type InfluxMHandle ¶
type InfluxMHandle struct {
// contains filtered or unexported fields
}
func NewInfluxMetrics ¶
func NewInfluxMetrics(config *InfluxConfig) *InfluxMHandle
func (*InfluxMHandle) DatabaseEvent ¶
func (m *InfluxMHandle) DatabaseEvent()
func (*InfluxMHandle) DnsEvent ¶
func (m *InfluxMHandle) DnsEvent()
func (*InfluxMHandle) HttpEvent ¶
func (m *InfluxMHandle) HttpEvent()
func (*InfluxMHandle) HttpTime ¶
func (m *InfluxMHandle) HttpTime(f func())
type MetricsHandle ¶
type MetricsHandle interface { DnsEvent() DatabaseEvent() HttpEvent() HttpTime(func()) }
type Registration ¶
type SqliteCoolDB ¶
func NewSqliteCoolDB ¶
func NewSqliteCoolDB(filename string) (*SqliteCoolDB, error)
func (*SqliteCoolDB) Close ¶
func (db *SqliteCoolDB) Close() error
func (*SqliteCoolDB) GetAuth ¶
func (db *SqliteCoolDB) GetAuth(name string) *Auth
func (*SqliteCoolDB) GetEntry ¶
func (db *SqliteCoolDB) GetEntry(name string) *Entry
func (*SqliteCoolDB) SaveAuth ¶
func (db *SqliteCoolDB) SaveAuth(auth *Auth) error
func (*SqliteCoolDB) SaveEntry ¶
func (db *SqliteCoolDB) SaveEntry(e *Entry) error
type Web ¶
func (*Web) FormApiDomainNew ¶
func (*Web) FormApiDomainUpdate ¶
func (*Web) UpdateDomain ¶
func (w *Web) UpdateDomain(db CoolDB, r render.Render, n WebUpdateDomain, errors binding.Errors, req *http.Request, errHandler WebErrorHandler, successHandler WebSuccessHandler)
type WebErrorHandler ¶
Web Error Handler function signature. Helps you interface with errors
type WebNewDomain ¶
type WebSuccessHandler ¶
type WebSuccessHandler func([]string, interface{})
Web Success Handler function signature. Helps interface with success messages