This commit is contained in:
1 parent
80d90ee85f
commit
8fc449d42d
4 files changed
+25
-5
No files matched your search
@@ -121,6 +121,14 @@ func buildDNSItemsWithWebIPv4(configData *config.Config, domain, dkimPublicKey,
|
||||
Tips: ipTips,
|
||||
})
|
||||
}
|
||||
} else if address != "" {
|
||||
items = append(items, &DNSItem{
|
||||
Type: "A",
|
||||
Host: webHost,
|
||||
Value: address,
|
||||
TTL: dnsRecordTTL,
|
||||
Tips: "Web 域名尚未解析,已推荐使用邮件服务器公网 IPv4",
|
||||
})
|
||||
} else {
|
||||
items = append(items, &DNSItem{
|
||||
Type: "A",
|
||||
|
||||
@@ -94,21 +94,33 @@ func TestBuildDNSItemsCreatesExpectedRecordShape(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildDNSItemsDoesNotReuseMailIPForUnresolvedWebDomain(t *testing.T) {
|
||||
func TestBuildDNSItemsReusesMailIPForUnresolvedWebDomain(t *testing.T) {
|
||||
cfg := &config.Config{
|
||||
Domain: "example.net",
|
||||
WebDomain: "panel.example.net",
|
||||
}
|
||||
items := buildDNSItemsWithWebIPv4(cfg, "example.net", "v=DKIM1; k=rsa; p=test", "198.51.100.30", "", "", nil)
|
||||
|
||||
if items[0].Host != "panel" || items[0].Value != "" || items[0].UnavailableReason != unresolvedWebIPv4 {
|
||||
t.Fatalf("unresolved web A record = %#v", items[0])
|
||||
if items[0].Host != "panel" || items[0].Value != "198.51.100.30" || items[0].UnavailableReason != "" {
|
||||
t.Fatalf("unresolved web A record should fall back to mail public ip: %#v", items[0])
|
||||
}
|
||||
if items[1].Host != "smtp" || items[1].Value != "198.51.100.30" {
|
||||
t.Fatalf("mail A record = %#v", items[1])
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildDNSItemsWithoutAnyIPMarksUnresolvedWebDomain(t *testing.T) {
|
||||
cfg := &config.Config{
|
||||
Domain: "example.net",
|
||||
WebDomain: "panel.example.net",
|
||||
}
|
||||
items := buildDNSItemsWithWebIPv4(cfg, "example.net", "v=DKIM1; k=rsa; p=test", "", "", "", nil)
|
||||
|
||||
if items[0].Host != "panel" || items[0].Value != "" || items[0].UnavailableReason != unresolvedWebIPv4 {
|
||||
t.Fatalf("unresolved web A record without public ip = %#v", items[0])
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolvePublicIPv4UsesActualLookupResults(t *testing.T) {
|
||||
lookup := func(ctx stdcontext.Context, host string) ([]net.IP, error) {
|
||||
if host != "panel.example.org" {
|
||||
|
||||
@@ -71,7 +71,7 @@ func TestSMTPDeliveryUsesReferenceHTMLTemplate(t *testing.T) {
|
||||
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">",
|
||||
"<h1>邮箱验证码</h1>",
|
||||
"<p><xuans>,您好:</p>",
|
||||
"<p class=\"code\">123456</p>",
|
||||
">123456</p>",
|
||||
"<strong>7</strong> 分钟",
|
||||
"本邮件由 Smail 发送",
|
||||
} {
|
||||
|
||||
Reference in new issue
Block a user