MCPcopy
hub / github.com/AdguardTeam/dnsproxy / TestExchangeCustomUpstreamConfig

Function TestExchangeCustomUpstreamConfig

proxy/proxy_internal_test.go:939–969  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

937}
938
939func TestExchangeCustomUpstreamConfig(t *testing.T) {
940 prx := mustStartDefaultProxy(t)
941
942 ansIP := net.IP{4, 3, 2, 1}
943 u := &testUpstream{
944 ans: []dns.RR{&dns.A{
945 Hdr: dns.RR_Header{
946 Rrtype: dns.TypeA,
947 Name: "host.",
948 Ttl: 60,
949 },
950 A: ansIP,
951 }},
952 }
953
954 d := &DNSContext{
955 CustomUpstreamConfig: NewCustomUpstreamConfig(
956 &UpstreamConfig{Upstreams: []upstream.Upstream{u}},
957 false,
958 0,
959 false,
960 ),
961 Req: newHostTestMessage("host"),
962 Addr: netip.MustParseAddrPort("1.2.3.0:1234"),
963 }
964
965 err := prx.Resolve(testutil.ContextWithTimeout(t, defaultTimeout), d)
966 require.NoError(t, err)
967
968 assert.Equal(t, ansIP, firstIP(d.Res))
969}
970
971func TestExchangeCustomUpstreamConfigCache(t *testing.T) {
972 prx := mustNew(t, &Config{

Callers

nothing calls this directly

Calls 5

mustStartDefaultProxyFunction · 0.85
NewCustomUpstreamConfigFunction · 0.85
newHostTestMessageFunction · 0.85
firstIPFunction · 0.85
ResolveMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…