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") parts := strings.Split(string(line), "\t")
if len(parts) == 6 { if len(parts) == 6 {
query_name := parts[1] 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_class := parts[2]
query_type := parts[3]
query_id := parts[4] query_id := parts[4]
if len(fqdn_parts) > 0 { if hostname != "" {
if conn.HostExist(fqdn_parts[0]) { // check for existance and create response
host := conn.GetHost(fqdn_parts[0]) if conn.HostExist(hostname) {
host := conn.GetHost(hostname)
record := "A" record := "A"
if !host.IsIPv4() { if !host.IsIPv4() {