acme-dns/types.go

80 lines
1.8 KiB
Go
Raw Permalink Normal View History

2016-11-11 21:48:00 +07:00
package main
import (
2016-11-28 04:21:46 +07:00
"database/sql"
"sync"
"github.com/google/uuid"
2016-11-11 21:48:00 +07:00
)
// Config is global configuration struct
var Config DNSConfig
2016-11-28 18:13:45 +07:00
// DB is used to access the database functions in acme-dns
var DB database
2016-11-23 23:07:38 +07:00
// DNSConfig holds the config structure
2016-11-17 00:15:36 +07:00
type DNSConfig struct {
2016-11-13 19:50:44 +07:00
General general
2016-11-17 22:52:55 +07:00
Database dbsettings
2016-11-17 00:15:36 +07:00
API httpapi
2016-11-13 19:50:44 +07:00
Logconfig logconfig
2016-11-11 21:48:00 +07:00
}
// Config file general section
type general struct {
2016-11-28 02:21:38 +07:00
Listen string
2016-11-29 03:46:24 +07:00
Proto string `toml:"protocol"`
Domain string
Nsname string
Nsadmin string
2016-11-16 19:56:49 +07:00
Debug bool
StaticRecords []string `toml:"records"`
2016-11-13 19:50:44 +07:00
}
2016-11-17 22:52:55 +07:00
type dbsettings struct {
Engine string
Connection string
}
2016-11-13 19:50:44 +07: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 21:48:00 +07:00
}
2016-11-13 19:50:44 +07:00
// Logging config
type logconfig struct {
Level string `toml:"loglevel"`
Logtype string `toml:"logtype"`
File string `toml:"logfile"`
Format string `toml:"logformat"`
}
2016-11-28 04:21:46 +07:00
type acmedb struct {
Mutex sync.Mutex
2016-11-28 04:21:46 +07:00
DB *sql.DB
}
type database interface {
Init(string, string) error
2016-12-01 05:03:08 +07:00
Register(cidrslice) (ACMETxt, error)
2016-11-28 04:21:46 +07:00
GetByUsername(uuid.UUID) (ACMETxt, error)
GetTXTForDomain(string) ([]string, error)
Update(ACMETxtPost) error
2016-11-28 04:21:46 +07:00
GetBackend() *sql.DB
SetBackend(*sql.DB)
Close()
}