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:
parent
6daac3746c
commit
a500ad329f
1
.gitignore
vendored
1
.gitignore
vendored
@ -29,6 +29,7 @@ config.json
|
|||||||
*.swp
|
*.swp
|
||||||
*.gz
|
*.gz
|
||||||
cmd/godns/godns
|
cmd/godns/godns
|
||||||
|
cmd/godns/config.json
|
||||||
|
|
||||||
/.idea
|
/.idea
|
||||||
/godns.iml
|
/godns.iml
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"provider": "DNSPod",
|
"provider": "DNSPod",
|
||||||
"email": "example@gmail.com",
|
|
||||||
"password": "",
|
"password": "",
|
||||||
"login_token": "",
|
"login_token": "",
|
||||||
"domains": [
|
"domains": [
|
||||||
@ -29,4 +28,4 @@
|
|||||||
"smtp_port": 25,
|
"smtp_port": 25,
|
||||||
"send_to": ""
|
"send_to": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,10 +88,8 @@ func (handler *DNSPodHandler) GenerateHeader(content url.Values) url.Values {
|
|||||||
header := url.Values{}
|
header := url.Values{}
|
||||||
if handler.Configuration.LoginToken != "" {
|
if handler.Configuration.LoginToken != "" {
|
||||||
header.Add("login_token", 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("format", "json")
|
||||||
header.Add("lang", "en")
|
header.Add("lang", "en")
|
||||||
header.Add("error_on_empty", "no")
|
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, _ := http.NewRequest("POST", "https://dnsapi.cn"+url, strings.NewReader(values.Encode()))
|
||||||
|
|
||||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
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)
|
response, err := client.Do(req)
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ type Notify struct {
|
|||||||
// Settings struct
|
// Settings struct
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
Provider string `json:"provider"`
|
Provider string `json:"provider"`
|
||||||
Email string `json:"email"`
|
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
LoginToken string `json:"login_token"`
|
LoginToken string `json:"login_token"`
|
||||||
Domains []Domain `json:"domains"`
|
Domains []Domain `json:"domains"`
|
||||||
|
4
utils.go
4
utils.go
@ -74,8 +74,8 @@ func GetCurrentIP(configuration *Settings) (string, error) {
|
|||||||
// CheckSettings check the format of settings
|
// CheckSettings check the format of settings
|
||||||
func CheckSettings(config *Settings) error {
|
func CheckSettings(config *Settings) error {
|
||||||
if config.Provider == DNSPOD {
|
if config.Provider == DNSPOD {
|
||||||
if (config.Email == "" || config.Password == "") && config.LoginToken == "" {
|
if config.Password == "" && config.LoginToken == "" {
|
||||||
return errors.New("email/password or login token cannot be empty")
|
return errors.New("password or login token cannot be empty")
|
||||||
}
|
}
|
||||||
} else if config.Provider == HE {
|
} else if config.Provider == HE {
|
||||||
if config.Password == "" {
|
if config.Password == "" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user