Skip to content

Commit 3fd979e

Browse files
committed
Implement libdns provider for http.net DNS API
0 parents  commit 3fd979e

9 files changed

Lines changed: 1257 additions & 0 deletions

File tree

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Bene-GG
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# http.net DNS for `libdns`
2+
3+
[![Go Reference](https://pkg.go.dev/badge/github.com/libdns/httpnet.svg)](https://pkg.go.dev/github.com/libdns/httpnet)
4+
5+
This package implements the [libdns](https://github.com/libdns/libdns) interfaces for [http.net](https://www.http.net), allowing DNS records to be managed via the http.net partner API.
6+
7+
## Authenticating
8+
9+
Create an API token in the [http.net partner portal](https://partner.http.net)
10+
(API documentation: <https://www.http.net/docs/api/>) and pass it to the
11+
provider:
12+
13+
```go
14+
import "github.com/libdns/httpnet"
15+
16+
provider := &httpnet.Provider{
17+
AuthToken: "your-api-token",
18+
}
19+
20+
records, err := provider.GetRecords(context.Background(), "example.com.")
21+
```
22+
23+
The `Provider` implements `RecordGetter`, `RecordAppender`, `RecordSetter`, `RecordDeleter`, and `ZoneLister`.
24+
25+
Any DNS record type accepted by the http.net API is supported: records are
26+
parsed into the matching typed `libdns.Record` (`libdns.Address`, `libdns.MX`,
27+
`libdns.TXT`, …) via `libdns.RR.Parse()`.
28+
29+
## Caveats
30+
31+
### TTL floor
32+
33+
The http.net API enforces a 60-second minimum TTL. Lower values (including zero)
34+
are silently raised to 60 before being sent, to avoid request rejection.
35+
36+
### Asynchronous writes
37+
38+
Write operations may return a `pending` status with an empty record list. The
39+
provider handles this by performing a follow-up read, so callers still receive
40+
records with their assigned IDs.
41+
42+
### Atomicity
43+
44+
Updates within a single call are applied atomically by `recordsUpdate`, but
45+
concurrent modifications from separate processes to the same RRset may result
46+
in inconsistent state. Ensure concurrent processes operate on different RRsets.
47+
48+
## Testing
49+
50+
Unit tests run against an in-process mock server and require no credentials:
51+
52+
```bash
53+
go test ./...
54+
```
55+
56+
Integration tests against the live http.net API are opt-in via environment
57+
variables:
58+
59+
```bash
60+
export HTTPNET_AUTH_TOKEN=<your-api-token>
61+
export HTTPNET_TEST_ZONE=example.com. # a zone you control; trailing dot required
62+
go test -v ./...
63+
```
64+
65+
Tests that find these variables unset are skipped automatically.
66+
67+
## License
68+
69+
MIT

0 commit comments

Comments
 (0)