修复代理环境邮件目标解析
Security Checks / security (push) Waiting to run

This commit is contained in:
xuans committed 2026-09-16 14:27:53 +08:00
1 parent d8867dfc4a
commit 657f4922b4
2 files changed
+100

No files matched your search

+22
View File
@@ -11,6 +11,7 @@ import (
"io"
"math/big"
"net"
"net/netip"
"net/textproto"
"strings"
"testing"
@@ -42,6 +43,27 @@ func TestDialRejectsNonPublicRemoteAddress(t *testing.T) {
}
}
func TestContainsOnlyBenchmarkAddresses(t *testing.T) {
tests := []struct {
name string
addresses []netip.Addr
want bool
}{
{name: "empty", want: false},
{name: "fake IP", addresses: []netip.Addr{netip.MustParseAddr("198.18.1.77")}, want: true},
{name: "multiple fake IPs", addresses: []netip.Addr{netip.MustParseAddr("198.18.1.77"), netip.MustParseAddr("198.19.1.82")}, want: true},
{name: "public IP", addresses: []netip.Addr{netip.MustParseAddr("47.251.242.178")}, want: false},
{name: "mixed", addresses: []netip.Addr{netip.MustParseAddr("198.18.1.77"), netip.MustParseAddr("127.0.0.1")}, want: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := containsOnlyBenchmarkAddresses(tt.addresses); got != tt.want {
t.Fatalf("containsOnlyBenchmarkAddresses() = %v, want %v", got, tt.want)
}
})
}
}
func TestSendMailUnsafeRejectsNonLoopbackTargets(t *testing.T) {
tests := []struct {
name string