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"
|
2023-06-19 16:27:36 +01:00
|
|
|
"github.com/MrMelon54/mjwt"
|
2023-04-22 18:11:21 +01:00
|
|
|
errorPages "github.com/MrMelon54/violet/error-pages"
|
|
|
|
"github.com/MrMelon54/violet/favicons"
|
2023-04-24 15:36:21 +01:00
|
|
|
"github.com/MrMelon54/violet/router"
|
2023-04-22 18:11:21 +01:00
|
|
|
)
|
|
|
|
|
2023-04-24 15:36: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 {
|
2023-04-24 15:36:21 +01:00
|
|
|
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
|
2023-06-19 16:27:36 +01:00
|
|
|
Verify mjwt.Verifier
|
2023-04-22 18:11:21 +01:00
|
|
|
ErrorPages *errorPages.ErrorPages
|
2023-04-24 15:36:21 +01:00
|
|
|
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
|
2023-06-20 16:48:04 +01:00
|
|
|
Put(domain string, active bool)
|
|
|
|
Delete(domain string)
|
2023-06-20 16:59:39 +01:00
|
|
|
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
|
2023-06-20 16:48:04 +01:00
|
|
|
Compile()
|
2023-06-04 22:28:48 +01:00
|
|
|
}
|