From f278c65e6fe4f270d0a25b55a9520a0a8210d729 Mon Sep 17 00:00:00 2001 From: Moroka8 Date: Wed, 8 Apr 2026 19:43:33 +0700 Subject: [PATCH] Resolve gofmt formatting issues --- client/main.go | 172 ++++++++++++++++++++++++------------------------- server/main.go | 1 - 2 files changed, 86 insertions(+), 87 deletions(-) diff --git a/client/main.go b/client/main.go index 80f211b..1f0847e 100644 --- a/client/main.go +++ b/client/main.go @@ -245,91 +245,91 @@ type VkCaptchaError struct { } func ParseVkCaptchaError(errData map[string]interface{}) *VkCaptchaError { - // Extract error_code - codeFloat, ok := errData["error_code"].(float64) - if !ok { - log.Printf("missing error_code in captcha error data") - return nil - } - code := int(codeFloat) - - // Extract redirect_uri - RedirectURI, ok := errData["redirect_uri"].(string) - if !ok { - log.Printf("missing redirect_uri in captcha error data") - return nil - } - - // Extract captcha_sid - captchaSid, ok := errData["captcha_sid"].(string) - if !ok { - // try numeric - if sidNum, ok2 := errData["captcha_sid"].(float64); ok2 { - captchaSid = fmt.Sprintf("%.0f", sidNum) - } else { - log.Printf("missing captcha_sid in captcha error data") - return nil - } - } - - // Extract captcha_img - captchaImg, ok := errData["captcha_img"].(string) - if !ok { - log.Printf("missing captcha_img in captcha error data") - return nil - } - - // Extract error_msg - errorMsg, ok := errData["error_msg"].(string) - if !ok { - log.Printf("missing error_msg in captcha error data") - return nil - } - - // Extract session token if redirect_uri present - var sessionToken string - if RedirectURI != "" { - if parsed, err := neturl.Parse(RedirectURI); err == nil { - sessionToken = parsed.Query().Get("session_token") - } else { - log.Printf("failed to parse redirect_uri: %v", err) - return nil - } - } - - // Extract is_sound_captcha_available - isSound, ok := errData["is_sound_captcha_available"].(bool) - if !ok { - isSound = false - } - - // Extract captcha_ts - var captchaTs string - if tsFloat, ok := errData["captcha_ts"].(float64); ok { - captchaTs = fmt.Sprintf("%.0f", tsFloat) - } else if tsStr, ok := errData["captcha_ts"].(string); ok { - captchaTs = tsStr - } - - // Extract captcha_attempt - var captchaAttempt string - if attFloat, ok := errData["captcha_attempt"].(float64); ok { - captchaAttempt = fmt.Sprintf("%.0f", attFloat) - } else if attStr, ok := errData["captcha_attempt"].(string); ok { - captchaAttempt = attStr - } - - // Build VkCaptchaError - return &VkCaptchaError{ - ErrorCode: code, - ErrorMsg: errorMsg, - CaptchaSid: captchaSid, - CaptchaImg: captchaImg, - RedirectURI: RedirectURI, - IsSoundCaptchaAvailable: isSound, - SessionToken: sessionToken, - CaptchaTs: captchaTs, - CaptchaAttempt: captchaAttempt, + // Extract error_code + codeFloat, ok := errData["error_code"].(float64) + if !ok { + log.Printf("missing error_code in captcha error data") + return nil + } + code := int(codeFloat) + + // Extract redirect_uri + RedirectURI, ok := errData["redirect_uri"].(string) + if !ok { + log.Printf("missing redirect_uri in captcha error data") + return nil + } + + // Extract captcha_sid + captchaSid, ok := errData["captcha_sid"].(string) + if !ok { + // try numeric + if sidNum, ok2 := errData["captcha_sid"].(float64); ok2 { + captchaSid = fmt.Sprintf("%.0f", sidNum) + } else { + log.Printf("missing captcha_sid in captcha error data") + return nil + } + } + + // Extract captcha_img + captchaImg, ok := errData["captcha_img"].(string) + if !ok { + log.Printf("missing captcha_img in captcha error data") + return nil + } + + // Extract error_msg + errorMsg, ok := errData["error_msg"].(string) + if !ok { + log.Printf("missing error_msg in captcha error data") + return nil + } + + // Extract session token if redirect_uri present + var sessionToken string + if RedirectURI != "" { + if parsed, err := neturl.Parse(RedirectURI); err == nil { + sessionToken = parsed.Query().Get("session_token") + } else { + log.Printf("failed to parse redirect_uri: %v", err) + return nil + } + } + + // Extract is_sound_captcha_available + isSound, ok := errData["is_sound_captcha_available"].(bool) + if !ok { + isSound = false + } + + // Extract captcha_ts + var captchaTs string + if tsFloat, ok := errData["captcha_ts"].(float64); ok { + captchaTs = fmt.Sprintf("%.0f", tsFloat) + } else if tsStr, ok := errData["captcha_ts"].(string); ok { + captchaTs = tsStr + } + + // Extract captcha_attempt + var captchaAttempt string + if attFloat, ok := errData["captcha_attempt"].(float64); ok { + captchaAttempt = fmt.Sprintf("%.0f", attFloat) + } else if attStr, ok := errData["captcha_attempt"].(string); ok { + captchaAttempt = attStr + } + + // Build VkCaptchaError + return &VkCaptchaError{ + ErrorCode: code, + ErrorMsg: errorMsg, + CaptchaSid: captchaSid, + CaptchaImg: captchaImg, + RedirectURI: RedirectURI, + IsSoundCaptchaAvailable: isSound, + SessionToken: sessionToken, + CaptchaTs: captchaTs, + CaptchaAttempt: captchaAttempt, } } @@ -1003,7 +1003,7 @@ func getTokenChain(ctx context.Context, link string, streamID int, creds VKCrede } token3, ok := resp["session_key"].(string) if !ok { - return "", "", "", fmt.Errorf("missing session_key in response: %v", resp) + return "", "", "", fmt.Errorf("missing session_key in response: %v", resp) } vkDelayRandom(100, 150) diff --git a/server/main.go b/server/main.go index 123c101..36cd7cf 100644 --- a/server/main.go +++ b/server/main.go @@ -20,7 +20,6 @@ import ( "github.com/xtaci/smux" ) - func main() { listen := flag.String("listen", "0.0.0.0:56000", "listen on ip:port") connect := flag.String("connect", "", "connect to ip:port")