Browse Source

chore: resolve golangci-lint issues

pull/181/head
Moroka8 2 months ago
parent
commit
3d7289e4ce
  1. 13
      client/captcha_v2.go
  2. 12
      server/main.go

13
client/captcha_v2.go

@ -180,8 +180,8 @@ func (s *captchaV2Session) solveOnce(captchaErr *VkCaptchaError) (string, error)
log.Printf("v2 captcha pow solved")
base := captchaV2BaseValues(captchaErr.SessionToken)
if _, err := s.captchaRequest("captchaNotRobot.settings", base); err != nil {
return "", fmt.Errorf("captcha settings failed: %w", err)
if _, settingsErr := s.captchaRequest("captchaNotRobot.settings", base); settingsErr != nil {
return "", fmt.Errorf("captcha settings failed: %w", settingsErr)
}
browserFP, err := captchaV2BrowserFP()
@ -233,7 +233,9 @@ func (s *captchaV2Session) solveOnce(captchaErr *VkCaptchaError) (string, error)
showType = stErr.ShowType
}
_, _ = s.captchaRequest("captchaNotRobot.endSession", base)
if _, endErr := s.captchaRequest("captchaNotRobot.endSession", base); endErr != nil {
log.Printf("v2 captcha endSession failed: %v", endErr)
}
return token, nil
}
@ -269,7 +271,10 @@ func (s *captchaV2Session) fetchCaptchaHTML(redirectURI string) (string, error)
func (s *captchaV2Session) fetchDebugInfo(scriptURL string) (string, error) {
if cached, ok := captchaV2DebugCache.Load(scriptURL); ok {
return cached.(string), nil
if cachedDebugInfo, ok := cached.(string); ok {
return cachedDebugInfo, nil
}
captchaV2DebugCache.Delete(scriptURL)
}
body, err := s.doRaw(fhttp.MethodGet, scriptURL, nil, map[string]string{
"Accept": "text/javascript,*/*",

12
server/main.go

@ -284,14 +284,6 @@ type bondFrame struct {
data []byte
}
func readBondHello(r io.Reader) (bondHello, error) {
var hdr [17]byte
if _, err := io.ReadFull(r, hdr[:]); err != nil {
return bondHello{}, err
}
return parseBondHelloHeader(hdr[:])
}
func readBondHelloAfterMagic(r io.Reader, magic [4]byte) (bondHello, error) {
var hdr [17]byte
copy(hdr[0:4], magic[:])
@ -662,10 +654,6 @@ func (c *bondServerConn) writeToNextLane(typ byte, seq uint64, data []byte, lane
}
}
func handleBondServerStream(ctx context.Context, stream *smux.Stream, connectAddr string) {
handleBondServerStreamWithHello(ctx, stream, connectAddr, readBondHello)
}
func handleBondServerStreamAfterMagic(ctx context.Context, stream *smux.Stream, connectAddr string, magic [4]byte) {
handleBondServerStreamWithHello(ctx, stream, connectAddr, func(r io.Reader) (bondHello, error) {
return readBondHelloAfterMagic(r, magic)

Loading…
Cancel
Save