Files
acme-dns/types.go

80 lines
1.8 KiB
Go
Raw Normal View History

2016-11-11 16:48:00 +02:00
package main
import (
2016-11-27 23:21:46 +02:00
"database/sql"
"sync"
"github.com/google/uuid"
2016-11-11 16:48:00 +02:00
)
// Config is global configuration struct
var Config DNSConfig
2016-11-28 13:13:45 +02:00
// DB is used to access the database functions in acme-dns
var DB database
2016-11-23 18:07:38 +02:00
// DNSConfig holds the config structure
2016-11-16 19:15:36 +02:00
type DNSConfig struct {
2016-11-13 14:50:44 +02:00
General general
2016-11-17 17:52:55 +02:00
Database dbsettings
2016-11-16 19:15:36 +02:00
API httpapi
2016-11-13 14:50:44 +02:00
Logconfig logconfig
2016-11-11 16:48:00 +02:00
}
// Config file general section
type general struct {
2016-11-27 21:21:38 +02:00
Listen string
2016-11-28 22:46:24 +02:00
Proto string `toml:"protocol"`
Domain string
Nsname string
Nsadmin string
2016-11-16 14:56:49 +02:00
Debug bool
StaticRecords []string `toml:"records"`
2016-11-13 14:50:44 +02:00
}
2016-11-17 17:52:55 +02:00
type dbsettings struct {
Engine string
Connection string
}
2016-11-13 14:50:44 +02:00
// API config
type httpapi struct {
Domain string `toml:"api_domain"`
IP string
DisableRegistration bool `toml:"disable_registration"`
AutocertPort string `toml:"autocert_port"`
Port string `toml:"port"`
TLS string
TLSCertPrivkey string `toml:"tls_cert_privkey"`
TLSCertFullchain string `toml:"tls_cert_fullchain"`
ACMECacheDir string `toml:"acme_cache_dir"`
NotificationEmail string `toml:"notification_email"`
CorsOrigins []string
UseHeader bool `toml:"use_header"`
HeaderName string `toml:"header_name"`
2016-11-11 16:48:00 +02:00
}
2016-11-13 14:50:44 +02:00
// Logging config
type logconfig struct {
Level string `toml:"loglevel"`
Logtype string `toml:"logtype"`
File string `toml:"logfile"`
Format string `toml:"logformat"`
}
2016-11-27 23:21:46 +02:00
type acmedb struct {
Mutex sync.Mutex
2016-11-27 23:21:46 +02:00
DB *sql.DB
}
type database interface {
Init(string, string) error
2016-12-01 00:03:08 +02:00
Register(cidrslice) (ACMETxt, error)
2016-11-27 23:21:46 +02:00
GetByUsername(uuid.UUID) (ACMETxt, error)
GetTXTForDomain(string) ([]string, error)
Update(ACMETxtPost) error
2016-11-27 23:21:46 +02:00
GetBackend() *sql.DB
SetBackend(*sql.DB)
Close()
}