https://github.com/libdns/njalla
https://github.com/libdns/njalla
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/libdns/njalla
- Owner: libdns
- License: mit
- Created: 2022-10-06T22:31:14.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-08-15T08:10:32.000Z (10 months ago)
- Last Synced: 2025-11-29T23:54:15.253Z (7 months ago)
- Language: Go
- Size: 30.3 KB
- Stars: 3
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Njalla for [`libdns`](https://github.com/libdns/libdns)
=======================
[](https://pkg.go.dev/github.com/libdns/njalla)
This package implements the [libdns interfaces](https://github.com/libdns/libdns) for [Njalla](https://njal.la/), allowing you to manage DNS records.
## Configuration
To use this provider, you'll need to obtain an API token from Njalla. You can generate an API token from your Njalla account settings.
## Example
```go
package main
import (
"context"
"fmt"
"net/netip"
"time"
"github.com/libdns/libdns"
"github.com/libdns/njalla"
)
func main() {
// Create the provider
provider := njalla.Provider{
APIToken: "your-njalla-api-token",
}
// Define your zone
zone := "example.com"
// Add a record
records, err := provider.AppendRecords(context.TODO(), zone, []libdns.Record{
libdns.Address{
Name: "test",
IP: netip.MustParseAddr("192.0.2.1"),
TTL: time.Hour,
},
})
if err != nil {
fmt.Printf("Error adding record: %v\n", err)
return
}
fmt.Printf("Records added: %v\n", records)
// Get all records
allRecords, err := provider.GetRecords(context.TODO(), zone)
if err != nil {
fmt.Printf("Error getting records: %v\n", err)
return
}
fmt.Printf("All records: %v\n", allRecords)
// Delete records
deletedRecords, err := provider.DeleteRecords(context.TODO(), zone, records)
if err != nil {
fmt.Printf("Error deleting records: %v\n", err)
return
}
fmt.Printf("Deleted records: %v\n", deletedRecords)
}
```
## Caveats
- This provider is compatible with libdns v1.1.0 and follows the updated interfaces that use the new Record type system.
- The following record types are fully supported: A, AAAA, CNAME, TXT, MX, SRV
- Other record types are supported using the generic RR structure.