libdns / hetzner

Hetzner DNS implementation for libdns
MIT License
5 stars 8 forks source link

Cannot create root MX record #5

Open Adphi opened 2 years ago

Adphi commented 2 years ago
package main

import (
    "context"
    "log"
    "os"
    "strings"
    "time"

    "github.com/libdns/hetzner"
    "github.com/libdns/libdns"
)

func main() {
    ctx, cancel := context.WithCancel(context.Background())
    defer cancel()

    zone := "example.org"
    ttl := 3600 * time.Second

    c := hetzner.Provider{AuthAPIToken: os.Getenv("HETZNER_TOKEN")}
    rec := libdns.Record{
        Type:  "MX",
        Name:  zone,
        Value: "10 mail" + "." + zone,
        TTL:   ttl,
    }
    if _, err := c.AppendRecords(ctx, zone, []libdns.Record{rec}); err != nil {
        log.Printf("%s: %s: %v", rec.Name, rec.Value, err)
    } else {
        log.Printf("%s: Created record: %v", rec.Name, rec.Value)
    }
}

Output:

2022/10/08 18:27:04 example.org: 10 mail.example.org: Unprocessable Entity (422)

With https://github.com/libdns/hetzner/pull/4 its works, but I closed it because I thought it was finally working, but I had forgotten that I was using the fork (tiredness...) Could you please reopen it ?