Files
kami_script/CLAUDE.md
danial 5cf434370e chore(deps): 升级Go版本及第三方依赖库
- 将Go版本从1.20升级到1.23.0
- 添加resty客户端库github.com/go-resty/resty/v2 v2.17.0
- 升级go-nanoid库版本到v2.1.0
- 添加golang.org/x/net v0.43.0为间接依赖
- 升级testify测试库到v1.9.0
- 升级yaml.v3到v3.0.1版本

feat(main): 使用resty替代http客户端并提高请求并发

- 用resty库替代原始http.Client实现POST请求
- 修改支付网关和通知URL为测试环境地址
- 将并发请求数从10提升到100以增加负载
- 修正请求参数ProductCode为“玖隆”
- 调整请求发送及结果打印逻辑以兼容resty响应结构
2025-12-14 22:13:42 +08:00

108 lines
3.1 KiB
Markdown

# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
This is a Go-based load testing script (卡密并发脚本) designed for stress testing payment gateways. The script generates concurrent requests with random card numbers and credentials to test system performance under load.
## Architecture
### Core Components
- **main.go**: Entry point containing the main concurrency logic and request generation
- **models/**: Data structures for API requests
- `model.go`: Core request data structures (`Data`, `ExValue`) with URL encoding
- `order.go`: Order parameter encryption (`OrderParams`)
- `account.go`: Account-related models
- **utils/**: Utility functions
- `enctrypt.go`: AES-CBC encryption with PKCS7 padding for sensitive data
### Key Functions
- **randomRequest()** (main.go:76): Generates individual HTTP requests with random card data
- **genSign()** (main.go:47): Creates MD5 signature for API authentication using sorted parameter concatenation
- **GenRandomCardNo()** (main.go:31): Generates random 16-digit card numbers starting with "250306"
- **GenRandomCardPass()** (main.go:39): Generates random 16-digit card passwords starting with "350610"
### Request Flow
1. Generate unique order ID using nanoid
2. Create random card number and password
3. Build request parameters with hardcoded credentials
4. Generate MD5 signature using parameter sorting and app secret
5. Send POST request to external gateway
6. Process and display response
## Development Commands
### Build and Run
```bash
# Build the application
go build -o kami_script
# Run directly
go run main.go
# Run with specific parameters if modified
go run main.go -concurrency=50 -requests=1000
```
### Testing
```bash
# Run tests (if any exist)
go test ./...
# Run with verbose output
go test -v ./...
# Check code coverage
go test -cover ./...
```
### Dependency Management
```bash
# Download dependencies
go mod download
# Tidy up go.mod
go mod tidy
# Verify dependencies
go mod verify
```
### Code Quality
```bash
# Format code
go fmt ./...
# Lint code
go vet ./...
# Check for issues
golint ./...
```
## Configuration
### Hardcoded Values
- App Secret: `"ssssc9kit6bimggos5kk0c9g"` (main.go:48)
- Pay Key: `"kkkkc9kit6bimggos5kk0c90"` (main.go:98)
- Gateway URL: `"https://gateway.oceanpay.cc/gateway/scan"` (main.go:104)
- Notify URL: `"https://shop.oceanpay.cc/shop/notify"` (main.go:97)
- AES Encryption Key: `"thisis32bitlongpassphraseimusing"` (models/order.go:24)
- AES IV: `"1234567890123456"` (models/order.go:26)
### Concurrency Settings
- Default buffer channel size: 50 (main.go:112)
- Default request count: 10^1 = 10 (main.go:113)
## Important Notes
- This script is designed for load testing purposes only
- Contains hardcoded credentials and encryption keys
- Uses goroutines with sync.WaitGroup for concurrent request handling
- Implements panic recovery in goroutines to prevent crashes
- All requests generate random card data for testing uniqueness
- Signature generation follows specific parameter sorting algorithm for API compatibility