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")
|
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() {
|
||||||
|
|
Loading…
Reference in New Issue