Backend now determines the hostname by subtracting the domain
This commit is contained in:
parent
b3d993b0eb
commit
a018e2d33d
16
ddns.go
16
ddns.go
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue