dinahosting

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2022 License: MIT Imports: 8 Imported by: 2

README

Dinahosting DNS for libdns

Go Reference

This package implements the libdns interfaces for Dinahosting API, allowing you to manage DNS records for your domains.

Limitations

As this library is mainly intended to be used as a Caddy plugin for solving ACME challenges and adding dynamic dns capabilities,(and also beacause Dinahosting API is quite messy to work with) it only supports A and TXT records for the moment. I may add more in the future.

Authenticating

Dinahosting does not provide API keys, so you will need to use the username and password of your account.

Testing

You can easily test the library against your account. Just add your details to the test file provider_test.go:

// To be able to run the tests succesfully please replace this constants with you actual account details.
//
// This tests assumes you have a test zone with only 1 A type record
// they will create, modify and delete some records on that zone
// but it should be at the original state afer finishing runinng.
const (
	username = "YOUR_USERNAME"
	password = "YOUR_PASSWORD"
	zone     = "example.com"
	ip       = "YOUR A RECORD IP"
)

and run the tests:

go test provider_test.go

Example usage

Here is a minimal example of how to create a new TXT record using this libdns provider.

package main

import (
    "context"

    "github.com/libdns/libdns"
    "github.com/libdns/dinahosting"
)

func main() {
    p := &dinahosting.Provider{
        Username: "YOUR_USERNAME",   // required
        Password: "YOUR_PASSWORD",   // required
    }

    _, err := p.AppendRecords(context.Background(), "example.org.", []libdns.Record{
        {
            Name:  "_acme_whatever",
            Type:  "TXT",
            Value: "123456",
        },
    })
    if err != nil {
        panic(err)
    }
}

Documentation

Overview

Package dinahosting implements a DNS record management client compatible with the libdns interfaces for Dinahosting (https://es.dinahosting.com/api).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

Provider facilitates DNS record manipulation with Dinahosting.

func (*Provider) AppendRecords

func (p *Provider) AppendRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

AppendRecords adds records to the zone. It returns the records that were added.

API docs: https://es.dinahosting.com/api/documentation

func (*Provider) DeleteRecords

func (p *Provider) DeleteRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

DeleteRecords deletes the records from the zone. It returns the records that were deleted.

API docs: https://es.dinahosting.com/api/documentation

func (*Provider) SetRecords

func (p *Provider) SetRecords(ctx context.Context, zone string, records []libdns.Record) ([]libdns.Record, error)

SetRecords sets the records in the zone, either by updating existing records or creating new ones. It returns the updated records.

API docs: https://es.dinahosting.com/api/documentation

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL