handle soa requests

This commit is contained in:
Konstantin Demin 2024-06-04 11:57:44 +03:00
parent 6d0875e29a
commit f9618226fd
Signed by: krd
GPG Key ID: 4D56F87A8BA65FD0
2 changed files with 21 additions and 0 deletions

3
cfg.go
View File

@ -22,4 +22,7 @@ const (
cfgNftMapV6 = "tele6" cfgNftMapV6 = "tele6"
cfgNftCidrV4 = "251.0.0.0/8" cfgNftCidrV4 = "251.0.0.0/8"
cfgNftCidrV6 = "2001:db8:11::/48" cfgNftCidrV6 = "2001:db8:11::/48"
cfgSoaNs = "gw.vpn."
cfgSoaMbox = "dns.gw.vpn."
) )

View File

@ -5,12 +5,14 @@ package main
import ( import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt"
"io" "io"
"log" "log"
"net/http" "net/http"
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
"time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/miekg/dns" "github.com/miekg/dns"
@ -312,6 +314,22 @@ func dnsApi_lookup(r *PowerDnsJsonRequest) (interface{}, error) {
} }
func dnsApi_lookup_int(qname string, qtype uint16) (interface{}, error) { func dnsApi_lookup_int(qname string, qtype uint16) (interface{}, error) {
if qtype == dns.TypeSOA {
return []PowerDnsAnswer{
{
Qname: qname,
Qtype: dns.TypeToString[qtype],
Ttl: cfgTtlMax,
Content: fmt.Sprintf("%v %v %v %v %v %v %v",
// ns mbox serial
cfgSoaNs, cfgSoaMbox, time.Now().Unix(),
// refresh retry expire minttl
cfgTtlMax/2, cfgTtlMax, cfgTtlMax*2, cfgTtlMin,
),
},
}, nil
}
resp, err := dnsCustomResolve(qname, qtype) resp, err := dnsCustomResolve(qname, qtype)
if err != nil { if err != nil {
return nil, err return nil, err