Add a proxy pool with rotation, liveness checks and a management page
The parser will need to move between proxies, so this adds the module it will sit on: pluggable sources, a pool that hands proxies out and learns from the outcome, three rotation strategies, and a page to drive it. Sources are IProxySource implementations. The public proxifly/free-proxy-list feed is fetched as the combined all/data.json through jsDelivr and filtered locally — one conditional request beats four per-protocol ones that can disagree mid-publish — and cached for the five minutes upstream takes to regenerate. A feed that is down keeps serving its last payload rather than emptying the pool. The user's own list lives in proxies.custom.json beside the settings, takes a pasted blob, and names the lines it could not parse instead of quietly dropping them. Both knobs the pool exposes are settings, as asked: rotation is Sticky (default, the only one that keeps site sessions coherent), RoundRobin or WeightedRandom; liveness is either a parallel sweep of the whole pool or a probe at hand-out time. Free lists are a few percent alive, so skipping verification entirely means mostly waiting on timeouts. Two invariants worth keeping, both of which cost a bug to find: Availability is decided by the quarantine, never by Health. Excluding everything that has ever failed made the quarantine window dead code and discarded proxies permanently on their first hiccup, which is exactly wrong for addresses that flap constantly. Health only orders the candidates now. A probe verdict does not touch the success/failure counters. Those are about real requests, and letting a sweep over a few thousand proxies rewrite them would drown the evidence weighted selection reads. SOCKS needs no extra package — .NET resolves socks4/socks4a/socks5 in WebProxy — but a proxifly record with "protocol": "https" is still an HTTP proxy reached over http:// with CONNECT, not an https:// scheme. 115 new tests. Also fixes a pre-existing flake: a command gated on another command's IsExecuting cannot be driven straight after its Execute() completes, because IsExecuting is published on the output scheduler. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
aeafe0af36
commit
9bf2ea5532
@@ -84,6 +84,29 @@ dotnet csharpier check .
|
||||
выбор конструктора контейнером зависит от порядка регистраций.
|
||||
- `[Reactive]` из `ReactiveUI.SourceGenerators` на partial-свойствах; класс — `partial`.
|
||||
|
||||
## Добавить источник прокси
|
||||
|
||||
1. Реализовать `IProxySource` (или `IMutableProxySource`, если список редактируемый).
|
||||
2. Зарегистрировать как `IProxySource` в `AddAvParserProxies()`. Порядок регистрации = порядок
|
||||
слияния; свой список идёт последним, чтобы пользовательский адрес перебивал фидовый.
|
||||
|
||||
`ProxyPool` при обновлении **переиспользует существующие `ProxyEntry`** по `Endpoint.Key` — иначе
|
||||
перезагрузка списка стирала бы всю накопленную статистику, а публичные фиды переиздаются каждые
|
||||
несколько минут.
|
||||
|
||||
## Инварианты прокси-пула
|
||||
|
||||
- **Доступность определяется карантином, а не `Health`.** `Health` — это «что видели в последний
|
||||
раз». Если исключать всё, что когда-либо падало, окно карантина становится бессмысленным, а
|
||||
прокси теряется навсегда после первой же осечки. Это уже был баг, его ловит
|
||||
`A_failing_proxy_is_quarantined_and_comes_back_later`.
|
||||
- **Проба не трогает `SuccessCount`/`FailureCount`.** Эти счётчики про реальные запросы; свип по
|
||||
паре тысяч прокси перезаписал бы всё, на чём держится взвешенный выбор. Провалившаяся проба
|
||||
выставляет карантин через `RecordProbe(..., quarantineOnFailure:)`.
|
||||
- **Лиза без вердикта нейтральна.** Отменённая операция — не вина прокси; считать это отказом
|
||||
значит карантинить здоровые прокси на каждый Cancel.
|
||||
- **`Select` и `Next` — зарезервированные слова для CA1716.** Метод стратегии называется `Pick`.
|
||||
|
||||
## Грабли, уже оплаченные
|
||||
|
||||
- **Селектор типа в Avalonia матчит точный тип.** `UserControl.shell` не матчит `ShellView`
|
||||
@@ -110,6 +133,11 @@ dotnet csharpier check .
|
||||
резолвиться, даже если эту конфигурацию никто не собирает. Так тут проехал мёртвый
|
||||
`Avalonia.Diagnostics` (его нет под Avalonia 12): `dotnet build -c Release` работал,
|
||||
а голый `dotnet restore` падал.
|
||||
- **`Execute()` завершился ≠ `IsExecuting` уже false.** Второе публикуется на выходном
|
||||
планировщике. Тест, который сразу после `await` дёргает команду, закрытую по чужому
|
||||
`IsExecuting`, будет мигать под нагрузкой — ждите `CanExecute`, а не предполагайте.
|
||||
- **Проект VM-тестов не параллелится.** `ReactiveUiBootstrap` ставит глобальные планировщики
|
||||
ReactiveUI, то есть тесты делят изменяемое состояние независимо от их желания.
|
||||
- **Инспектора в Avalonia 12 нет из коробки.** `Avalonia.Diagnostics` закончился на 11.3.x;
|
||||
DevTools живут отдельно (`AvaloniaUI.DiagnosticsSupport` + `.WithDeveloperTools()`), со своей
|
||||
установкой. Зависимость намеренно не добавлена.
|
||||
|
||||
Reference in New Issue
Block a user