1
0
mirror of https://github.com/taigrr/godns synced 2025-01-18 04:03:25 -08:00

for V1.5.3

This commit is contained in:
TimothyYe 2018-09-04 11:30:59 +08:00
parent 6daac3746c
commit a500ad329f
5 changed files with 6 additions and 9 deletions

1
.gitignore vendored
View File

@ -29,6 +29,7 @@ config.json
*.swp
*.gz
cmd/godns/godns
cmd/godns/config.json
/.idea
/godns.iml

View File

@ -1,6 +1,5 @@
{
"provider": "DNSPod",
"email": "example@gmail.com",
"password": "",
"login_token": "",
"domains": [

View File

@ -88,10 +88,8 @@ func (handler *DNSPodHandler) GenerateHeader(content url.Values) url.Values {
header := url.Values{}
if handler.Configuration.LoginToken != "" {
header.Add("login_token", handler.Configuration.LoginToken)
} else {
header.Add("login_email", handler.Configuration.Email)
header.Add("login_password", handler.Configuration.Password)
}
header.Add("format", "json")
header.Add("lang", "en")
header.Add("error_on_empty", "no")
@ -253,7 +251,7 @@ func (handler *DNSPodHandler) PostData(url string, content url.Values) (string,
req, _ := http.NewRequest("POST", "https://dnsapi.cn"+url, strings.NewReader(values.Encode()))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("User-Agent", fmt.Sprintf("GoDNS/0.1 (%s)", handler.Configuration.Email))
req.Header.Set("User-Agent", fmt.Sprintf("GoDNS/0.1 (%s)", ""))
response, err := client.Do(req)

View File

@ -25,7 +25,6 @@ type Notify struct {
// Settings struct
type Settings struct {
Provider string `json:"provider"`
Email string `json:"email"`
Password string `json:"password"`
LoginToken string `json:"login_token"`
Domains []Domain `json:"domains"`

View File

@ -74,8 +74,8 @@ func GetCurrentIP(configuration *Settings) (string, error) {
// CheckSettings check the format of settings
func CheckSettings(config *Settings) error {
if config.Provider == DNSPOD {
if (config.Email == "" || config.Password == "") && config.LoginToken == "" {
return errors.New("email/password or login token cannot be empty")
if config.Password == "" && config.LoginToken == "" {
return errors.New("password or login token cannot be empty")
}
} else if config.Provider == HE {
if config.Password == "" {