refactor: удалить поддержку Yandex Telemost и мёртвый код
Удаляет флаг -yandex-link, getYandexCreds и ветку Telemost из основного потока клиента. Убрана зависимость gorilla/websocket. Вычищен мёртвый код, всплывший после удаления: - browserprofile.ApplyHTTP / Random / profileList - dnsdial DohResolver.LookupIPAddr / queryIPs / parseAnswer / dohCache и их тесты (единственный production-вызыватель — путь forwarder) - устаревшая строка -captcha-solver в README Публичные DoH-эндпоинты Yandex оставлены (RU-дружественный fallback, не связан с Telemost).
This commit is contained in:
1 parent
ac3a6031d0
commit
ead97d0089
7 files changed
+14
-677
No files matched your search
@@ -6,7 +6,6 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -59,101 +58,6 @@ func readWire(t *testing.T, r io.Reader) []byte {
|
||||
return b
|
||||
}
|
||||
|
||||
func TestDohResolver_LookupIPAddr_Success(t *testing.T) {
|
||||
var hits atomic.Int32
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
hits.Add(1)
|
||||
if ct := r.Header.Get("Content-Type"); ct != "application/dns-message" {
|
||||
t.Errorf("wrong Content-Type: %q", ct)
|
||||
}
|
||||
body := readWire(t, r.Body)
|
||||
w.Header().Set("Content-Type", "application/dns-message")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, _ = w.Write(dohAnswer(t, body, net.ParseIP("93.184.216.34"), 300)) //nolint:errcheck
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
r := newDohResolverWithClient(
|
||||
[]DohEndpoint{{URL: srv.URL, Hostname: "mock", BootstrapIPs: []string{"127.0.0.1"}}},
|
||||
srv.Client(),
|
||||
)
|
||||
|
||||
ips, err := r.LookupIPAddr(context.Background(), "example.com")
|
||||
if err != nil {
|
||||
t.Fatalf("lookup: %v", err)
|
||||
}
|
||||
if len(ips) == 0 {
|
||||
t.Fatalf("no ips returned")
|
||||
}
|
||||
if ips[0].String() != "93.184.216.34" {
|
||||
t.Fatalf("unexpected ip %s", ips[0])
|
||||
}
|
||||
// Two concurrent queries fire (A + AAAA), so we expect 2 hits.
|
||||
if got := hits.Load(); got != 2 {
|
||||
t.Fatalf("expected 2 HTTP hits, got %d", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDohResolver_Fallback(t *testing.T) {
|
||||
var firstHits, secondHits atomic.Int32
|
||||
first := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
firstHits.Add(1)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
}))
|
||||
defer first.Close()
|
||||
second := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
secondHits.Add(1)
|
||||
body := readWire(t, r.Body)
|
||||
w.Header().Set("Content-Type", "application/dns-message")
|
||||
_, _ = w.Write(dohAnswer(t, body, net.ParseIP("1.2.3.4"), 300)) //nolint:errcheck
|
||||
}))
|
||||
defer second.Close()
|
||||
|
||||
r := newDohResolverWithClient(
|
||||
[]DohEndpoint{
|
||||
{URL: first.URL, Hostname: "first", BootstrapIPs: []string{"127.0.0.1"}},
|
||||
{URL: second.URL, Hostname: "second", BootstrapIPs: []string{"127.0.0.1"}},
|
||||
},
|
||||
first.Client(),
|
||||
)
|
||||
ips, err := r.LookupIPAddr(context.Background(), "example.com")
|
||||
if err != nil {
|
||||
t.Fatalf("lookup: %v", err)
|
||||
}
|
||||
if len(ips) != 1 || ips[0].String() != "1.2.3.4" {
|
||||
t.Fatalf("unexpected ips: %v", ips)
|
||||
}
|
||||
if firstHits.Load() == 0 || secondHits.Load() == 0 {
|
||||
t.Fatalf("fallback did not probe both endpoints: first=%d second=%d", firstHits.Load(), secondHits.Load())
|
||||
}
|
||||
}
|
||||
|
||||
func TestDohResolver_Cache(t *testing.T) {
|
||||
var hits atomic.Int32
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
hits.Add(1)
|
||||
body := readWire(t, r.Body)
|
||||
w.Header().Set("Content-Type", "application/dns-message")
|
||||
_, _ = w.Write(dohAnswer(t, body, net.ParseIP("5.6.7.8"), 300)) //nolint:errcheck
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
r := newDohResolverWithClient(
|
||||
[]DohEndpoint{{URL: srv.URL, Hostname: "mock", BootstrapIPs: []string{"127.0.0.1"}}},
|
||||
srv.Client(),
|
||||
)
|
||||
if _, err := r.LookupIPAddr(context.Background(), "example.com"); err != nil {
|
||||
t.Fatalf("first lookup: %v", err)
|
||||
}
|
||||
firstHits := hits.Load()
|
||||
if _, err := r.LookupIPAddr(context.Background(), "example.com"); err != nil {
|
||||
t.Fatalf("second lookup: %v", err)
|
||||
}
|
||||
if hits.Load() != firstHits {
|
||||
t.Fatalf("cache miss: expected %d HTTP hits, got %d", firstHits, hits.Load())
|
||||
}
|
||||
}
|
||||
|
||||
func TestAutoDial_StickyAfterUDPFailure(t *testing.T) {
|
||||
// DoH backend: always responds with a valid wire-format reply.
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in new issue
Block a user