2016-11-11 16:48:00 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-11-27 23:21:46 +02:00
|
|
|
"database/sql"
|
|
|
|
"sync"
|
2018-08-10 16:51:32 +03:00
|
|
|
|
|
|
|
"github.com/google/uuid"
|
2016-11-11 16:48:00 +02:00
|
|
|
)
|
|
|
|
|
2017-11-14 00:42:30 +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"`
|
2016-11-15 09:27:34 +02:00
|
|
|
Domain string
|
|
|
|
Nsname string
|
|
|
|
Nsadmin string
|
2016-11-16 14:56:49 +02:00
|
|
|
Debug bool
|
2016-11-15 09:27:34 +02:00
|
|
|
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 {
|
2018-03-14 23:35:39 +02:00
|
|
|
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"`
|
2018-05-14 05:42:39 -05:00
|
|
|
ACMECacheDir string `toml:"acme_cache_dir"`
|
2021-01-11 06:35:54 -06:00
|
|
|
NotificationEmail string `toml:"notification_email"`
|
2018-03-14 23:35:39 +02:00
|
|
|
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 {
|
2022-08-10 15:17:11 +03:00
|
|
|
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)
|
2018-01-22 09:53:07 +02:00
|
|
|
GetTXTForDomain(string) ([]string, error)
|
2019-06-12 14:41:02 +02:00
|
|
|
Update(ACMETxtPost) error
|
2016-11-27 23:21:46 +02:00
|
|
|
GetBackend() *sql.DB
|
|
|
|
SetBackend(*sql.DB)
|
|
|
|
Close()
|
|
|
|
}
|