# 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