dnscontrol/providers/hexonet/hexonetProvider.go
Patrick Gaskin 2f83aa9302 Internals: Switch to v2 go.mod, drop GOPATH, and fix Azure Pipelines (#595)
* 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...
2020-01-28 10:42:31 -05:00

70 lines
2.4 KiB
Go

// Package hexonet implements a registrar that uses the hexonet api to set name servers. It will self register it's providers when imported.
package hexonet
import (
"encoding/json"
"fmt"
"github.com/StackExchange/dnscontrol/v2/providers"
hxcl "github.com/hexonet/go-sdk/client"
)
// HXClient describes a connection to the hexonet API.
type HXClient struct {
APILogin string
APIPassword string
APIEntity string
client *hxcl.Client
}
var features = providers.DocumentationNotes{
providers.CanUseAlias: providers.Cannot("Using ALIAS is possible through our extended DNS (X-DNS) service. Feel free to get in touch with us."),
providers.CanUseCAA: providers.Can(),
providers.CanUsePTR: providers.Can(),
providers.CanUseRoute53Alias: providers.Cannot("Using ALIAS is possible through our extended DNS (X-DNS) service. Feel free to get in touch with us."),
providers.CanUseSRV: providers.Can(),
providers.CanUseTLSA: providers.Can(),
providers.CanUseTXTMulti: providers.Can(),
providers.CantUseNOPURGE: providers.Can(),
providers.DocCreateDomains: providers.Can(),
providers.DocDualHost: providers.Can(),
providers.DocOfficiallySupported: providers.Cannot("Actively maintained provider module."),
}
func newProvider(conf map[string]string) (*HXClient, error) {
api := &HXClient{
client: hxcl.NewClient(),
}
api.APILogin, api.APIPassword, api.APIEntity = conf["apilogin"], conf["apipassword"], conf["apientity"]
if conf["debugmode"] == "1" {
api.client.EnableDebugMode()
}
if len(conf["ipaddress"]) > 0 {
api.client.SetIPAddress(conf["ipaddress"])
}
if api.APIEntity != "OTE" && api.APIEntity != "LIVE" {
return nil, fmt.Errorf("wrong api system entity used. use \"OTE\" for OT&E system or \"LIVE\" for Live system")
}
if api.APIEntity == "OTE" {
api.client.UseOTESystem()
}
if api.APILogin == "" || api.APIPassword == "" {
return nil, fmt.Errorf("missing login credentials apilogin or apipassword")
}
api.client.SetCredentials(api.APILogin, api.APIPassword, "")
return api, nil
}
func newReg(conf map[string]string) (providers.Registrar, error) {
return newProvider(conf)
}
func newDsp(conf map[string]string, meta json.RawMessage) (providers.DNSServiceProvider, error) {
return newProvider(conf)
}
func init() {
providers.RegisterRegistrarType("HEXONET", newReg)
providers.RegisterDomainServiceProviderType("HEXONET", newDsp, features)
}