diff --git a/config_sample.json b/config_sample.json index 6f63c3f..cbedc6b 100644 --- a/config_sample.json +++ b/config_sample.json @@ -13,5 +13,13 @@ ], "ip_url": "http://members.3322.org/dyndns/getip", "log_path": "./godns.log", - "socks5_proxy": "" + "socks5_proxy": "", + "notify": { + "enabled": false, + "smtp_server": "", + "smtp_username": "", + "smtp_password": "", + "smtp_port": 25, + "send_to": "", + } } diff --git a/handler/dnspod_handler.go b/handler/dnspod_handler.go index 483f11f..cc96816 100644 --- a/handler/dnspod_handler.go +++ b/handler/dnspod_handler.go @@ -76,7 +76,8 @@ func (handler *DNSPodHandler) DomainLoop(domain *godns.Domain, panicChan chan<- // Send mail notification if notify is enabled if handler.Configuration.Notify.Enabled { - godns.SendNotify(handler.Configuration, currentIP) + log.Print("Sending notification to:", handler.Configuration.Notify.SendTo) + godns.SendNotify(handler.Configuration, fmt.Sprintf("%s.%s", subDomain, domain.DomainName), currentIP) } } else { diff --git a/handler/he_handler.go b/handler/he_handler.go index ce31dd1..d11a2ab 100644 --- a/handler/he_handler.go +++ b/handler/he_handler.go @@ -61,7 +61,8 @@ func (handler *HEHandler) DomainLoop(domain *godns.Domain, panicChan chan<- godn // Send mail notification if notify is enabled if handler.Configuration.Notify.Enabled { - godns.SendNotify(handler.Configuration, currentIP) + log.Print("Sending notification to:", handler.Configuration.Notify.SendTo) + godns.SendNotify(handler.Configuration, fmt.Sprintf("%s.%s", subDomain, domain.DomainName), currentIP) } } } diff --git a/settings.go b/settings.go index 0d35613..fd3cf1f 100644 --- a/settings.go +++ b/settings.go @@ -13,12 +13,12 @@ type Domain struct { } type Notify struct { - Enabled bool `json:"enabled"` - SMTPServer string `json:"smtp_server"` - SendTo string `json:"send_to"` - Port int `json:"port"` - Account string `json:"account"` - Password string `json:"password"` + Enabled bool `json:"enabled"` + SMTPServer string `json:"smtp_server"` + SMTPUsername string `json:"smtp_username"` + SMTPPassword string `json:"smtp_password"` + SMTPPort int `json:"smtp_port"` + SendTo string `json:"send_to"` } // Settings struct diff --git a/template.go b/template.go new file mode 100644 index 0000000..aec9221 --- /dev/null +++ b/template.go @@ -0,0 +1,105 @@ +package godns + +var template = ` + +
+