mirror of
https://git.oceanpay.cc/danial/kami_script.git
synced 2025-12-18 20:56:47 +00:00
refactor(main): 重构 randomRequest 函数并更新请求参数
- 移除 randomRequest 函数的 client 参数,改为在函数内部创建 http.Client - 更新请求的 NotifyUrl 为 "https://shop.oceanpay.cc/shop/notify" - 从 main 函数中移除 client 的创建,简化代码结构- 修改循环次数,从 math.Pow10(0) 改为 math.Pow10(1),增加请求次数
This commit is contained in:
10
main.go
10
main.go
@@ -73,7 +73,7 @@ func genSign(data models.Data) string {
|
||||
return hex.EncodeToString(h.Sum(nil))
|
||||
}
|
||||
|
||||
func randomRequest(count int, stop chan int, group *sync.WaitGroup, client *http.Client) {
|
||||
func randomRequest(count int, stop chan int, group *sync.WaitGroup) {
|
||||
defer func() {
|
||||
<-stop
|
||||
group.Done()
|
||||
@@ -94,12 +94,13 @@ func randomRequest(count int, stop chan int, group *sync.WaitGroup, client *http
|
||||
OrderPrice: "10",
|
||||
ProductCode: "fdsu",
|
||||
Ip: "127.0.0.1",
|
||||
NotifyUrl: "https://shop.kkknametrans.buzz/shop/notify",
|
||||
NotifyUrl: "https://shop.oceanpay.cc/shop/notify",
|
||||
PayKey: "kkkkc9kit6bimggos5kk0c90",
|
||||
TimeStamp: strconv.FormatInt(time.Now().Unix(), 10),
|
||||
Sign: "",
|
||||
}
|
||||
formData.Sign = genSign(formData)
|
||||
client := http.Client{}
|
||||
res, _ := client.PostForm("https://gateway.oceanpay.cc/gateway/scan", formData.Url())
|
||||
result, _ := io.ReadAll(res.Body)
|
||||
fmt.Println(string(result))
|
||||
@@ -109,11 +110,10 @@ func main() {
|
||||
group := sync.WaitGroup{}
|
||||
startTime := time.Now()
|
||||
stop := make(chan int, 50)
|
||||
client := http.Client{}
|
||||
for i := 0; i < int(math.Pow10(0)); i++ {
|
||||
for i := 0; i < int(math.Pow10(1)); i++ {
|
||||
group.Add(1)
|
||||
stop <- 1
|
||||
go randomRequest(i, stop, &group, &client)
|
||||
go randomRequest(i, stop, &group)
|
||||
}
|
||||
group.Wait()
|
||||
fmt.Println("总耗时", time.Since(startTime).Seconds())
|
||||
|
||||
Reference in New Issue
Block a user