maddy

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

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

 1//go:build libdns_gandi || !libdns_separate
 2// +build libdns_gandi !libdns_separate
 3
 4package libdns
 5
 6import (
 7	"fmt"
 8
 9	"github.com/foxcpp/maddy/framework/config"
10	"github.com/foxcpp/maddy/framework/log"
11	"github.com/foxcpp/maddy/framework/module"
12	"github.com/libdns/gandi"
13)
14
15func init() {
16	module.Register("libdns.gandi", func(modName, instName string, _, _ []string) (module.Module, error) {
17		p := gandi.Provider{}
18		return &ProviderModule{
19			RecordDeleter:  &p,
20			RecordAppender: &p,
21			setConfig: func(c *config.Map) {
22				c.String("api_token", false, false, "", &p.APIToken)
23				c.String("personal_token", false, false, "", &p.BearerToken)
24			},
25			afterConfig: func() error {
26				if p.APIToken != "" {
27					log.Println("libdns.gandi: api_token is deprecated, use personal_token instead (https://api.gandi.net/docs/authentication/)")
28				}
29				if p.APIToken == "" && p.BearerToken == "" {
30					return fmt.Errorf("libdns.gandi: either api_token or personal_token should be specified")
31				}
32				return nil
33			},
34			instName: instName,
35			modName:  modName,
36		}, nil
37	})
38}