refactor: вынести солвер captcha в internal/captcha
Вытаскивает auto-captcha пайплайн из client/main и даёт ему узкий публичный интерфейс, чтобы main.go больше не держал ~1.2k строк обработки VK-челленджей. Новые пакеты под client/internal/: - browserprofile: типы Profile / Saved плюс Load / Save / Random и инжекторы заголовков ApplyHTTP / ApplyFhttp (перенесены из profiles.go + main.go). manual_captcha.go тоже переключён на него. - captcha: package-level entrypoint Solve(ctx, *Error, ...), плюс Error / ParseError / IsCaptcha (переименованы из VkCaptchaError / ParseVkCaptchaError / IsCaptchaError). Сессия, scoring слайдера, синтез курсора и PoW теперь неэкспортируемая деталь реализации. solveVkCaptcha в main.go сжимается до обёртки над captcha.Solve с загрузкой SavedProfile.
This commit is contained in:
1 parent
130d5e9298
commit
ac3a6031d0
6 files changed
+172
-169
No files matched your search
@@ -18,6 +18,8 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/cacggghp/vk-turn-proxy/client/internal/browserprofile"
|
||||
)
|
||||
|
||||
const captchaListenPort = "8765"
|
||||
@@ -626,8 +628,8 @@ func (t *loggingTransport) RoundTrip(req *http.Request) (*http.Response, error)
|
||||
|
||||
// We only save it if device is present. componentDone usually has it.
|
||||
if device != "" && browserFp != "" {
|
||||
sp := SavedProfile{
|
||||
Profile: Profile{
|
||||
sp := browserprofile.Saved{
|
||||
Profile: browserprofile.Profile{
|
||||
UserAgent: req.Header.Get("User-Agent"),
|
||||
SecChUa: req.Header.Get("Sec-Ch-Ua"),
|
||||
SecChUaMobile: req.Header.Get("Sec-Ch-Ua-Mobile"),
|
||||
@@ -636,7 +638,7 @@ func (t *loggingTransport) RoundTrip(req *http.Request) (*http.Response, error)
|
||||
DeviceJSON: device,
|
||||
BrowserFp: browserFp,
|
||||
}
|
||||
if err := SaveProfileToDisk(sp); err != nil {
|
||||
if err := browserprofile.Save(sp); err != nil {
|
||||
log.Printf("[Captcha Proxy] Failed to save browser profile: %v", err)
|
||||
} else {
|
||||
log.Printf("[Captcha Proxy] Successfully intercepted and saved real browser profile!")
|
||||
|
||||
Reference in new issue
Block a user