优化依赖管理,更新请求参数和地址,调整并发请求逻辑

This commit is contained in:
danial
2025-08-18 21:01:37 +08:00
parent 2b092c43f6
commit 634192ff66
3 changed files with 8 additions and 11 deletions

5
go.mod
View File

@@ -2,7 +2,4 @@ module kami_scripts
go 1.20
require (
github.com/matoous/go-nanoid/v2 v2.0.0 // indirect
github.com/rs/xid v1.5.0 // indirect
)
require github.com/matoous/go-nanoid/v2 v2.0.0

7
go.sum
View File

@@ -1,12 +1,13 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/matoous/go-nanoid v1.5.0 h1:VRorl6uCngneC4oUQqOYtO3S0H5QKFtKuKycFG3euek=
github.com/matoous/go-nanoid v1.5.0/go.mod h1:zyD2a71IubI24efhpvkJz+ZwfwagzgSO6UNiFsZKN7U=
github.com/matoous/go-nanoid/v2 v2.0.0 h1:d19kur2QuLeHmJBkvYkFdhFBzLoo1XVm2GgTpL+9Tj0=
github.com/matoous/go-nanoid/v2 v2.0.0/go.mod h1:FtS4aGPVfEkxKxhdWPAspZpZSh1cOjtM7Ej/So3hR0g=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@@ -81,7 +81,6 @@ func randomRequest(count int, stop chan int, group *sync.WaitGroup, client *http
fmt.Println(err)
}
}()
fmt.Println("正在发送请求次数", count, time.Now().Format("2006-01-02 15:04:05"))
id, _ := gonanoid.New()
formData := models.Data{
ExValue: models.ExValue{
@@ -93,7 +92,7 @@ func randomRequest(count int, stop chan int, group *sync.WaitGroup, client *http
OrderNo: id,
OrderPeriod: strconv.Itoa(rand.Intn(24)),
OrderPrice: "10",
ProductCode: "666",
ProductCode: "fdsu",
Ip: "127.0.0.1",
NotifyUrl: "https://shop.kkknametrans.buzz/shop/notify",
PayKey: "kkkkc9kit6bimggos5kk0c90",
@@ -101,7 +100,7 @@ func randomRequest(count int, stop chan int, group *sync.WaitGroup, client *http
Sign: "",
}
formData.Sign = genSign(formData)
res, _ := client.PostForm("http://175.27.239.142:12309/gateway/scan", formData.Url())
res, _ := client.PostForm("https://gateway.oceanpay.cc/gateway/scan", formData.Url())
result, _ := io.ReadAll(res.Body)
fmt.Println(string(result))
}
@@ -111,7 +110,7 @@ func main() {
startTime := time.Now()
stop := make(chan int, 50)
client := http.Client{}
for i := 1; i < int(math.Pow10(3)); i++ {
for i := 0; i < int(math.Pow10(0)); i++ {
group.Add(1)
stop <- 1
go randomRequest(i, stop, &group, &client)