mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-11-15 12:45:14 +08:00
2f83aa9302
* Switched to v2 go.mod Also set GO111MODULE=on in build stuff to always use Go modules even when in GOPATH. * Ensure go.mod, go.sum, and vendor are up to date * Attempt to fix Azure pipelines * Add set -e to properly fail on exit (it didn't seem to be propagating properly before). * Set workingDirectory for GoFmt and GoGen (this might be why it fails unlike compile and unitests). * Another attempt to fix Azure Pipelines * Use the Go env template for all go-related jobs. * Completely fixed Azure Pipelines * Added a display name to GoFmt for consistency. * Fixed diffs for GoFmt and GoGen. * Show git status for checks. * Drop GOPATH for tests TODO: Do the same for integration tests. * Drop GOPATH for integration tests * Show more diffs * Regenerate provider support matrix This wasn't done in #590...
64 lines
1.4 KiB
Go
64 lines
1.4 KiB
Go
package internetbs
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/StackExchange/dnscontrol/v2/models"
|
|
"github.com/StackExchange/dnscontrol/v2/providers"
|
|
"github.com/pkg/errors"
|
|
"sort"
|
|
"strings"
|
|
)
|
|
|
|
/*
|
|
|
|
Internet.bs Registrator:
|
|
|
|
Info required in `creds.json`:
|
|
- api-key ApiKey
|
|
- password Your account password
|
|
|
|
*/
|
|
|
|
func init() {
|
|
providers.RegisterRegistrarType("INTERNETBS", newInternetBs)
|
|
}
|
|
|
|
func newInternetBs(m map[string]string) (providers.Registrar, error) {
|
|
api := &api{}
|
|
|
|
api.key, api.password = m["api-key"], m["password"]
|
|
if api.key == "" || api.password == "" {
|
|
return nil, errors.Errorf("missing Internet.bs api-key and password")
|
|
}
|
|
|
|
return api, nil
|
|
}
|
|
|
|
// GetRegistrarCorrections gathers corrections that would being n to match dc.
|
|
func (c *api) GetRegistrarCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
|
|
nss, err := c.getNameservers(dc.Name)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
foundNameservers := strings.Join(nss, ",")
|
|
|
|
expected := []string{}
|
|
for _, ns := range dc.Nameservers {
|
|
name := strings.TrimRight(ns.Name, ".")
|
|
expected = append(expected, name)
|
|
}
|
|
sort.Strings(expected)
|
|
expectedNameservers := strings.Join(expected, ",")
|
|
|
|
if foundNameservers != expectedNameservers {
|
|
return []*models.Correction{
|
|
{
|
|
Msg: fmt.Sprintf("Update nameservers (%s) -> (%s)", foundNameservers, expectedNameservers),
|
|
F: func() error {
|
|
return c.updateNameservers(expected, dc.Name)
|
|
},
|
|
},
|
|
}, nil
|
|
}
|
|
return nil, nil
|
|
}
|