1、优化初始化设置时的操作说明
2、发件人和发件时间修复
3、发件空指针异常修复
This commit is contained in:
jinnrry committed 2024-04-27 12:51:59 +08:00
1 parent 89c24884f2
commit 7a3d056e77
10 files changed
+124 -59

No files matched your search

+3 -24
View File
@@ -1,14 +1,12 @@
package setup
import (
"encoding/json"
"fmt"
"io"
"net/http"
"pmail/i18n"
"pmail/services/auth"
"pmail/utils/context"
"pmail/utils/errors"
"pmail/utils/ip"
)
type DNSItem struct {
@@ -26,30 +24,11 @@ func GetDNSSettings(ctx *context.Context) ([]*DNSItem, error) {
}
ret := []*DNSItem{
{Type: "A", Host: "smtp", Value: getIp(), TTL: 3600, Tips: i18n.GetText(ctx.Lang, "ip_taps")},
{Type: "A", Host: "pop", Value: getIp(), TTL: 3600, Tips: i18n.GetText(ctx.Lang, "ip_taps")},
{Type: "A", Host: "smtp", Value: ip.GetIp(), TTL: 3600, Tips: i18n.GetText(ctx.Lang, "ip_taps")},
{Type: "A", Host: "pop", Value: ip.GetIp(), TTL: 3600, Tips: i18n.GetText(ctx.Lang, "ip_taps")},
{Type: "MX", Host: "-", Value: fmt.Sprintf("smtp.%s", configData.Domain), TTL: 3600},
{Type: "TXT", Host: "-", Value: "v=spf1 a mx ~all", TTL: 3600},
{Type: "TXT", Host: "default._domainkey", Value: auth.DkimGen(), TTL: 3600},
}
return ret, nil
}
func getIp() string {
resp, err := http.Get("http://ip-api.com/json/?lang=zh-CN ")
if err != nil {
return "Your Server IP"
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
body, err := io.ReadAll(resp.Body)
if err == nil {
var queryRes map[string]string
_ = json.Unmarshal(body, &queryRes)
return queryRes["query"]
}
}
return "Your Server IP"
}