Skip to content

gptkong/gin-flaresolverr-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gin-flaresolverr-proxy

一个最小可用的 Gin 服务:接收 trade_no/pid/key 等查询参数,调用本地 FlareSolverr 获取通过 Cloudflare 后的真实响应体,并把响应返回给调用方。

依赖

  • Go(建议 1.20+)
  • FlareSolverr(默认地址:http://127.0.0.1:8191/v1

配置

  • PORT:服务端口,默认 8080
  • TARGET_URL:目标接口地址,默认 https://credit.linux.do/epay/api.php
  • FLARESOLVERR_URL:FlareSolverr 地址,默认 http://127.0.0.1:8191/v1
  • MAX_TIMEOUT_MS:FlareSolverr maxTimeout(毫秒),默认 60000

接口

GET /api

查询订单状态。

认证:pid + key

参数 必填 说明
act 可选字段,建议 order(后端不强校验)
pid Client ID
key Client Secret
trade_no 编号
out_trade_no 业务单号
raw 1/true 返回原始响应体(不提取/不解析)

POST /api

订单退款等 POST 操作。

编码:application/jsonapplication/x-www-form-urlencoded

参数 必填 说明
pid Client ID
key Client Secret
trade_no 编号
money 是(退款时) 退款金额,必须等于原积分流转服务的积分数量
out_trade_no 业务单号(兼容)
raw URL 参数,传 1/true 返回原始响应体

运行

cd gin-flaresolverr-proxy
go mod tidy
go run .

Docker 部署

docker compose(推荐)

cd gin-flaresolverr-proxy
# 可选:通过环境变量覆盖 FlareSolverr 地址(比如外部 FlareSolverr)
# export FLARESOLVERR_URL='http://127.0.0.1:8191/v1'
docker compose up -d --build

docker run(仅运行本服务)

cd gin-flaresolverr-proxy
docker build -t gin-flaresolverr-proxy .
docker run --rm -p 8080:8080 \
  -e FLARESOLVERR_URL='http://127.0.0.1:8191/v1' \
  gin-flaresolverr-proxy

GitHub Actions 自动打包

  • Workflow:gin-flaresolverr-proxy/.github/workflows/docker.yml
  • 触发:push 到 main/master 或打 v* tag
  • 产物:推送到 ghcr.io/<owner>/<repo>(使用 GITHUB_TOKEN

调用示例

1) 返回提取后的 JSON(优先从 <pre>...</pre> 中提取)

curl 'http://127.0.0.1:8080/api?trade_no=011887340502908928&pid=...&key=...'

2) 返回原始响应体(不做提取/解析)

curl 'http://127.0.0.1:8080/api?trade_no=011887340502908928&pid=...&key=...&raw=1'

3) POST 退款请求(JSON 格式)

curl -X POST 'http://127.0.0.1:8080/api' \
  -H 'Content-Type: application/json' \
  -d '{"pid":"your_pid","key":"your_key","trade_no":"011887340502908928","money":"100"}'

4) POST 退款请求(form-urlencoded 格式)

curl -X POST 'http://127.0.0.1:8080/api' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'pid=your_pid&key=your_key&trade_no=011887340502908928&money=100'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors