acme-dns/types.go

90 lines
1.8 KiB
Go
Raw Normal View History

2016-11-11 21:48:00 +07:00
package main
import (
2016-11-28 04:21:46 +07:00
"database/sql"
2016-11-11 21:48:00 +07:00
"github.com/miekg/dns"
2016-11-13 19:50:44 +07:00
"github.com/satori/go.uuid"
2016-11-28 04:21:46 +07:00
"sync"
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
// RR holds the static DNS records
var RR Records
2016-11-23 23:07:38 +07:00
// Records is for static records
2016-11-11 21:48:00 +07:00
type Records struct {
Records map[uint16]map[string][]dns.RR
}
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
}
2016-11-13 19:50:44 +07:00
// Auth middleware
2016-11-23 23:07:38 +07:00
type authMiddleware struct{}
2016-11-13 19:50:44 +07:00
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 {
2016-11-28 04:21:46 +07:00
Domain string `toml:"api_domain"`
LEmail string `toml:"le_email"`
IP string
Port string `toml:"port"`
2016-11-17 00:15:36 +07:00
TLS string
TLSCertPrivkey string `toml:"tls_cert_privkey"`
TLSCertFullchain string `toml:"tls_cert_fullchain"`
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 {
sync.Mutex
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)
GetByDomain(string) ([]ACMETxt, error)
Update(ACMETxt) error
GetBackend() *sql.DB
SetBackend(*sql.DB)
Close()
Lock()
Unlock()
}