Skip to content

Commit 9bb33fc

Browse files
authored
Merge pull request #120 from antongospod/main
feat: manual captcha flag + delay before manual captcha has been reduce
2 parents 72f051e + 9dcaf66 commit 9bb33fc

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

client/main.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ var (
6565
globalAppCancel context.CancelFunc
6666
handshakeSem = make(chan struct{}, 3)
6767
isDebug bool
68+
manualCaptcha bool
6869
)
6970

7071
type UDPPacket struct {
@@ -815,7 +816,10 @@ func getTokenChain(ctx context.Context, link string, streamID int, creds VKCrede
815816
urlAddr := fmt.Sprintf("https://api.vk.ru/method/calls.getAnonymousToken?v=5.275&client_id=%s", creds.ClientID)
816817

817818
var token2 string
818-
const maxAutoAttempts = 2
819+
maxAutoAttempts := 2
820+
if manualCaptcha {
821+
maxAutoAttempts = 0
822+
}
819823
for attempt := 0; attempt <= maxAutoAttempts+1; attempt++ {
820824
resp, err = doRequest(data, urlAddr)
821825
if err != nil {
@@ -891,11 +895,11 @@ func getTokenChain(ctx context.Context, link string, streamID int, creds VKCrede
891895
}
892896
continue
893897
} else if attempt == maxAutoAttempts-1 {
894-
log.Printf("[STREAM %d] [Captcha] Backing off for 30 seconds before manual fallback...", streamID)
898+
log.Printf("[STREAM %d] [Captcha] Backing off for 2 seconds before manual fallback...", streamID)
895899
select {
896900
case <-ctx.Done():
897901
return "", "", "", ctx.Err()
898-
case <-time.After(30 * time.Second):
902+
case <-time.After(2 * time.Second):
899903
}
900904
continue
901905
}
@@ -1674,6 +1678,7 @@ func main() {
16741678
udp := flag.Bool("udp", false, "connect to TURN with UDP")
16751679
direct := flag.Bool("no-dtls", false, "connect without obfuscation. DO NOT USE")
16761680
debugFlag := flag.Bool("debug", false, "enable debug logging")
1681+
manualCaptchaFlag := flag.Bool("manual-captcha", false, "skip auto captcha solving, use manual mode immediately")
16771682
flag.Parse()
16781683
if *peerAddr == "" {
16791684
log.Panicf("Need peer address!")
@@ -1687,6 +1692,7 @@ func main() {
16871692
}
16881693

16891694
isDebug = *debugFlag
1695+
manualCaptcha = *manualCaptchaFlag
16901696

16911697
var link string
16921698
var getCreds getCredsFunc

0 commit comments

Comments
 (0)