Resolve gofmt formatting issues
This commit is contained in:
1 parent
c87ccd05e3
commit
f278c65e6f
2 files changed
+77
-78
No files matched your search
+77
-77
@@ -245,91 +245,91 @@ type VkCaptchaError struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ParseVkCaptchaError(errData map[string]interface{}) *VkCaptchaError {
|
func ParseVkCaptchaError(errData map[string]interface{}) *VkCaptchaError {
|
||||||
// Extract error_code
|
// Extract error_code
|
||||||
codeFloat, ok := errData["error_code"].(float64)
|
codeFloat, ok := errData["error_code"].(float64)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Printf("missing error_code in captcha error data")
|
log.Printf("missing error_code in captcha error data")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
code := int(codeFloat)
|
code := int(codeFloat)
|
||||||
|
|
||||||
// Extract redirect_uri
|
// Extract redirect_uri
|
||||||
RedirectURI, ok := errData["redirect_uri"].(string)
|
RedirectURI, ok := errData["redirect_uri"].(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Printf("missing redirect_uri in captcha error data")
|
log.Printf("missing redirect_uri in captcha error data")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract captcha_sid
|
// Extract captcha_sid
|
||||||
captchaSid, ok := errData["captcha_sid"].(string)
|
captchaSid, ok := errData["captcha_sid"].(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
// try numeric
|
// try numeric
|
||||||
if sidNum, ok2 := errData["captcha_sid"].(float64); ok2 {
|
if sidNum, ok2 := errData["captcha_sid"].(float64); ok2 {
|
||||||
captchaSid = fmt.Sprintf("%.0f", sidNum)
|
captchaSid = fmt.Sprintf("%.0f", sidNum)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("missing captcha_sid in captcha error data")
|
log.Printf("missing captcha_sid in captcha error data")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract captcha_img
|
// Extract captcha_img
|
||||||
captchaImg, ok := errData["captcha_img"].(string)
|
captchaImg, ok := errData["captcha_img"].(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Printf("missing captcha_img in captcha error data")
|
log.Printf("missing captcha_img in captcha error data")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract error_msg
|
// Extract error_msg
|
||||||
errorMsg, ok := errData["error_msg"].(string)
|
errorMsg, ok := errData["error_msg"].(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Printf("missing error_msg in captcha error data")
|
log.Printf("missing error_msg in captcha error data")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract session token if redirect_uri present
|
// Extract session token if redirect_uri present
|
||||||
var sessionToken string
|
var sessionToken string
|
||||||
if RedirectURI != "" {
|
if RedirectURI != "" {
|
||||||
if parsed, err := neturl.Parse(RedirectURI); err == nil {
|
if parsed, err := neturl.Parse(RedirectURI); err == nil {
|
||||||
sessionToken = parsed.Query().Get("session_token")
|
sessionToken = parsed.Query().Get("session_token")
|
||||||
} else {
|
} else {
|
||||||
log.Printf("failed to parse redirect_uri: %v", err)
|
log.Printf("failed to parse redirect_uri: %v", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract is_sound_captcha_available
|
// Extract is_sound_captcha_available
|
||||||
isSound, ok := errData["is_sound_captcha_available"].(bool)
|
isSound, ok := errData["is_sound_captcha_available"].(bool)
|
||||||
if !ok {
|
if !ok {
|
||||||
isSound = false
|
isSound = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract captcha_ts
|
// Extract captcha_ts
|
||||||
var captchaTs string
|
var captchaTs string
|
||||||
if tsFloat, ok := errData["captcha_ts"].(float64); ok {
|
if tsFloat, ok := errData["captcha_ts"].(float64); ok {
|
||||||
captchaTs = fmt.Sprintf("%.0f", tsFloat)
|
captchaTs = fmt.Sprintf("%.0f", tsFloat)
|
||||||
} else if tsStr, ok := errData["captcha_ts"].(string); ok {
|
} else if tsStr, ok := errData["captcha_ts"].(string); ok {
|
||||||
captchaTs = tsStr
|
captchaTs = tsStr
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract captcha_attempt
|
// Extract captcha_attempt
|
||||||
var captchaAttempt string
|
var captchaAttempt string
|
||||||
if attFloat, ok := errData["captcha_attempt"].(float64); ok {
|
if attFloat, ok := errData["captcha_attempt"].(float64); ok {
|
||||||
captchaAttempt = fmt.Sprintf("%.0f", attFloat)
|
captchaAttempt = fmt.Sprintf("%.0f", attFloat)
|
||||||
} else if attStr, ok := errData["captcha_attempt"].(string); ok {
|
} else if attStr, ok := errData["captcha_attempt"].(string); ok {
|
||||||
captchaAttempt = attStr
|
captchaAttempt = attStr
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build VkCaptchaError
|
// Build VkCaptchaError
|
||||||
return &VkCaptchaError{
|
return &VkCaptchaError{
|
||||||
ErrorCode: code,
|
ErrorCode: code,
|
||||||
ErrorMsg: errorMsg,
|
ErrorMsg: errorMsg,
|
||||||
CaptchaSid: captchaSid,
|
CaptchaSid: captchaSid,
|
||||||
CaptchaImg: captchaImg,
|
CaptchaImg: captchaImg,
|
||||||
RedirectURI: RedirectURI,
|
RedirectURI: RedirectURI,
|
||||||
IsSoundCaptchaAvailable: isSound,
|
IsSoundCaptchaAvailable: isSound,
|
||||||
SessionToken: sessionToken,
|
SessionToken: sessionToken,
|
||||||
CaptchaTs: captchaTs,
|
CaptchaTs: captchaTs,
|
||||||
CaptchaAttempt: captchaAttempt,
|
CaptchaAttempt: captchaAttempt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1003,7 +1003,7 @@ func getTokenChain(ctx context.Context, link string, streamID int, creds VKCrede
|
|||||||
}
|
}
|
||||||
token3, ok := resp["session_key"].(string)
|
token3, ok := resp["session_key"].(string)
|
||||||
if !ok {
|
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)
|
vkDelayRandom(100, 150)
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import (
|
|||||||
"github.com/xtaci/smux"
|
"github.com/xtaci/smux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
listen := flag.String("listen", "0.0.0.0:56000", "listen on ip:port")
|
listen := flag.String("listen", "0.0.0.0:56000", "listen on ip:port")
|
||||||
connect := flag.String("connect", "", "connect to ip:port")
|
connect := flag.String("connect", "", "connect to ip:port")
|
||||||
|
|||||||
Reference in new issue
Block a user