internal/client/captcha, captcha/manual, dnsdial: добавить package-level Log +
SetLogger; убрать прямой обход -debug через stdlib log.Printf. cmd/{client,
server}/main.go: сначала строить logger, весь вывод через logger.{Info,Warn,
Error}f; оставлен один log.Fatalf только для сбоя разбора конфига до логгера.
dnsdial: log.Panicf → panic(fmt.Sprintf).
Исправлены уровни:
- vkauth/token.go: пути [FATAL] теперь Errorf; Auto/Manual captcha failed →
Warnf; ignored-cleanup-error → Debugf.
- vkauth/client.go: HandleAuthError/cache invalidated → Warnf; throttle wait →
Debugf; Failed-with-client_id → Warnf.
- udprelay: "Backing off 60s" + SetDeadline failed → Warnf.
- captcha: PoW/show_type/check status/debug_info → Debugf; endSession/close-body/
script-drift → Warnf.
Префиксы нормализованы к [STREAM %d] [Pkg] msg / [Pkg] msg.
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package vkauth
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/cacggghp/vk-turn-proxy/internal/client/browserprofile"
|
|
"github.com/cacggghp/vk-turn-proxy/internal/client/captcha"
|
|
|
|
tlsclient "github.com/bogdanfinn/tls-client"
|
|
)
|
|
|
|
// DefaultAutoSolve drives the in-page widget flow. It loads a saved real
|
|
// browser profile when available so the captcha origin sees consistent
|
|
// fingerprints across the page load and the solve POST.
|
|
func DefaultAutoSolve(
|
|
ctx context.Context,
|
|
captchaErr *captcha.Error,
|
|
streamID int,
|
|
client tlsclient.HttpClient,
|
|
profile browserprofile.Profile,
|
|
) (string, error) {
|
|
captcha.Log.Infof("[STREAM %d] [Captcha] Solving captcha...", streamID)
|
|
|
|
if captchaErr.SessionToken == "" {
|
|
return "", fmt.Errorf("no session_token in redirect_uri for auto-solve")
|
|
}
|
|
if captchaErr.RedirectURI == "" {
|
|
return "", fmt.Errorf("no redirect_uri for auto-solve")
|
|
}
|
|
|
|
var savedProfile *browserprofile.Saved
|
|
if sp, err := browserprofile.Load(); err == nil {
|
|
captcha.Log.Infof("[STREAM %d] [Captcha] Using saved real browser profile", streamID)
|
|
savedProfile = sp
|
|
profile = sp.Profile
|
|
}
|
|
|
|
successToken, err := captcha.Solve(ctx, captchaErr, streamID, client, profile, savedProfile)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
captcha.Log.Infof("[STREAM %d] [Captcha] solver succeeded", streamID)
|
|
return successToken, nil
|
|
}
|