violet/servers/conf.go

45 lines
1.1 KiB
Go
Raw Normal View History

2023-04-22 18:11:21 +01:00
package servers
import (
2023-06-04 22:28:48 +01:00
"crypto/tls"
2023-04-22 18:11:21 +01:00
"database/sql"
"github.com/MrMelon54/mjwt"
2023-04-22 18:11:21 +01:00
errorPages "github.com/MrMelon54/violet/error-pages"
"github.com/MrMelon54/violet/favicons"
"github.com/MrMelon54/violet/router"
2023-04-22 18:11:21 +01:00
)
// Conf stores the shared configuration for the API, HTTP and HTTPS servers.
2023-04-22 18:11:21 +01:00
type Conf struct {
ApiListen string // api server listen address
HttpListen string // http server listen address
HttpsListen string // https server listen address
2023-06-04 22:28:48 +01:00
RateLimit uint64 // rate limit per minute
2023-04-22 18:11:21 +01:00
DB *sql.DB
2023-06-04 22:28:48 +01:00
Domains DomainProvider
Acme AcmeChallengeProvider
Certs CertProvider
2023-04-22 18:11:21 +01:00
Favicons *favicons.Favicons
Verify mjwt.Verifier
2023-04-22 18:11:21 +01:00
ErrorPages *errorPages.ErrorPages
Router *router.Manager
2023-04-22 18:11:21 +01:00
}
2023-06-04 22:28:48 +01:00
type DomainProvider interface {
IsValid(host string) bool
Put(domain string, active bool)
Delete(domain string)
Compile()
2023-06-04 22:28:48 +01:00
}
type AcmeChallengeProvider interface {
Get(domain, key string) string
Put(domain, key, value string)
Delete(domain, key string)
}
type CertProvider interface {
GetCertForDomain(domain string) *tls.Certificate
Compile()
2023-06-04 22:28:48 +01:00
}