修复向导Web域名未解析公网IP时自动回退为邮件服务器公网IP并升级版本至V2.10.6
Some checks are pending
Security Checks / security (push) Waiting to run

This commit is contained in:
smail 2026-10-17 11:11:07 +08:00
parent 80d90ee85f
commit 8fc449d42d
4 changed files with 25 additions and 5 deletions

View File

@ -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",

View File

@ -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" {

View File

@ -71,7 +71,7 @@ func TestSMTPDeliveryUsesReferenceHTMLTemplate(t *testing.T) {
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">",
"<h1>邮箱验证码</h1>",
"<p>&lt;xuans&gt;,您好:</p>",
"<p class=\"code\">123456</p>",
">123456</p>",
"<strong>7</strong> 分钟",
"本邮件由 Smail 发送",
} {

View File

@ -57,7 +57,7 @@
<el-icon><Setting /></el-icon>
<span class="settings-label">{{ lang.settings }}</span>
</div>
<span class="app-version-badge">V2.10.5</span>
<span class="app-version-badge">V2.10.6</span>
</button>
</div>
</div>