Files
free-turn-proxy-orig/internal/client/vkauth/solver.go
T
samosvalishe 242862397a chore: переименовать модуль в github.com/samosvalishe/btp; обновить зависимости
- путь модуля: github.com/cacggghp/vk-turn-proxy → github.com/samosvalishe/btp
- директории cmd: cmd/vk-turn-{client,server} → cmd/{client,server}
- зависимости: pion/turn v5.0.4, kcp-go v5.6.72, smux v1.5.57, x/crypto v0.51,
  klauspost/{compress,cpuid,reedsolomon}, x/{net,sys,text,tools,mod,time}
- README, workflows, GLOSSARY обновлены под новые пути
2026-05-20 12:39:26 +03:00

65 lines
1.7 KiB
Go

package vkauth
import (
"context"
"net"
"github.com/samosvalishe/btp/internal/client/browserprofile"
"github.com/samosvalishe/btp/internal/client/captcha"
tlsclient "github.com/bogdanfinn/tls-client"
)
// CaptchaSolveMode selects between auto-solving and manual-browser fallback.
type CaptchaSolveMode int
const (
CaptchaSolveModeAuto CaptchaSolveMode = iota
CaptchaSolveModeManual
)
// CaptchaSolveModeForAttempt picks the solver to use on a given retry attempt.
// Returns (mode, true) when a mode is available, (_, false) when exhausted.
func CaptchaSolveModeForAttempt(attempt int, manualOnly bool) (CaptchaSolveMode, bool) {
if manualOnly {
return CaptchaSolveModeManual, attempt == 0
}
switch attempt {
case 0:
return CaptchaSolveModeAuto, true
case 1:
return CaptchaSolveModeManual, true
}
return 0, false
}
func CaptchaSolveModeLabel(mode CaptchaSolveMode) string {
switch mode {
case CaptchaSolveModeAuto:
return "auto captcha"
case CaptchaSolveModeManual:
return "manual captcha"
default:
return "captcha"
}
}
// AutoSolveFunc returns a success_token for the captcha when solvable via the
// in-page widget flow. Implementations must respect ctx cancellation.
type AutoSolveFunc func(
ctx context.Context,
captchaErr *captcha.Error,
streamID int,
http tlsclient.HttpClient,
profile browserprofile.Profile,
) (token string, err error)
// ManualSolveFunc opens the local browser-based fallback. Returns either a
// success_token (token != "") or a captcha_key, depending on which path the
// VK error exposed.
type ManualSolveFunc func(
ctx context.Context,
captchaErr *captcha.Error,
dialer net.Dialer,
) (token, key string, err error)