Files
acme-dns/types.go

101 lines
1.9 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"
2016-11-11 16:48:00 +02:00
"github.com/miekg/dns"
2016-11-13 14:50:44 +02:00
"github.com/satori/go.uuid"
2016-11-27 23:21:46 +02:00
"sync"
2016-11-11 16:48:00 +02:00
)
2016-11-28 13:13:45 +02:00
// DNSConf is global configuration struct
var DNSConf DNSConfig
// 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 18:07:38 +02:00
// Records is for static records
2016-11-11 16:48:00 +02:00
type Records struct {
Records map[uint16]map[string][]dns.RR
}
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
}
2016-11-13 14:50:44 +02:00
// Auth middleware
2016-11-23 18:07:38 +02:00
type authMiddleware struct{}
2016-11-13 14:50:44 +02:00
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 {
2016-11-27 23:21:46 +02:00
Domain string `toml:"api_domain"`
2016-11-16 19:15:36 +02:00
Port string
TLS string
TLSCertPrivkey string `toml:"tls_cert_privkey"`
TLSCertFullchain string `toml:"tls_cert_fullchain"`
CorsOrigins []string
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-23 18:07:38 +02:00
// ACMETxt is the default structure for the user controlled record
2016-11-13 14:50:44 +02:00
type ACMETxt struct {
Username uuid.UUID
Password string
ACMETxtPost
2016-11-17 17:52:55 +02:00
LastActive int64
AllowFrom string
2016-11-13 14:50:44 +02:00
}
2016-11-23 18:07:38 +02:00
// ACMETxtPost holds the DNS part of the ACMETxt struct
2016-11-13 14:50:44 +02:00
type ACMETxtPost struct {
Subdomain string `json:"subdomain"`
Value string `json:"txt"`
}
2016-11-27 23:21:46 +02:00
type acmedb struct {
sync.Mutex
DB *sql.DB
}
type database interface {
Init(string, string) error
Register() (ACMETxt, error)
GetByUsername(uuid.UUID) (ACMETxt, error)
GetByDomain(string) ([]ACMETxt, error)
Update(ACMETxt) error
GetBackend() *sql.DB
SetBackend(*sql.DB)
Close()
Lock()
Unlock()
}