Backend now determines the hostname by subtracting the domain

This commit is contained in:
Philipp Böhm 2014-07-15 22:58:12 +02:00
parent b3d993b0eb
commit a018e2d33d
1 changed files with 12 additions and 4 deletions

16
ddns.go
View File

@ -37,14 +37,22 @@ func RunBackend() {
parts := strings.Split(string(line), "\t")
if len(parts) == 6 {
query_name := parts[1]
fqdn_parts := strings.Split(query_name, ".")
// get the host part of the fqdn
// pi.d.example.org -> pi
hostname := ""
if strings.HasSuffix(query_name, DdnsDomain) {
hostname = query_name[:len(query_name)-len(DdnsDomain)]
}
query_class := parts[2]
query_type := parts[3]
query_id := parts[4]
if len(fqdn_parts) > 0 {
if conn.HostExist(fqdn_parts[0]) {
host := conn.GetHost(fqdn_parts[0])
if hostname != "" {
// check for existance and create response
if conn.HostExist(hostname) {
host := conn.GetHost(hostname)
record := "A"
if !host.IsIPv4() {