cfgo

package
v0.0.0-...-556e507 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSameIP returns when the current ip is alread set on the local storage
	ErrSameIP = errors.New("current and old ip are the same, no need to update")
)

Functions

func GetIPV4IP

func GetIPV4IP() (string, error)

GetIPV4IP gets the current external ipv4 ip

func GetIPV6IP

func GetIPV6IP() (string, error)

GetIPV6IP gets the current external ipv6 ip

func GetInterfaceIPV4

func GetInterfaceIPV4(iface string) (string, error)

GetInterfaceIPV4 returns the ipv4 for the given interface

func UpdateRecord

func UpdateRecord(client Client, zone, dns, ip string) error

UpdateRecord updates the DNS record

Types

type Client

type Client interface {
	GetDNSRecord(zone, dns string) (*Domain, error)
	UpdateDNSRecord(domain *Domain) error
}

Client defines how to client will update records on DNS

type CloudflareClient

type CloudflareClient struct {
	API *cloudflare.API
}

CloudflareClient the Client that will handle the Cloudflare api

func NewCloudflareClient

func NewCloudflareClient(cfKey, cfEmail string) (*CloudflareClient, error)

NewCloudflareClient creates a new client for the cloudflare api

func (*CloudflareClient) GetDNSRecord

func (c *CloudflareClient) GetDNSRecord(zone, dns string) (*Domain, error)

GetDNSRecord gets the Cloudflare DNS record for the given value

zone is the cloudflare domain you are working on eg: domain.com

dns is the address you want get the DNSRecord eg: my.domain.com

The first matching DNSRecord will be returned

func (*CloudflareClient) UpdateDNSRecord

func (c *CloudflareClient) UpdateDNSRecord(domain *Domain) error

UpdateDNSRecord updates the Cloudflare DNSRecord

type Domain

type Domain struct {
	ZoneID   string // the identifier of the zone on cloudflare
	RecordID string // the identifer of the record on cloudflare
	Type     string // valid values: A, AAAA, CNAME, TXT, SRV, LOC, MX, NS, SPF
	Zone     string // cloudflare zone
	DNS      string // cloudflare dns (the domain that will be handled)
	IP       string // the ip of the domain
}

Domain a single domain on the dns

Jump to

Keyboard shortcuts

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