mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-01 09:32:35 +02:00

Some checks are pending
Docker Image CI (socket-proxy) / build (push) Waiting to run
* refactor: simplify io code and make utils module independent * fix(docker): agent and socket-proxy docker event flushing with modified reverse proxy handler * refactor: remove unused code * refactor: remove the use of logging module in most code * refactor: streamline domain mismatch check in certState function * tweak: use ecdsa p-256 for autocert * fix(tests): update health check tests for invalid host and add case for port in host * feat(acme): custom acme directory * refactor: code refactor and improved context and error handling * tweak: optimize memory usage under load * fix(oidc): restore old user matching behavior * docs: add ChatGPT assistant to README --------- Co-authored-by: yusing <yusing@6uo.me>
28 lines
685 B
Go
28 lines
685 B
Go
package autocert
|
|
|
|
import (
|
|
"github.com/go-acme/lego/v4/challenge"
|
|
"github.com/yusing/go-proxy/internal/gperr"
|
|
"github.com/yusing/go-proxy/internal/serialization"
|
|
)
|
|
|
|
type Generator func(map[string]any) (challenge.Provider, gperr.Error)
|
|
|
|
var Providers = make(map[string]Generator)
|
|
|
|
func DNSProvider[CT any, PT challenge.Provider](
|
|
defaultCfg func() *CT,
|
|
newProvider func(*CT) (PT, error),
|
|
) Generator {
|
|
return func(opt map[string]any) (challenge.Provider, gperr.Error) {
|
|
cfg := defaultCfg()
|
|
if len(opt) > 0 {
|
|
err := serialization.MapUnmarshalValidate(opt, &cfg)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
p, pErr := newProvider(cfg)
|
|
return p, gperr.Wrap(pErr)
|
|
}
|
|
}
|