All Projects → joeig → go-powerdns

joeig / go-powerdns

Licence: MIT license
Go PowerDNS 4.x API Client

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to go-powerdns

Pdns
PowerDNS Authoritative, PowerDNS Recursor, dnsdist
Stars: ✭ 2,575 (+3578.57%)
Mutual labels:  powerdns
docker-pdns
Docker images for PowerDNS
Stars: ✭ 148 (+111.43%)
Mutual labels:  powerdns
powerdns-php
PowerDNS API PHP Client
Stars: ✭ 67 (-4.29%)
Mutual labels:  powerdns
powerdns
PowerDNS dnsdist, recursor, authoritative, and admin interface. Supports DNSCrypt, DoH, and DoT.
Stars: ✭ 35 (-50%)
Mutual labels:  powerdns
PowerDNS-Admin
A PowerDNS web interface with advanced features
Stars: ✭ 1,612 (+2202.86%)
Mutual labels:  powerdns
docker-powerdns
PowerDNS + Recursor + Admin GUI + Adblock in one single Docker
Stars: ✭ 49 (-30%)
Mutual labels:  powerdns
docker-powerdns-admin
PowerDNS Admin Web UI. Dockerized version of https://github.com/ngoduykhanh/PowerDNS-Admin
Stars: ✭ 18 (-74.29%)
Mutual labels:  powerdns
chef-pdns
Development repository for DNSimple Cookbook PowerDNS.
Stars: ✭ 22 (-68.57%)
Mutual labels:  powerdns
dnstap-receiver
Dnstap streams receiver in Python
Stars: ✭ 33 (-52.86%)
Mutual labels:  powerdns

PowerDNS 4.x API bindings for Golang

This community project provides bindings for PowerDNS Authoritative Server. It's not associated with the official PowerDNS product itself.

Build Status Go Report Card Coverage Status PkgGoDev

Features

  • Zone handling
  • Resource record handling
  • Server statistics gathering
  • DNSSEC handling

For more features, consult our documentation.

Usage

Initialize the handle

import (
  "context"
  "github.com/joeig/go-powerdns/v3"
)

pdns := powerdns.NewClient("http://localhost:80", "localhost", map[string]string{"X-API-Key": "apipw"}, nil)

Assuming that the server is listening on http://localhost:80 for virtual host localhost, the API password is apipw and you want to edit the domain example.com.

Get/add/change/delete zones

ctx := context.Background()

zones, err := pdns.Zones.List(ctx)
zone, err := pdns.Zones.Get(ctx, "example.com")
export, err := pdns.Zones.Export(ctx, "example.com")
zone, err := pdns.Zones.AddNative(ctx, "example.com", true, "", false, "foo", "foo", true, []string{"ns.foo.tld."})
err := pdns.Zones.Change(ctx, "example.com", &zone)
err := pdns.Zones.Delete(ctx, "example.com")

Add/change/delete resource records

err := pdns.Records.Add(ctx, "example.com", "www.example.com", powerdns.RRTypeAAAA, 60, []string{"::1"})
err := pdns.Records.Change(ctx, "example.com", "www.example.com", powerdns.RRTypeAAAA, 3600, []string{"::1"})
err := pdns.Records.Delete(ctx, "example.com", "www.example.com", powerdns.RRTypeA)

Request server information and statistics

statistics, err := pdns.Statistics.List(ctx)
servers, err := pdns.Servers.List(ctx)
server, err := pdns.Servers.Get(ctx, "localhost")

Handle DNSSEC cryptographic material

cryptokeys, err := pdns.Cryptokeys.List(ctx)
cryptokey, err := pdns.Cryptokeys.Get(ctx, "example.com", "1337")
err := pdns.Cryptokeys.Delete(ctx, "example.com", "1337")

More examples

See examples.

Documentation

See pkg.go.dev for a full reference.

Setup

Requirements

Tested PowerDNS versions

Supported versions of PowerDNS Authoritative Server ("API v1"):

  • 4.5
  • 4.6
  • 4.7

Version 4.1, 4.2 and 4.3 are probably working fine, but are officially end-of-life. Be aware that there are breaking changes in "API v1" between PowerDNS 3.x, 4.0 and 4.1.

Tested Go versions

In accordance with Go's version support policy, this module is being tested with the following Go releases:

  • 1.19
  • 1.20

Contribution

This API client has not been completed yet, so feel free to contribute. The OpenAPI specification is a good reference.

You can use Docker Compose to launch a PowerDNS authoritative server including a generic SQLite3 backend, DNSSEC support and some optional fixtures:

docker-compose -f docker-compose-v4.7.yml up
docker-compose -f docker-compose-v4.7.yml exec powerdns sh init_docker_fixtures.sh

It's also possible to target mocks against this server, or any other PowerDNS instance which is running on http://localhost:8080.

make test-without-mocks

The mocks assume there is a vHost/Server ID called localhost and API key apipw.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].