Last active
January 24, 2016 18:22
-
-
Save hlandau/93a45884db97e8dcaeba to your computer and use it in GitHub Desktop.
Convert any DNS record to generic RFC3597 syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reads DNS records in zone file format on stdin and outputs them in generic | |
// RFC3597 format. This is useful if you need to configure DNS records for a | |
// nameserver which doesn't support the rrtypes you're trying to configure. | |
// | |
// Supports whatever rrtypes that github.com/miekg/dns supports, which tends to | |
// be pretty exhaustive. | |
package main | |
import ( | |
"fmt" | |
"github.com/hlandau/xlog" | |
"github.com/miekg/dns" | |
"os" | |
) | |
var log, Log = xlog.New("to3597") | |
func main() { | |
tokCh := dns.ParseZone(os.Stdin, ".", "stdin") | |
for tok := range tokCh { | |
if tok.Error != nil { | |
log.Fatale(tok.Error, "parse error") | |
} | |
if tok.RR == nil { | |
continue | |
} | |
genRR := dns.RFC3597{} | |
err := genRR.ToRFC3597(tok.RR) | |
if err != nil { | |
log.Errore(err, "convert to RFC3597") | |
} | |
fmt.Printf("%s\n", genRR.String()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment