mirror of
https://github.com/taigrr/godns
synced 2025-01-18 04:03:25 -08:00
Bug fix
This commit is contained in:
parent
2f6c8c23e3
commit
8edfb5be83
@ -116,10 +116,10 @@ func getSubDomain(domainID int64, name string) (string, string) {
|
|||||||
return "", ""
|
return "", ""
|
||||||
}
|
}
|
||||||
|
|
||||||
sjson, parse_err := simplejson.NewJson([]byte(response))
|
sjson, parseErr := simplejson.NewJson([]byte(response))
|
||||||
|
|
||||||
if parse_err != nil {
|
if parseErr != nil {
|
||||||
log.Println(parse_err)
|
log.Println(parseErr)
|
||||||
return "", ""
|
return "", ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,11 +144,11 @@ func getSubDomain(domainID int64, name string) (string, string) {
|
|||||||
return ret, ip
|
return ret, ip
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateIP(domain_id int64, sub_domain_id string, sub_domain_name string, ip string) {
|
func updateIP(domainID int64, subDomainID string, subDomainName string, ip string) {
|
||||||
value := url.Values{}
|
value := url.Values{}
|
||||||
value.Add("domain_id", strconv.FormatInt(domain_id, 10))
|
value.Add("domain_id", strconv.FormatInt(domainID, 10))
|
||||||
value.Add("record_id", sub_domain_id)
|
value.Add("record_id", subDomainID)
|
||||||
value.Add("sub_domain", sub_domain_name)
|
value.Add("sub_domain", subDomainName)
|
||||||
value.Add("record_type", "A")
|
value.Add("record_type", "A")
|
||||||
value.Add("record_line", "默认")
|
value.Add("record_line", "默认")
|
||||||
value.Add("value", ip)
|
value.Add("value", ip)
|
||||||
@ -161,10 +161,10 @@ func updateIP(domain_id int64, sub_domain_id string, sub_domain_name string, ip
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sjson, parse_err := simplejson.NewJson([]byte(response))
|
sjson, parseErr := simplejson.NewJson([]byte(response))
|
||||||
|
|
||||||
if parse_err != nil {
|
if parseErr != nil {
|
||||||
log.Println(parse_err)
|
log.Println(parseErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +183,6 @@ func postData(url string, content url.Values) (string, error) {
|
|||||||
req.Header.Set("User-Agent", fmt.Sprintf("GoDNS/0.1 (%s)", configuration.Email))
|
req.Header.Set("User-Agent", fmt.Sprintf("GoDNS/0.1 (%s)", configuration.Email))
|
||||||
|
|
||||||
response, err := client.Do(req)
|
response, err := client.Do(req)
|
||||||
defer response.Body.Close()
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Post failed...")
|
log.Println("Post failed...")
|
||||||
@ -191,6 +190,7 @@ func postData(url string, content url.Values) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer response.Body.Close()
|
||||||
resp, _ := ioutil.ReadAll(response.Body)
|
resp, _ := ioutil.ReadAll(response.Body)
|
||||||
|
|
||||||
return string(resp), nil
|
return string(resp), nil
|
||||||
|
@ -20,9 +20,10 @@ type Settings struct {
|
|||||||
Group int
|
Group int
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadSettings(config_path string) (Settings, error) {
|
//LoadSettings from config file
|
||||||
|
func LoadSettings(configPath string) (Settings, error) {
|
||||||
setting := Settings{}
|
setting := Settings{}
|
||||||
file, err := ioutil.ReadFile(config_path)
|
file, err := ioutil.ReadFile(configPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error occurs while reading config file, please make sure config file exists!")
|
fmt.Println("Error occurs while reading config file, please make sure config file exists!")
|
||||||
return setting, err
|
return setting, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user