From a500ad329f00826cc95a7e570c79a4beb0f1f8e7 Mon Sep 17 00:00:00 2001 From: TimothyYe Date: Tue, 4 Sep 2018 11:30:59 +0800 Subject: [PATCH] for V1.5.3 --- .gitignore | 1 + config_sample.json | 3 +-- handler/dnspod_handler.go | 6 ++---- settings.go | 1 - utils.go | 4 ++-- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 07f3619..b8bf4d9 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ config.json *.swp *.gz cmd/godns/godns +cmd/godns/config.json /.idea /godns.iml diff --git a/config_sample.json b/config_sample.json index 7553c94..7eb6785 100644 --- a/config_sample.json +++ b/config_sample.json @@ -1,6 +1,5 @@ { "provider": "DNSPod", - "email": "example@gmail.com", "password": "", "login_token": "", "domains": [ @@ -29,4 +28,4 @@ "smtp_port": 25, "send_to": "" } -} \ No newline at end of file +} diff --git a/handler/dnspod_handler.go b/handler/dnspod_handler.go index 06a4381..590a277 100644 --- a/handler/dnspod_handler.go +++ b/handler/dnspod_handler.go @@ -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) diff --git a/settings.go b/settings.go index c287628..bc60de2 100644 --- a/settings.go +++ b/settings.go @@ -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"` diff --git a/utils.go b/utils.go index 7c0ebce..65ea705 100644 --- a/utils.go +++ b/utils.go @@ -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 == "" {