projects
/
ddnset.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f582482
)
IP of "zero" means "only delete"
master
author
Volodymyr Poltavets
<Volodymyr.Poltavets@feig.de>
Mon, 15 Mar 2021 17:45:56 +0000
(18:45 +0100)
committer
Volodymyr Poltavets
<Volodymyr.Poltavets@feig.de>
Mon, 15 Mar 2021 17:45:56 +0000
(18:45 +0100)
ddnset.go
patch
|
blob
|
history
diff --git
a/ddnset.go
b/ddnset.go
index 4328d78f0258954b8113705ad1eaac0eaad92f90..23f17c0304cf2f3a8ef82aa8c66dc220e56243a7 100644
(file)
--- a/
ddnset.go
+++ b/
ddnset.go
@@
-175,9
+175,15
@@
func knsupdate(host, ip, zone string, ver int) bool {
fmt.Fprintf(tmpfile, "server 127.0.0.1\n")
fmt.Fprintf(tmpfile, "zone %s\n", zone)
fmt.Fprintf(tmpfile, "del %s 300 IN %s\n", host, rectype)
fmt.Fprintf(tmpfile, "server 127.0.0.1\n")
fmt.Fprintf(tmpfile, "zone %s\n", zone)
fmt.Fprintf(tmpfile, "del %s 300 IN %s\n", host, rectype)
- fmt.Fprintf(tmpfile, "add %s 300 IN %s %s\n", host, rectype, ip)
+ if "::" != ip && "0.0.0.0" != ip {
+ fmt.Fprintf(tmpfile, "add %s 300 IN %s %s\n", host, rectype, ip)
+ }
fmt.Fprintf(tmpfile, "send\n")
tmpfile.Close()
fmt.Fprintf(tmpfile, "send\n")
tmpfile.Close()
+ /*
+ data, _ := ioutil.ReadFile(tmpfile.Name())
+ log.Printf("%s\n", data)
+ */
out, err := exec.Command("/usr/bin/knsupdate", tmpfile.Name()).Output()
if err != nil {
out, err := exec.Command("/usr/bin/knsupdate", tmpfile.Name()).Output()
if err != nil {
@@
-289,15
+295,26
@@
func rootHandle(w http.ResponseWriter, r *http.Request) {
log.Print("User hosts: ", hosts)
//check ip
q := r.URL.Query()
log.Print("User hosts: ", hosts)
//check ip
q := r.URL.Query()
-
- myip := "
0.0.0.0
"
- ver :=
4
+ log.Print("q: ", q)
+ myip := "
[unset]
"
+ ver :=
0
valid := false
myip_count := len(q["myip"])
log.Print("myips: ", myip_count)
if !hostip {
if myip_count == 1 {
valid := false
myip_count := len(q["myip"])
log.Print("myips: ", myip_count)
if !hostip {
if myip_count == 1 {
- myip, ver, valid = checkIP(q["myip"][0]) //one IP to rule them all
+ myip = q["myip"][0]
+ if "::" == myip {
+ ver = 6
+ valid = true
+ log.Printf("delete AAAA req")
+ } else if "0.0.0.0" == myip {
+ ver = 4
+ valid = true
+ log.Printf("delete A req")
+ } else {
+ myip, ver, valid = checkIP(myip) //one IP to rule them all
+ }
}
log.Printf("IP: %s (valid:%v, ver:%d)", myip, valid, ver)
if !valid {
}
log.Printf("IP: %s (valid:%v, ver:%d)", myip, valid, ver)
if !valid {