rind
rind copied to clipboard
How do you manually add rules?
It looks like the library implementation for querying records is public - but saving is private. How can I start the server with some seed records without using a separate HTTP client to insert the rules via the HTTP/S interface?
var initialRules = []string{`{
"Host": "_sip._tcp.example.com.",
"TTL": 300,
"Type": "SRV",
"SRV": {
"Priority": 0,
"Weight": 5,
"Port": 5060,
"Target": "sipserver.example.com."
}`}
dns := rind.Start("", []net.UDPAddr{{IP: net.IP{1, 1, 1, 1}, Port: 53}})
for _, rule := range initialRules {
var req rind.Request
if err := json.NewDecoder(rule).Decode(&req); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
resource, err := rind.toResource(req)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
dns.save(rind.ntString(resource.Header.Name, resource.Header.Type), resource, nil)
}
you should be able to use curl and in doing so execute a bash script or similar to load it.
No reason to execute an external program. As I said, I could create an http.Request
object, start an HTTP server, run the client requests, etc.. all within Go... but why?
If @owlwalks can just change the save()
function to public we won't need workarounds.
Static rules will open whole range of parsing, I wouldn't suggest http.Request to start with, a text zone file is more of a favored practice:
example.com. IN A 192.0.2.1
The whole zone-file would be great, but can't we just make save() public for now so that I can add a few records?