MCPcopy Create free account
hub / github.com/foxcpp/maddy / Configure

Method Configure

internal/tls/file.go:57–87  ·  view source on GitHub ↗
(inlineArgs []string, cfg *config.Map)

Source from the content-addressed store, hash-verified

55}
56
57func (f *FileLoader) Configure(inlineArgs []string, cfg *config.Map) error {
58 cfg.StringList("certs", false, false, nil, &f.certPaths)
59 cfg.StringList("keys", false, false, nil, &f.keyPaths)
60 if _, err := cfg.Process(); err != nil {
61 return err
62 }
63
64 if len(f.certPaths) != len(f.keyPaths) {
65 return errors.New("tls.loader.file: mismatch in certs and keys count")
66 }
67
68 if len(inlineArgs)%2 != 0 {
69 return errors.New("tls.loader.file: odd amount of arguments")
70 }
71 for i := 0; i < len(inlineArgs); i += 2 {
72 f.certPaths = append(f.certPaths, inlineArgs[i])
73 f.keyPaths = append(f.keyPaths, inlineArgs[i+1])
74 }
75
76 for _, certPath := range f.certPaths {
77 if !filepath.IsAbs(certPath) {
78 return fmt.Errorf("tls.loader.file: only absolute paths allowed in certificate paths: sorry :(")
79 }
80 }
81
82 if err := f.loadCerts(); err != nil {
83 return err
84 }
85
86 return nil
87}
88
89func (f *FileLoader) Start() error {
90 f.reloadTick = time.NewTicker(time.Minute)

Callers

nothing calls this directly

Calls 3

loadCertsMethod · 0.95
StringListMethod · 0.80
ProcessMethod · 0.80

Tested by

no test coverage detected