Эх сурвалжийг харах

验证码服务请求忽略证书校验

maxiaoshan 2 жил өмнө
parent
commit
d0a20da3ad

+ 9 - 4
src/analysiscode/server.go

@@ -1,9 +1,10 @@
-package analysiscode
+package main
 
 import (
 	"analysiscode/proto"
 	"bytes"
 	"context"
+	"crypto/tls"
 	"encoding/json"
 	"fmt"
 	"net"
@@ -26,7 +27,7 @@ type CodeService struct {
 }
 
 //server
-func main1() {
+func main() {
 	util.Debug("port", spiderutil.Config.ServerPort)
 	lis, err := net.Listen("tcp", spiderutil.Config.ServerPort)
 	if err != nil {
@@ -67,7 +68,9 @@ func getCode(path, stype, head, cookie string) (code string, respheader http.Hea
 
 func getCodeByFree(path, stype, head, cookie string) (code string, respheader http.Header, respcookie []*http.Cookie, getCodeResp *req.Response) {
 	defer util.Catch()
-	client := req.C().SetTimeout(spiderutil.Config.TimeOut * time.Second)
+	client := req.C().
+		SetTimeout(spiderutil.Config.TimeOut * time.Second).
+		SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}) //忽略证书验证
 	headers := map[string]string{}
 	if head != "" {
 		json.Unmarshal([]byte(head), &headers)
@@ -124,7 +127,9 @@ func getCodeByFree(path, stype, head, cookie string) (code string, respheader ht
 
 func getCodeByPay(path, stype, head, cookie string) (code string, respheader http.Header, respcookie []*http.Cookie) {
 	defer util.Catch()
-	client := req.C().SetTimeout(spiderutil.Config.TimeOut * time.Second)
+	client := req.C().
+		SetTimeout(spiderutil.Config.TimeOut * time.Second).
+		SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}) //忽略证书验证
 	headers := map[string]string{}
 	if head != "" {
 		json.Unmarshal([]byte(head), &headers)

+ 1 - 1
src/spiderutil/upload.go

@@ -56,7 +56,7 @@ func Upload(code, fileName, url string, bt []byte) (string, string, string) {
 
 //返回下载链接,文件名称,文件大小,文件类型,文件fid
 func UploadFile(code, fileName, url string, bt []byte) (string, string, string, string, string) {
-	if bt == nil || len(bt) < 1024*3 {
+	if bt == nil || len(bt) < 1024*5 {
 		logger.Error("下载文件出错!", code, " upload file "+fileName, url)
 		return "", "", "", "", ""
 	}