mirror of
				https://github.com/taigrr/godns
				synced 2025-01-18 04:03:25 -08:00 
			
		
		
		
	fix lint warnings
This commit is contained in:
		
							parent
							
								
									7e30cdf6b2
								
							
						
					
					
						commit
						4a3b2216d3
					
				| @ -3,7 +3,8 @@ go: | |||||||
|  - 1.12 |  - 1.12 | ||||||
| 
 | 
 | ||||||
| install: | install: | ||||||
|  - go get -v |  - export GO111MODULE="on" | ||||||
|  |  - go mod download | ||||||
|  - go get -v github.com/smartystreets/goconvey/convey |  - go get -v github.com/smartystreets/goconvey/convey | ||||||
|  - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.15.0 |  - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.15.0 | ||||||
| script: | script: | ||||||
|  | |||||||
| @ -5,6 +5,7 @@ import ( | |||||||
| 	"crypto/sha1" | 	"crypto/sha1" | ||||||
| 	"encoding/base64" | 	"encoding/base64" | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
|  | 	"errors" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" | 	"io/ioutil" | ||||||
| 	"math/rand" | 	"math/rand" | ||||||
| @ -100,7 +101,10 @@ func (d *AliDNS) GetDomainRecords(domain, rr string) []DomainRecord { | |||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		fmt.Printf("GetDomainRecords error.%+v\n", err) | 		fmt.Printf("GetDomainRecords error.%+v\n", err) | ||||||
| 	} else { | 	} else { | ||||||
| 		json.Unmarshal(body, resp) | 		if err := json.Unmarshal(body, resp); err != nil { | ||||||
|  | 			fmt.Printf("GetDomainRecords error. %+v\n", err) | ||||||
|  | 			return nil | ||||||
|  | 		} | ||||||
| 		return resp.DomainRecords.Record | 		return resp.DomainRecords.Record | ||||||
| 	} | 	} | ||||||
| 	return nil | 	return nil | ||||||
| @ -119,6 +123,9 @@ func (d *AliDNS) UpdateDomainRecord(r DomainRecord) error { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	urlPath := d.genRequestURL(parms) | 	urlPath := d.genRequestURL(parms) | ||||||
|  | 	if urlPath == "" { | ||||||
|  | 		return errors.New("Failed to generate request URL") | ||||||
|  | 	} | ||||||
| 	_, err := getHTTPBody(urlPath) | 	_, err := getHTTPBody(urlPath) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		fmt.Printf("UpdateDomainRecord error.%+v\n", err) | 		fmt.Printf("UpdateDomainRecord error.%+v\n", err) | ||||||
| @ -152,7 +159,9 @@ func (d *AliDNS) genRequestURL(parms map[string]string) string { | |||||||
| 	s = strings.Replace(s, "%2A", "%252A", -1) | 	s = strings.Replace(s, "%2A", "%252A", -1) | ||||||
| 	mac := hmac.New(sha1.New, []byte(d.AccessKeySecret+"&")) | 	mac := hmac.New(sha1.New, []byte(d.AccessKeySecret+"&")) | ||||||
| 
 | 
 | ||||||
| 	mac.Write([]byte(s)) | 	if _, err := mac.Write([]byte(s)); err != nil { | ||||||
|  | 		return "" | ||||||
|  | 	} | ||||||
| 	sign := base64.StdEncoding.EncodeToString(mac.Sum(nil)) | 	sign := base64.StdEncoding.EncodeToString(mac.Sum(nil)) | ||||||
| 	return fmt.Sprintf("%s?%s&Signature=%s", baseURL, path, url.QueryEscape(sign)) | 	return fmt.Sprintf("%s?%s&Signature=%s", baseURL, path, url.QueryEscape(sign)) | ||||||
| } | } | ||||||
|  | |||||||
| @ -65,7 +65,9 @@ func (handler *Handler) DomainLoop(domain *godns.Domain, panicChan chan<- godns. | |||||||
| 				// Send mail notification if notify is enabled | 				// Send mail notification if notify is enabled | ||||||
| 				if handler.Configuration.Notify.Enabled { | 				if handler.Configuration.Notify.Enabled { | ||||||
| 					log.Print("Sending notification to:", handler.Configuration.Notify.SendTo) | 					log.Print("Sending notification to:", handler.Configuration.Notify.SendTo) | ||||||
| 					godns.SendNotify(handler.Configuration, fmt.Sprintf("%s.%s", subDomain, domain.DomainName), currentIP) | 					if err := godns.SendNotify(handler.Configuration, fmt.Sprintf("%s.%s", subDomain, domain.DomainName), currentIP); err != nil { | ||||||
|  | 						log.Printf("Failed to send notification") | ||||||
|  | 					} | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  | |||||||
| @ -107,7 +107,9 @@ func (handler *Handler) DomainLoop(domain *godns.Domain, panicChan chan<- godns. | |||||||
| 						// Send mail notification if notify is enabled | 						// Send mail notification if notify is enabled | ||||||
| 						if handler.Configuration.Notify.Enabled { | 						if handler.Configuration.Notify.Enabled { | ||||||
| 							log.Print("Sending notification to:", handler.Configuration.Notify.SendTo) | 							log.Print("Sending notification to:", handler.Configuration.Notify.SendTo) | ||||||
| 							godns.SendNotify(handler.Configuration, rec.Name, currentIP) | 							if err := godns.SendNotify(handler.Configuration, rec.Name, currentIP); err != nil { | ||||||
|  | 								log.Println("Failed to send notification") | ||||||
|  | 							} | ||||||
| 						} | 						} | ||||||
| 					} else { | 					} else { | ||||||
| 						log.Printf("Record OK: %+v - %+v\r\n", rec.Name, rec.IP) | 						log.Printf("Record OK: %+v - %+v\r\n", rec.Name, rec.IP) | ||||||
|  | |||||||
| @ -76,7 +76,9 @@ func (handler *Handler) DomainLoop(domain *godns.Domain, panicChan chan<- godns. | |||||||
| 					// Send mail notification if notify is enabled | 					// Send mail notification if notify is enabled | ||||||
| 					if handler.Configuration.Notify.Enabled { | 					if handler.Configuration.Notify.Enabled { | ||||||
| 						log.Print("Sending notification to:", handler.Configuration.Notify.SendTo) | 						log.Print("Sending notification to:", handler.Configuration.Notify.SendTo) | ||||||
| 						godns.SendNotify(handler.Configuration, fmt.Sprintf("%s.%s", subDomain, domain.DomainName), currentIP) | 						if err := godns.SendNotify(handler.Configuration, fmt.Sprintf("%s.%s", subDomain, domain.DomainName), currentIP); err != nil { | ||||||
|  | 							log.Println("Failed to send notification") | ||||||
|  | 						} | ||||||
| 					} | 					} | ||||||
| 
 | 
 | ||||||
| 				} else { | 				} else { | ||||||
|  | |||||||
| @ -62,7 +62,9 @@ func (handler *Handler) DomainLoop(domain *godns.Domain, panicChan chan<- godns. | |||||||
| 				// Send mail notification if notify is enabled | 				// Send mail notification if notify is enabled | ||||||
| 				if handler.Configuration.Notify.Enabled { | 				if handler.Configuration.Notify.Enabled { | ||||||
| 					log.Print("Sending notification to:", handler.Configuration.Notify.SendTo) | 					log.Print("Sending notification to:", handler.Configuration.Notify.SendTo) | ||||||
| 					godns.SendNotify(handler.Configuration, fmt.Sprintf("%s.%s", subDomain, domain.DomainName), currentIP) | 					if err := godns.SendNotify(handler.Configuration, fmt.Sprintf("%s.%s", subDomain, domain.DomainName), currentIP); err != nil { | ||||||
|  | 						log.Println("Failed to send notificaiton") | ||||||
|  | 					} | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  | |||||||
							
								
								
									
										5
									
								
								utils.go
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								utils.go
									
									
									
									
									
								
							| @ -217,7 +217,10 @@ func SendNotify(configuration *Settings, domain, currentIP string) error { | |||||||
| 
 | 
 | ||||||
| func buildTemplate(currentIP, domain string) string { | func buildTemplate(currentIP, domain string) string { | ||||||
| 	t := template.New("notification template") | 	t := template.New("notification template") | ||||||
| 	t.Parse(mailTemplate) | 	if _, err := t.Parse(mailTemplate); err != nil { | ||||||
|  | 		log.Println("Failed to parse template") | ||||||
|  | 		return "" | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	data := struct { | 	data := struct { | ||||||
| 		CurrentIP string | 		CurrentIP string | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user