maddy

Fork https://github.com/foxcpp/maddy

git clone git://git.lin.moe/go/maddy.git

 1//go:build libdns_gcore || !libdns_separate
 2// +build libdns_gcore !libdns_separate
 3
 4package libdns
 5
 6import (
 7	"fmt"
 8
 9	"github.com/foxcpp/maddy/framework/config"
10	"github.com/foxcpp/maddy/framework/module"
11	"github.com/libdns/gcore"
12)
13
14func init() {
15	module.Register("libdns.gcore", func(modName, instName string, _, _ []string) (module.Module, error) {
16		p := gcore.Provider{}
17		return &ProviderModule{
18			RecordDeleter:  &p,
19			RecordAppender: &p,
20			setConfig: func(c *config.Map) {
21				c.String("api_key", false, false, "", &p.APIKey)
22			},
23			afterConfig: func() error {
24				if p.APIKey == "" {
25					return fmt.Errorf("libdns.gcore: api_key should be specified")
26				}
27				return nil
28			},
29
30			instName: instName,
31			modName:  modName,
32		}, nil
33	})
34}