support flags
parent
e373627c09
commit
d2cf67828e
10
main.go
10
main.go
|
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
|
@ -48,7 +49,10 @@ curl "https://www.namesilo.com/api/dnsUpdateRecord?version=1&type=xml&key=7a26bd
|
|||
*/
|
||||
|
||||
func main() {
|
||||
resp, err := http.Get("https://www.namesilo.com/api/dnsListRecords?version=1&type=xml&key=7a26bd4b7aedbc6c44f56af38&domain=blapointe.com")
|
||||
domain := flag.String("domain", "blapoionte.com", "domain to modify")
|
||||
subdomain := flag.String("prefix", "*.home.", "subdomain to modify")
|
||||
flag.Parse()
|
||||
resp, err := http.Get("https://www.namesilo.com/api/dnsListRecords?version=1&type=xml&key=7a26bd4b7aedbc6c44f56af38&domain=" + *domain)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
@ -75,11 +79,11 @@ func main() {
|
|||
panic(err)
|
||||
}
|
||||
for _, v := range rawraw.Namesilo.Reply.ResourceRecord {
|
||||
if v.Host == "*.home.blapointe.com" {
|
||||
if v.Host == *subdomain+*domain {
|
||||
rrid := v.RecordID
|
||||
ip := rawraw.Namesilo.Request.IP
|
||||
log.Println(rrid, ip)
|
||||
url := fmt.Sprintf("https://www.namesilo.com/api/dnsUpdateRecord?version=1&type=xml&key=7a26bd4b7aedbc6c44f56af38&domain=blapointe.com&rrid=%s&rrhost=*.home&rrvalue=%s&rrttl=3600", rrid, ip)
|
||||
url := fmt.Sprintf("https://www.namesilo.com/api/dnsUpdateRecord?version=1&type=xml&key=7a26bd4b7aedbc6c44f56af38&domain="+*domain+"&rrid=%s&rrhost="+strings.TrimRight(*subdomain, ".")+"&rrvalue=%s&rrttl=3600", rrid, ip)
|
||||
resp, err := http.Get(url)
|
||||
b, _ := ioutil.ReadAll(resp.Body)
|
||||
js, _ := xj.Convert(bytes.NewBuffer(b))
|
||||
|
|
|
|||
Loading…
Reference in New Issue