@@ -852,10 +852,8 @@ func TestProxy_ReplyFromUpstream_badResponse(t *testing.T) {
852852 0 ,
853853 false ,
854854 ),
855- Req : createHostTestMessage ("host" ),
856- Addr : & net.TCPAddr {
857- IP : net.IP {1 , 2 , 3 , 0 },
858- },
855+ Req : createHostTestMessage ("host" ),
856+ Addr : netip .MustParseAddrPort ("1.2.3.0:1234" ),
859857 }
860858
861859 var err error
@@ -893,7 +891,7 @@ func TestExchangeCustomUpstreamConfig(t *testing.T) {
893891 false ,
894892 ),
895893 Req : createHostTestMessage ("host" ),
896- Addr : & net. TCPAddr { IP : net. IP { 1 , 2 , 3 , 0 }} ,
894+ Addr : netip . MustParseAddrPort ( "1.2.3.0:1234" ) ,
897895 }
898896
899897 err = prx .Resolve (& d )
@@ -945,7 +943,7 @@ func TestExchangeCustomUpstreamConfigCache(t *testing.T) {
945943 d := DNSContext {
946944 CustomUpstreamConfig : customUpstreamConfig ,
947945 Req : createHostTestMessage ("host" ),
948- Addr : & net. TCPAddr { IP : net. IP { 1 , 2 , 3 , 0 }} ,
946+ Addr : netip . MustParseAddrPort ( "1.2.3.0:1234" ) ,
949947 }
950948
951949 err = prx .Resolve (& d )
@@ -1036,7 +1034,7 @@ func TestECSProxy(t *testing.T) {
10361034 t .Run ("cache_subnet" , func (t * testing.T ) {
10371035 d := DNSContext {
10381036 Req : createHostTestMessage ("host" ),
1039- Addr : & net. TCPAddr { IP : ip1230 } ,
1037+ Addr : netip . MustParseAddrPort ( "1.2.3.0:1234" ) ,
10401038 }
10411039
10421040 err = prx .Resolve (& d )
@@ -1049,7 +1047,7 @@ func TestECSProxy(t *testing.T) {
10491047 t .Run ("serve_subnet_cache" , func (t * testing.T ) {
10501048 d := DNSContext {
10511049 Req : createHostTestMessage ("host" ),
1052- Addr : & net. TCPAddr { IP : net. IP { 1 , 2 , 3 , 1 }} ,
1050+ Addr : netip . MustParseAddrPort ( "1.2.3.1:1234" ) ,
10531051 }
10541052 u .ans , u .ecsIP , u .ecsReqIP = nil , nil , nil
10551053
@@ -1063,7 +1061,7 @@ func TestECSProxy(t *testing.T) {
10631061 t .Run ("another_subnet" , func (t * testing.T ) {
10641062 d := DNSContext {
10651063 Req : createHostTestMessage ("host" ),
1066- Addr : & net. TCPAddr { IP : ip2230 } ,
1064+ Addr : netip . MustParseAddrPort ( "2.2.3.0:1234" ) ,
10671065 }
10681066 u .ans = []dns.RR {& dns.A {
10691067 Hdr : dns.RR_Header {Rrtype : dns .TypeA , Name : "host." , Ttl : 60 },
@@ -1081,7 +1079,7 @@ func TestECSProxy(t *testing.T) {
10811079 t .Run ("cache_general" , func (t * testing.T ) {
10821080 d := DNSContext {
10831081 Req : createHostTestMessage ("host" ),
1084- Addr : & net. TCPAddr { IP : net. IP { 127 , 0 , 0 , 1 }} ,
1082+ Addr : netip . MustParseAddrPort ( " 127.0.0.1:1234" ) ,
10851083 }
10861084 u .ans = []dns.RR {& dns.A {
10871085 Hdr : dns.RR_Header {Rrtype : dns .TypeA , Name : "host." , Ttl : 60 },
@@ -1099,7 +1097,7 @@ func TestECSProxy(t *testing.T) {
10991097 t .Run ("serve_general_cache" , func (t * testing.T ) {
11001098 d := DNSContext {
11011099 Req : createHostTestMessage ("host" ),
1102- Addr : & net. TCPAddr { IP : net. IP { 127 , 0 , 0 , 2 }} ,
1100+ Addr : netip . MustParseAddrPort ( " 127.0.0.2:1234" ) ,
11031101 }
11041102 u .ans , u .ecsIP , u .ecsReqIP = nil , nil , nil
11051103
@@ -1138,7 +1136,7 @@ func TestECSProxyCacheMinMaxTTL(t *testing.T) {
11381136 // first request
11391137 d := DNSContext {
11401138 Req : createHostTestMessage ("host" ),
1141- Addr : & net. TCPAddr { IP : clientIP } ,
1139+ Addr : netip . MustParseAddrPort ( "1.2.3.0:1234" ) ,
11421140 }
11431141 err = prx .Resolve (& d )
11441142 require .NoError (t , err )
@@ -1156,9 +1154,7 @@ func TestECSProxyCacheMinMaxTTL(t *testing.T) {
11561154 // 2nd request
11571155 clientIP = net.IP {1 , 2 , 4 , 0 }
11581156 d .Req = createHostTestMessage ("host" )
1159- d .Addr = & net.TCPAddr {
1160- IP : clientIP ,
1161- }
1157+ d .Addr = netip .MustParseAddrPort ("1.2.4.0:1234" )
11621158 u .ans = []dns.RR {& dns.A {
11631159 Hdr : dns.RR_Header {
11641160 Rrtype : dns .TypeA ,
@@ -1242,8 +1238,8 @@ func createTestProxy(t *testing.T, tlsConfig *tls.Config) *Proxy {
12421238
12431239 p .TrustedProxies = []string {"0.0.0.0/0" , "::0/0" }
12441240
1245- p .RatelimitSubnetMaskIPv4 = net . CIDRMask ( 24 , 32 )
1246- p .RatelimitSubnetMaskIPv6 = net . CIDRMask ( 64 , 128 )
1241+ p .RatelimitSubnetLenIPv4 = 24
1242+ p .RatelimitSubnetLenIPv6 = 64
12471243
12481244 return & p
12491245}
0 commit comments