frist
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.env
|
||||
backend
|
||||
58
Makefile
Normal file
58
Makefile
Normal file
@@ -0,0 +1,58 @@
|
||||
.PHONY: build run test clean deps migrate
|
||||
|
||||
# 构建
|
||||
build:
|
||||
go build -o bin/proxyrotator ./cmd/server
|
||||
|
||||
# 运行
|
||||
run:
|
||||
go run ./cmd/server
|
||||
|
||||
# 测试
|
||||
test:
|
||||
go test -v ./...
|
||||
|
||||
# 清理
|
||||
clean:
|
||||
rm -rf bin/
|
||||
|
||||
# 安装依赖
|
||||
deps:
|
||||
go mod tidy
|
||||
go mod download
|
||||
|
||||
# 数据库迁移(需要 psql)
|
||||
migrate:
|
||||
@echo "Running database migration..."
|
||||
@if [ -z "$(DATABASE_URL)" ]; then \
|
||||
echo "DATABASE_URL is not set"; \
|
||||
exit 1; \
|
||||
fi
|
||||
psql "$(DATABASE_URL)" -f migrations/001_init.sql
|
||||
|
||||
# 开发模式(自动重载)
|
||||
dev:
|
||||
@which air > /dev/null || go install github.com/cosmtrek/air@latest
|
||||
air
|
||||
|
||||
# 格式化代码
|
||||
fmt:
|
||||
go fmt ./...
|
||||
|
||||
# 静态检查
|
||||
lint:
|
||||
@which golangci-lint > /dev/null || go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||
golangci-lint run
|
||||
|
||||
# 帮助
|
||||
help:
|
||||
@echo "Available targets:"
|
||||
@echo " build - Build the binary"
|
||||
@echo " run - Run the server"
|
||||
@echo " test - Run tests"
|
||||
@echo " clean - Remove build artifacts"
|
||||
@echo " deps - Install dependencies"
|
||||
@echo " migrate - Run database migrations"
|
||||
@echo " dev - Run with hot reload (requires air)"
|
||||
@echo " fmt - Format code"
|
||||
@echo " lint - Run linter"
|
||||
303
README.md
Normal file
303
README.md
Normal file
@@ -0,0 +1,303 @@
|
||||
# ProxyRotator
|
||||
|
||||
代理池管理系统 - 支持代理导入、测试、轮询分发和结果上报。
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 1. 安装依赖
|
||||
|
||||
```bash
|
||||
go mod tidy
|
||||
```
|
||||
|
||||
### 2. 初始化数据库
|
||||
|
||||
```bash
|
||||
# 创建 PostgreSQL 数据库
|
||||
createdb proxyrotator
|
||||
|
||||
# 执行迁移脚本
|
||||
export DATABASE_URL="postgres://user:pass@localhost:5432/proxyrotator?sslmode=disable"
|
||||
make migrate
|
||||
```
|
||||
|
||||
### 3. 启动服务
|
||||
|
||||
```bash
|
||||
make run
|
||||
```
|
||||
|
||||
## 配置
|
||||
|
||||
通过环境变量配置,或创建 `.env` 文件:
|
||||
|
||||
```env
|
||||
DATABASE_URL=postgres://user:pass@localhost:5432/proxyrotator?sslmode=disable
|
||||
LISTEN_ADDR=:8080
|
||||
API_KEY=your-secret-key
|
||||
RETURN_SECRET=true
|
||||
MAX_CONCURRENCY=200
|
||||
MAX_TEST_LIMIT=2000
|
||||
LEASE_TTL=60s
|
||||
```
|
||||
|
||||
| 变量 | 说明 | 默认值 |
|
||||
|------|------|--------|
|
||||
| `DATABASE_URL` | PostgreSQL 连接串 | - |
|
||||
| `LISTEN_ADDR` | 监听地址 | `:8080` |
|
||||
| `API_KEY` | API 密钥(空则不鉴权) | - |
|
||||
| `RETURN_SECRET` | 是否返回代理密码 | `true` |
|
||||
| `MAX_CONCURRENCY` | 测试最大并发数 | `200` |
|
||||
| `MAX_TEST_LIMIT` | 单次测试上限 | `2000` |
|
||||
| `LEASE_TTL` | 租约有效期 | `60s` |
|
||||
|
||||
---
|
||||
|
||||
## 代理格式
|
||||
|
||||
### 支持的格式
|
||||
|
||||
| 格式 | 示例 |
|
||||
|------|------|
|
||||
| `host:port` | `192.168.1.1:8080` |
|
||||
| `user:pass@host:port` | `admin:123456@192.168.1.1:8080` |
|
||||
| `http://host:port` | `http://192.168.1.1:8080` |
|
||||
| `http://user:pass@host:port` | `http://admin:123456@192.168.1.1:8080` |
|
||||
| `https://host:port` | `https://192.168.1.1:443` |
|
||||
| `socks5://host:port` | `socks5://192.168.1.1:1080` |
|
||||
| `socks5://user:pass@host:port` | `socks5://admin:123456@192.168.1.1:1080` |
|
||||
|
||||
### TXT 文件格式
|
||||
|
||||
每行一个代理,支持 `#` 注释:
|
||||
|
||||
```txt
|
||||
# HTTP 代理
|
||||
http://user:pass@1.2.3.4:8080
|
||||
http://5.6.7.8:3128
|
||||
|
||||
# SOCKS5 代理
|
||||
socks5://admin:pwd@10.0.0.1:1080
|
||||
socks5://10.0.0.2:1080
|
||||
|
||||
# 简写格式(自动推断协议)
|
||||
192.168.1.100:8080
|
||||
user:pass@192.168.1.101:8888
|
||||
```
|
||||
|
||||
### CSV 文件格式
|
||||
|
||||
列名:`protocol,host,port,username,password,group,tags`
|
||||
|
||||
```csv
|
||||
protocol,host,port,username,password,group,tags
|
||||
http,1.2.3.4,8080,user,pass,default,tag1;tag2
|
||||
socks5,5.6.7.8,1080,,,default,
|
||||
http,9.9.9.9,3128,admin,secret,vip,premium;fast
|
||||
```
|
||||
|
||||
- `tags` 使用分号 `;` 分隔多个标签
|
||||
- `username` 和 `password` 可留空
|
||||
|
||||
### 协议自动推断
|
||||
|
||||
当使用 `host:port` 或 `user:pass@host:port` 格式时,系统根据端口自动推断协议:
|
||||
|
||||
| 端口 | 推断协议 |
|
||||
|------|----------|
|
||||
| 443 | `https` |
|
||||
| 1080 | `socks5` |
|
||||
| 其他 | `http` |
|
||||
|
||||
可通过 `protocol_hint` 参数强制指定协议。
|
||||
|
||||
---
|
||||
|
||||
## API 接口
|
||||
|
||||
### 鉴权
|
||||
|
||||
如果配置了 `API_KEY`,请求时需携带:
|
||||
|
||||
```bash
|
||||
# 方式一:Authorization Header
|
||||
-H "Authorization: Bearer your-api-key"
|
||||
|
||||
# 方式二:X-API-Key Header
|
||||
-H "X-API-Key: your-api-key"
|
||||
```
|
||||
|
||||
### 1. 文本导入
|
||||
|
||||
`POST /v1/proxies/import/text`
|
||||
|
||||
```bash
|
||||
curl -X POST "http://localhost:8080/v1/proxies/import/text" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"group": "default",
|
||||
"tags": ["batch-01"],
|
||||
"protocol_hint": "auto",
|
||||
"text": "http://user:pass@1.2.3.4:8080\nsocks5://5.6.7.8:1080\n9.9.9.9:3128"
|
||||
}'
|
||||
```
|
||||
|
||||
**响应:**
|
||||
|
||||
```json
|
||||
{
|
||||
"imported": 2,
|
||||
"duplicated": 1,
|
||||
"invalid": 0,
|
||||
"invalid_items": []
|
||||
}
|
||||
```
|
||||
|
||||
### 2. 文件上传
|
||||
|
||||
`POST /v1/proxies/import/file`
|
||||
|
||||
```bash
|
||||
curl -X POST "http://localhost:8080/v1/proxies/import/file" \
|
||||
-F "file=@proxies.txt" \
|
||||
-F "group=default" \
|
||||
-F "tags=batch-01,imported" \
|
||||
-F "protocol_hint=auto" \
|
||||
-F "type=auto"
|
||||
```
|
||||
|
||||
| 参数 | 说明 |
|
||||
|------|------|
|
||||
| `file` | 上传的文件(必填) |
|
||||
| `group` | 分组名(默认 `default`) |
|
||||
| `tags` | 标签,逗号分隔 |
|
||||
| `type` | 文件类型:`auto`/`txt`/`csv` |
|
||||
| `protocol_hint` | 协议提示:`auto`/`http`/`https`/`socks5` |
|
||||
|
||||
### 3. 测试代理
|
||||
|
||||
`POST /v1/proxies/test`
|
||||
|
||||
```bash
|
||||
curl -X POST "http://localhost:8080/v1/proxies/test" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"group": "default",
|
||||
"filter": {
|
||||
"status": ["unknown", "alive"],
|
||||
"tags_any": ["batch-01"],
|
||||
"limit": 100
|
||||
},
|
||||
"test_spec": {
|
||||
"url": "https://httpbin.org/ip",
|
||||
"method": "GET",
|
||||
"timeout_ms": 5000,
|
||||
"expect_status": [200]
|
||||
},
|
||||
"concurrency": 50,
|
||||
"update_store": true,
|
||||
"write_log": true
|
||||
}'
|
||||
```
|
||||
|
||||
**响应:**
|
||||
|
||||
```json
|
||||
{
|
||||
"summary": {
|
||||
"tested": 100,
|
||||
"alive": 75,
|
||||
"dead": 25
|
||||
},
|
||||
"results": [
|
||||
{"proxy_id": "uuid", "ok": true, "latency_ms": 340, "error": ""},
|
||||
{"proxy_id": "uuid", "ok": false, "latency_ms": 5000, "error": "timeout"}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 4. 获取代理(轮询)
|
||||
|
||||
`GET /v1/proxies/next`
|
||||
|
||||
```bash
|
||||
curl "http://localhost:8080/v1/proxies/next?group=default&policy=round_robin&site=https://example.com"
|
||||
```
|
||||
|
||||
| 参数 | 说明 |
|
||||
|------|------|
|
||||
| `group` | 分组名(默认 `default`) |
|
||||
| `policy` | 策略:`round_robin`/`random`/`weighted` |
|
||||
| `site` | 目标站点(用于分组轮询) |
|
||||
| `tags_any` | 标签过滤,逗号分隔 |
|
||||
|
||||
**响应:**
|
||||
|
||||
```json
|
||||
{
|
||||
"proxy": {
|
||||
"id": "uuid",
|
||||
"protocol": "http",
|
||||
"host": "1.2.3.4",
|
||||
"port": 8080,
|
||||
"username": "user",
|
||||
"password": "pass"
|
||||
},
|
||||
"lease_id": "lease_abc123",
|
||||
"ttl_ms": 60000
|
||||
}
|
||||
```
|
||||
|
||||
### 5. 上报结果
|
||||
|
||||
`POST /v1/proxies/report`
|
||||
|
||||
```bash
|
||||
curl -X POST "http://localhost:8080/v1/proxies/report" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"lease_id": "lease_abc123",
|
||||
"proxy_id": "uuid",
|
||||
"success": true,
|
||||
"latency_ms": 500
|
||||
}'
|
||||
```
|
||||
|
||||
上报结果会影响代理的分数:
|
||||
- 成功:`score +1`
|
||||
- 失败:`score -3`
|
||||
|
||||
### 6. 健康检查
|
||||
|
||||
`GET /health`
|
||||
|
||||
```bash
|
||||
curl "http://localhost:8080/health"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 分发策略
|
||||
|
||||
| 策略 | 说明 |
|
||||
|------|------|
|
||||
| `round_robin` | 轮询(默认),按顺序依次返回 |
|
||||
| `random` | 随机选择 |
|
||||
| `weighted` | 加权随机,分数高的代理被选中概率更大 |
|
||||
|
||||
---
|
||||
|
||||
## 构建命令
|
||||
|
||||
```bash
|
||||
make build # 构建二进制
|
||||
make run # 运行服务
|
||||
make test # 运行测试
|
||||
make migrate # 数据库迁移
|
||||
make fmt # 格式化代码
|
||||
make lint # 静态检查
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
839
docs/developdoc.md
Normal file
839
docs/developdoc.md
Normal file
@@ -0,0 +1,839 @@
|
||||
下面是一份「**代理池 + 测试 + 分发(轮询)服务**」的**完整开发文档(PgSQL 版本)**。内容包括:整体架构、数据库表结构(SQL)、HTTP API 请求形式与契约、Go 语言预留接口(契约)与关键伪代码、关键流程与安全建议。
|
||||
|
||||
> 备注:该系统属于通用网络基础设施能力,建议仅在合法合规场景(自有业务、授权测试、合规爬取、出站路由)使用,并做好鉴权、审计与 SSRF 防护。
|
||||
|
||||
---
|
||||
|
||||
## 1. 目标与范围
|
||||
|
||||
### 1.1 目标能力
|
||||
|
||||
1. **导入代理**
|
||||
|
||||
* 支持:文本粘贴、上传 txt、上传 csv
|
||||
* 自动解析多种格式,去重入库(PgSQL 唯一约束)
|
||||
|
||||
2. **测试代理可用性**
|
||||
|
||||
* 可指定目标网站(URL)与测试规则(超时、期望状态码、可选关键字)
|
||||
* 支持并发 worker pool
|
||||
* 测试结果可写回数据库(状态/延迟/计数/分数)
|
||||
|
||||
3. **分发服务(轮询接口预留)**
|
||||
|
||||
* 调用方通过 HTTP 获取“下一条可用代理”(RoundRobin / Random / Weighted 可扩展)
|
||||
* 支持 lease(租约)机制(推荐),便于结果上报与统计
|
||||
|
||||
4. **结果上报(可选但强烈推荐)**
|
||||
|
||||
* 调用方用完代理后上报 success/fail,驱动 score 调整与熔断策略
|
||||
|
||||
---
|
||||
|
||||
## 2. 总体架构与模块划分
|
||||
|
||||
### 2.1 模块
|
||||
|
||||
* **API Layer**:HTTP 路由与鉴权、参数校验、返回 JSON
|
||||
* **Importer**:解析 Text / CSV 为 Proxy 列表,输出 invalid 行原因
|
||||
* **Store (PgSQL)**:Upsert、查询、健康度更新、RR 游标、lease 管理
|
||||
* **Tester**:对代理执行 HTTP 请求测试,返回 TestResult
|
||||
* **Selector**:按策略从可用代理集合中选择一条(RoundRobin 为默认)
|
||||
* (可选)**Cleaner Job**:定期清理过期 lease、(可选)写测试日志
|
||||
|
||||
### 2.2 推荐包结构
|
||||
|
||||
```
|
||||
cmd/server/main.go
|
||||
internal/api/handlers.go
|
||||
internal/model/types.go
|
||||
internal/importer/importer.go
|
||||
internal/tester/http_tester.go
|
||||
internal/selector/selector.go
|
||||
internal/store/pg_store.go
|
||||
internal/security/validate_url.go
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. 数据模型(Go)
|
||||
|
||||
```go
|
||||
// internal/model/types.go
|
||||
|
||||
type ProxyProtocol string
|
||||
const (
|
||||
ProtoHTTP ProxyProtocol = "http"
|
||||
ProtoHTTPS ProxyProtocol = "https"
|
||||
ProtoSOCKS5 ProxyProtocol = "socks5"
|
||||
)
|
||||
|
||||
type ProxyStatus string
|
||||
const (
|
||||
StatusUnknown ProxyStatus = "unknown"
|
||||
StatusAlive ProxyStatus = "alive"
|
||||
StatusDead ProxyStatus = "dead"
|
||||
)
|
||||
|
||||
type Proxy struct {
|
||||
ID string // uuid
|
||||
|
||||
Protocol ProxyProtocol
|
||||
Host string
|
||||
Port int
|
||||
Username string
|
||||
Password string
|
||||
|
||||
Group string
|
||||
Tags []string
|
||||
|
||||
Status ProxyStatus
|
||||
Score int
|
||||
LatencyMs int64
|
||||
LastCheckAt int64 // unix ms 或 time.Time(看你序列化偏好)
|
||||
|
||||
FailCount int
|
||||
SuccessCount int
|
||||
Disabled bool
|
||||
|
||||
CreatedAt int64
|
||||
UpdatedAt int64
|
||||
}
|
||||
|
||||
type HealthPatch struct {
|
||||
Status *ProxyStatus
|
||||
ScoreDelta int
|
||||
LatencyMs *int64
|
||||
CheckedAtMs *int64
|
||||
FailInc int
|
||||
SuccessInc int
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. PostgreSQL 表结构(SQL)
|
||||
|
||||
> 设计要点:**唯一约束去重**、tags 用 `text[] + GIN`、RR 游标用独立表原子自增、lease 用表可追踪。
|
||||
|
||||
### 4.1 枚举类型与主表 `proxies`
|
||||
|
||||
```sql
|
||||
CREATE TYPE proxy_protocol AS ENUM ('http', 'https', 'socks5');
|
||||
CREATE TYPE proxy_status AS ENUM ('unknown', 'alive', 'dead');
|
||||
|
||||
CREATE TABLE proxies (
|
||||
id uuid PRIMARY KEY,
|
||||
|
||||
protocol proxy_protocol NOT NULL,
|
||||
host text NOT NULL,
|
||||
port int NOT NULL CHECK (port > 0 AND port < 65536),
|
||||
username text NOT NULL DEFAULT '',
|
||||
password text NOT NULL DEFAULT '',
|
||||
|
||||
"group" text NOT NULL DEFAULT 'default',
|
||||
tags text[] NOT NULL DEFAULT ARRAY[]::text[],
|
||||
|
||||
status proxy_status NOT NULL DEFAULT 'unknown',
|
||||
score int NOT NULL DEFAULT 0,
|
||||
latency_ms bigint NOT NULL DEFAULT 0,
|
||||
last_check_at timestamptz,
|
||||
|
||||
fail_count int NOT NULL DEFAULT 0,
|
||||
success_count int NOT NULL DEFAULT 0,
|
||||
|
||||
disabled boolean NOT NULL DEFAULT false,
|
||||
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
|
||||
CONSTRAINT uq_proxy UNIQUE (protocol, host, port, username)
|
||||
);
|
||||
|
||||
-- 常用索引
|
||||
CREATE INDEX idx_proxies_group_status_disabled
|
||||
ON proxies ("group", status, disabled);
|
||||
|
||||
-- tags 查询:tags && ARRAY['a','b']
|
||||
CREATE INDEX idx_proxies_tags_gin
|
||||
ON proxies USING gin (tags);
|
||||
|
||||
-- 可用代理热点查询(可选)
|
||||
CREATE INDEX idx_proxies_alive_fast
|
||||
ON proxies ("group", disabled, score DESC, last_check_at DESC)
|
||||
WHERE status = 'alive';
|
||||
|
||||
-- updated_at 自动维护(可选,触发器)
|
||||
CREATE OR REPLACE FUNCTION touch_updated_at()
|
||||
RETURNS trigger AS $$
|
||||
BEGIN
|
||||
NEW.updated_at = now();
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE TRIGGER trg_touch_updated_at
|
||||
BEFORE UPDATE ON proxies
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION touch_updated_at();
|
||||
```
|
||||
|
||||
### 4.2 RR 游标表 `rr_cursors`
|
||||
|
||||
```sql
|
||||
CREATE TABLE rr_cursors (
|
||||
k text PRIMARY KEY,
|
||||
v bigint NOT NULL DEFAULT 0,
|
||||
updated_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
```
|
||||
|
||||
### 4.3 租约表 `proxy_leases`(推荐)
|
||||
|
||||
```sql
|
||||
CREATE TABLE proxy_leases (
|
||||
lease_id text PRIMARY KEY,
|
||||
proxy_id uuid NOT NULL REFERENCES proxies(id),
|
||||
expire_at timestamptz NOT NULL,
|
||||
|
||||
site text NOT NULL DEFAULT '',
|
||||
"group" text NOT NULL DEFAULT 'default',
|
||||
|
||||
created_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX idx_leases_expire ON proxy_leases(expire_at);
|
||||
```
|
||||
|
||||
### 4.4(可选)测试记录表 `proxy_test_logs`
|
||||
|
||||
如果你需要审计/排障(哪个目标站导致失败),建议加:
|
||||
|
||||
```sql
|
||||
CREATE TABLE proxy_test_logs (
|
||||
id bigserial PRIMARY KEY,
|
||||
proxy_id uuid NOT NULL REFERENCES proxies(id),
|
||||
site text NOT NULL,
|
||||
ok boolean NOT NULL,
|
||||
latency_ms bigint NOT NULL,
|
||||
error_text text NOT NULL DEFAULT '',
|
||||
checked_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX idx_test_logs_proxy_time ON proxy_test_logs(proxy_id, checked_at DESC);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. HTTP API 设计(请求形式 + 契约)
|
||||
|
||||
### 通用约定
|
||||
|
||||
* BasePath:`/v1`
|
||||
* Content-Type:`application/json`(文件上传除外)
|
||||
* 鉴权:建议 `Authorization: Bearer <token>` 或 `X-API-Key: <key>`
|
||||
* 错误返回统一:
|
||||
|
||||
```json
|
||||
{"error":"bad_request","message":"..."}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 5.1 导入(文本粘贴)
|
||||
|
||||
`POST /v1/proxies/import/text`
|
||||
|
||||
**Request**
|
||||
|
||||
```json
|
||||
{
|
||||
"group": "default",
|
||||
"tags": ["batch-2026-01"],
|
||||
"protocol_hint": "auto",
|
||||
"text": "http://user:pass@1.2.3.4:8080\nsocks5://5.6.7.8:1080\n9.9.9.9:3128"
|
||||
}
|
||||
```
|
||||
|
||||
**Response**
|
||||
|
||||
```json
|
||||
{
|
||||
"imported": 120,
|
||||
"duplicated": 30,
|
||||
"invalid": 5,
|
||||
"invalid_items": [
|
||||
{"raw":"bad_line","reason":"parse_failed"}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
支持解析的常见行格式(建议实现):
|
||||
|
||||
* `host:port`
|
||||
* `user:pass@host:port`
|
||||
* `http://user:pass@host:port`
|
||||
* `socks5://host:port`
|
||||
|
||||
---
|
||||
|
||||
### 5.2 导入(文件上传 txt/csv)
|
||||
|
||||
`POST /v1/proxies/import/file`(multipart/form-data)
|
||||
|
||||
**Form fields**
|
||||
|
||||
* `group`: string
|
||||
* `tags`: 逗号分隔(或 tags 可重复)
|
||||
* `type`: `auto|txt|csv`
|
||||
* `file`: 上传文件
|
||||
|
||||
**Response** 同 5.1
|
||||
|
||||
CSV 建议列名:
|
||||
|
||||
* `protocol,host,port,username,password,group,tags`
|
||||
* tags 用 `;` 分隔(例:`a;b;c`)
|
||||
|
||||
---
|
||||
|
||||
### 5.3 测试代理
|
||||
|
||||
`POST /v1/proxies/test`
|
||||
|
||||
**Request**
|
||||
|
||||
```json
|
||||
{
|
||||
"group": "default",
|
||||
"filter": {
|
||||
"status": ["unknown", "alive"],
|
||||
"tags_any": ["batch-2026-01"],
|
||||
"limit": 200
|
||||
},
|
||||
"test_spec": {
|
||||
"url": "https://example.com/",
|
||||
"method": "GET",
|
||||
"timeout_ms": 5000,
|
||||
"expect_status": [200, 301, 302],
|
||||
"expect_contains": ""
|
||||
},
|
||||
"concurrency": 50,
|
||||
"update_store": true,
|
||||
"write_log": false
|
||||
}
|
||||
```
|
||||
|
||||
**Response**
|
||||
|
||||
```json
|
||||
{
|
||||
"summary": {"tested":200,"alive":120,"dead":80},
|
||||
"results": [
|
||||
{"proxy_id":"...","ok":true,"latency_ms":340,"error":""},
|
||||
{"proxy_id":"...","ok":false,"latency_ms":5000,"error":"timeout"}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 5.4 获取下一条可用代理(轮询)
|
||||
|
||||
`GET /v1/proxies/next?group=default&site=https%3A%2F%2Fexample.com&policy=round_robin&tags_any=batch-2026-01`
|
||||
|
||||
**Response**
|
||||
|
||||
```json
|
||||
{
|
||||
"proxy": {
|
||||
"id": "uuid",
|
||||
"protocol": "http",
|
||||
"host": "1.2.3.4",
|
||||
"port": 8080,
|
||||
"username": "user",
|
||||
"password": "pass"
|
||||
},
|
||||
"lease_id": "lease_01H...",
|
||||
"ttl_ms": 60000
|
||||
}
|
||||
```
|
||||
|
||||
> 是否返回 password:建议做配置开关,例如 `RETURN_SECRET=true/false`。
|
||||
|
||||
---
|
||||
|
||||
### 5.5 上报使用结果
|
||||
|
||||
`POST /v1/proxies/report`
|
||||
|
||||
**Request**
|
||||
|
||||
```json
|
||||
{
|
||||
"lease_id": "lease_01H...",
|
||||
"proxy_id": "uuid",
|
||||
"success": false,
|
||||
"error": "403",
|
||||
"latency_ms": 1200
|
||||
}
|
||||
```
|
||||
|
||||
**Response**
|
||||
|
||||
```json
|
||||
{"ok": true}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. Go 预留接口(名称与契约)
|
||||
|
||||
### 6.1 Store(PgSQL 实现)
|
||||
|
||||
```go
|
||||
type ProxyQuery struct {
|
||||
Group string
|
||||
TagsAny []string
|
||||
StatusIn []ProxyStatus
|
||||
OnlyEnabled bool
|
||||
Limit int
|
||||
}
|
||||
|
||||
type InvalidLine struct {
|
||||
Raw string
|
||||
Reason string
|
||||
}
|
||||
|
||||
type ProxyStore interface {
|
||||
// 导入:批量 upsert + 去重统计
|
||||
UpsertMany(ctx context.Context, proxies []Proxy) (imported, duplicated int, invalid []InvalidLine, err error)
|
||||
|
||||
// 查询
|
||||
List(ctx context.Context, q ProxyQuery) ([]Proxy, error)
|
||||
GetByID(ctx context.Context, id string) (*Proxy, error)
|
||||
|
||||
// 写回健康度(测试/上报)
|
||||
UpdateHealth(ctx context.Context, proxyID string, patch HealthPatch) error
|
||||
|
||||
// Round-robin 原子游标:返回 [0, modulo) 的索引
|
||||
NextIndex(ctx context.Context, key string, modulo int) (int, error)
|
||||
|
||||
// lease(推荐)
|
||||
CreateLease(ctx context.Context, lease Lease) error
|
||||
GetLease(ctx context.Context, leaseID string) (*Lease, error)
|
||||
DeleteExpiredLeases(ctx context.Context) (int64, error)
|
||||
|
||||
// 可选:写测试日志
|
||||
InsertTestLog(ctx context.Context, r TestResult, site string) error
|
||||
}
|
||||
```
|
||||
|
||||
### 6.2 Importer
|
||||
|
||||
```go
|
||||
type ImportInput struct {
|
||||
Group string
|
||||
Tags []string
|
||||
ProtocolHint string // "auto"|"http"|"socks5"
|
||||
}
|
||||
|
||||
type ProxyImporter interface {
|
||||
ParseText(ctx context.Context, in ImportInput, text string) (proxies []Proxy, invalid []InvalidLine)
|
||||
ParseCSV(ctx context.Context, in ImportInput, r io.Reader) (proxies []Proxy, invalid []InvalidLine)
|
||||
}
|
||||
```
|
||||
|
||||
### 6.3 Tester
|
||||
|
||||
```go
|
||||
type TestSpec struct {
|
||||
URL string
|
||||
Method string
|
||||
Timeout time.Duration
|
||||
ExpectStatus []int
|
||||
ExpectContains string
|
||||
}
|
||||
|
||||
type TestResult struct {
|
||||
ProxyID string
|
||||
OK bool
|
||||
LatencyMs int64
|
||||
ErrorText string
|
||||
CheckedAt time.Time
|
||||
}
|
||||
|
||||
type ProxyTester interface {
|
||||
TestOne(ctx context.Context, p Proxy, spec TestSpec) TestResult
|
||||
TestBatch(ctx context.Context, proxies []Proxy, spec TestSpec, concurrency int) []TestResult
|
||||
}
|
||||
```
|
||||
|
||||
### 6.4 Selector(分发策略)
|
||||
|
||||
```go
|
||||
type SelectRequest struct {
|
||||
Group string
|
||||
Site string
|
||||
Policy string // "round_robin"|"random"|"weighted"
|
||||
TagsAny []string
|
||||
}
|
||||
|
||||
type Lease struct {
|
||||
LeaseID string
|
||||
Proxy Proxy
|
||||
ExpireAt time.Time
|
||||
Group string
|
||||
Site string
|
||||
}
|
||||
|
||||
type ProxySelector interface {
|
||||
Next(ctx context.Context, req SelectRequest) (*Lease, error)
|
||||
Report(ctx context.Context, leaseID, proxyID string, success bool, latencyMs int64, errText string) error
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 7. PgSQL 关键实现伪代码(Store)
|
||||
|
||||
> 假设使用 `pgx` / `database/sql` 都可。这里用伪代码表达 SQL 要点。
|
||||
|
||||
### 7.1 批量 UpsertMany(导入去重统计)
|
||||
|
||||
**核心 SQL(单条示意)**:用 `(xmax = 0)` 判断是否插入(PG 技巧)
|
||||
|
||||
```sql
|
||||
INSERT INTO proxies (id, protocol, host, port, username, password, "group", tags)
|
||||
VALUES ($1,$2,$3,$4,$5,$6,$7,$8)
|
||||
ON CONFLICT (protocol, host, port, username)
|
||||
DO UPDATE SET
|
||||
password = EXCLUDED.password,
|
||||
"group" = EXCLUDED."group",
|
||||
tags = (
|
||||
SELECT ARRAY(
|
||||
SELECT DISTINCT unnest(proxies.tags || EXCLUDED.tags)
|
||||
)
|
||||
)
|
||||
RETURNING (xmax = 0) AS inserted, id;
|
||||
```
|
||||
|
||||
**Go 伪代码**
|
||||
|
||||
```go
|
||||
func (s *PgStore) UpsertMany(ctx context.Context, proxies []Proxy) (int, int, []InvalidLine, error) {
|
||||
// proxies 参数应已由 importer 过滤掉明显非法的 host/port
|
||||
imported := 0
|
||||
duplicated := 0
|
||||
|
||||
tx := s.db.BeginTx(ctx)
|
||||
defer tx.Rollback()
|
||||
|
||||
for _, p := range proxies {
|
||||
// 执行上面的 INSERT...RETURNING
|
||||
inserted := tx.QueryRow(ctx, sqlUpsert, p.ID, p.Protocol, p.Host, p.Port, p.Username, p.Password, p.Group, p.Tags).ScanBool()
|
||||
if inserted { imported++ } else { duplicated++ }
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil { return 0,0,nil,err }
|
||||
return imported, duplicated, nil, nil
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 7.2 List(查询可用代理)
|
||||
|
||||
```go
|
||||
func (s *PgStore) List(ctx context.Context, q ProxyQuery) ([]Proxy, error) {
|
||||
// SQL 要点:
|
||||
// group = $1
|
||||
// disabled=false(OnlyEnabled)
|
||||
// status IN (...)
|
||||
// tagsAny => tags && $tags
|
||||
// order by score desc, last_check_at desc
|
||||
|
||||
rows := s.db.Query(ctx, sqlList, q.Group, q.StatusIn, q.TagsAny, q.Limit)
|
||||
return ScanProxies(rows), nil
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 7.3 UpdateHealth(写回健康度)
|
||||
|
||||
建议规则(你可调整):
|
||||
|
||||
* success:`score += 1`,`success_count += 1`,`status = alive`,更新延迟与 last_check_at
|
||||
* fail:`score -= 3`,`fail_count += 1`,`status = dead`(或 fail_count 超阈值才 dead)
|
||||
* score 下限可做 clamp(避免无限负)
|
||||
|
||||
```go
|
||||
func (s *PgStore) UpdateHealth(ctx context.Context, proxyID string, patch HealthPatch) error {
|
||||
// 伪 SQL:按 patch 拼接更新字段(或固定一套更新逻辑)
|
||||
// UPDATE proxies SET
|
||||
// status = COALESCE($status, status),
|
||||
// score = score + $delta,
|
||||
// latency_ms = COALESCE($latency, latency_ms),
|
||||
// last_check_at = COALESCE($checked_at, last_check_at),
|
||||
// fail_count = fail_count + $failInc,
|
||||
// success_count = success_count + $successInc
|
||||
// WHERE id=$id;
|
||||
|
||||
return nil
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 7.4 RR 游标 NextIndex(PgSQL 原子自增)
|
||||
|
||||
```sql
|
||||
INSERT INTO rr_cursors (k, v)
|
||||
VALUES ($1, 0)
|
||||
ON CONFLICT (k)
|
||||
DO UPDATE SET v = rr_cursors.v + 1, updated_at = now()
|
||||
RETURNING v;
|
||||
```
|
||||
|
||||
```go
|
||||
func (s *PgStore) NextIndex(ctx context.Context, key string, modulo int) (int, error) {
|
||||
if modulo <= 0 { return 0, ErrBadModulo }
|
||||
v := s.db.QueryRow(ctx, sqlCursor, key).ScanInt64()
|
||||
idx := int(v % int64(modulo))
|
||||
if idx < 0 { idx = -idx }
|
||||
return idx, nil
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 7.5 Lease(推荐)
|
||||
|
||||
```go
|
||||
func (s *PgStore) CreateLease(ctx context.Context, lease Lease) error {
|
||||
// INSERT INTO proxy_leases(lease_id, proxy_id, expire_at, site, group) VALUES ...
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *PgStore) GetLease(ctx context.Context, leaseID string) (*Lease, error) {
|
||||
// SELECT ... FROM proxy_leases WHERE lease_id=$1 AND expire_at > now()
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *PgStore) DeleteExpiredLeases(ctx context.Context) (int64, error) {
|
||||
// DELETE FROM proxy_leases WHERE expire_at <= now()
|
||||
return 0, nil
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 8. Importer 与 Tester 关键伪代码
|
||||
|
||||
### 8.1 Importer:解析文本
|
||||
|
||||
```go
|
||||
func (im *Importer) ParseText(ctx context.Context, in ImportInput, text string) ([]Proxy, []InvalidLine) {
|
||||
lines := SplitLines(text)
|
||||
var out []Proxy
|
||||
var bad []InvalidLine
|
||||
|
||||
for _, raw := range lines {
|
||||
raw = strings.TrimSpace(raw)
|
||||
if raw == "" { continue }
|
||||
|
||||
p, err := ParseProxyLine(raw, in.ProtocolHint)
|
||||
if err != nil {
|
||||
bad = append(bad, InvalidLine{Raw: raw, Reason: "parse_failed"})
|
||||
continue
|
||||
}
|
||||
p.Group = Coalesce(p.Group, in.Group)
|
||||
p.Tags = MergeTags(p.Tags, in.Tags)
|
||||
p.ID = NewUUID()
|
||||
out = append(out, p)
|
||||
}
|
||||
// 可选:应用内再做一次去重(减少 DB 压力)
|
||||
out = Dedup(out)
|
||||
return out, bad
|
||||
}
|
||||
```
|
||||
|
||||
### 8.2 Tester:并发测试(worker pool)
|
||||
|
||||
```go
|
||||
func (t *HTTPTester) TestBatch(ctx context.Context, proxies []Proxy, spec TestSpec, concurrency int) []TestResult {
|
||||
jobs := make(chan Proxy)
|
||||
results := make(chan TestResult)
|
||||
|
||||
for i := 0; i < concurrency; i++ {
|
||||
go func() {
|
||||
for p := range jobs {
|
||||
results <- t.TestOne(ctx, p, spec)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
go func() {
|
||||
defer close(jobs)
|
||||
for _, p := range proxies { jobs <- p }
|
||||
}()
|
||||
|
||||
out := make([]TestResult, 0, len(proxies))
|
||||
for i := 0; i < len(proxies); i++ {
|
||||
out = append(out, <-results)
|
||||
}
|
||||
return out
|
||||
}
|
||||
```
|
||||
|
||||
(实现细节提醒)
|
||||
|
||||
* HTTP 代理:`http.Transport{ Proxy: http.ProxyURL(proxyURL) }`
|
||||
* SOCKS5:可用 `golang.org/x/net/proxy` 创建 dialer,再塞给 Transport 的 DialContext(实现时注意超时与连接复用)
|
||||
|
||||
---
|
||||
|
||||
## 9. Selector(轮询分发)关键伪代码
|
||||
|
||||
```go
|
||||
func (s *Selector) Next(ctx context.Context, req SelectRequest) (*Lease, error) {
|
||||
policy := Coalesce(req.Policy, "round_robin")
|
||||
|
||||
proxies, err := s.store.List(ctx, ProxyQuery{
|
||||
Group: req.Group,
|
||||
TagsAny: req.TagsAny,
|
||||
StatusIn: []ProxyStatus{StatusAlive},
|
||||
OnlyEnabled: true,
|
||||
Limit: 5000,
|
||||
})
|
||||
if err != nil { return nil, err }
|
||||
if len(proxies) == 0 { return nil, ErrNoProxy }
|
||||
|
||||
var chosen Proxy
|
||||
switch policy {
|
||||
case "round_robin":
|
||||
key := "rr:" + req.Group + ":" + NormalizeSite(req.Site)
|
||||
idx, err := s.store.NextIndex(ctx, key, len(proxies))
|
||||
if err != nil { return nil, err }
|
||||
chosen = proxies[idx]
|
||||
case "random":
|
||||
chosen = proxies[rand.Intn(len(proxies))]
|
||||
case "weighted":
|
||||
chosen = WeightedPickByScore(proxies)
|
||||
default:
|
||||
return nil, ErrBadPolicy
|
||||
}
|
||||
|
||||
// lease
|
||||
lease := Lease{
|
||||
LeaseID: NewLeaseID(),
|
||||
Proxy: chosen,
|
||||
Group: req.Group,
|
||||
Site: req.Site,
|
||||
ExpireAt: time.Now().Add(60 * time.Second),
|
||||
}
|
||||
_ = s.store.CreateLease(ctx, lease) // 推荐:失败也可降级不存(看你需要)
|
||||
|
||||
return &lease, nil
|
||||
}
|
||||
|
||||
func (s *Selector) Report(ctx context.Context, leaseID, proxyID string, success bool, latencyMs int64, errText string) error {
|
||||
// 可选:校验 lease 存在且未过期
|
||||
// l, _ := s.store.GetLease(ctx, leaseID)
|
||||
|
||||
nowMs := time.Now().UnixMilli()
|
||||
if success {
|
||||
st := StatusAlive
|
||||
return s.store.UpdateHealth(ctx, proxyID, HealthPatch{
|
||||
Status: &st, ScoreDelta: +1, SuccessInc: 1,
|
||||
LatencyMs: &latencyMs, CheckedAtMs: &nowMs,
|
||||
})
|
||||
}
|
||||
st := StatusDead
|
||||
return s.store.UpdateHealth(ctx, proxyID, HealthPatch{
|
||||
Status: &st, ScoreDelta: -3, FailInc: 1,
|
||||
CheckedAtMs: &nowMs,
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 10. Handler(API 层)伪代码示例
|
||||
|
||||
### 10.1 `/v1/proxies/next`
|
||||
|
||||
```go
|
||||
func HandleNext(sel ProxySelector) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
req := SelectRequest{
|
||||
Group: r.URL.Query().Get("group"),
|
||||
Site: r.URL.Query().Get("site"),
|
||||
Policy: r.URL.Query().Get("policy"),
|
||||
TagsAny: SplitCSV(r.URL.Query().Get("tags_any")),
|
||||
}
|
||||
if req.Group == "" { req.Group = "default" }
|
||||
|
||||
lease, err := sel.Next(r.Context(), req)
|
||||
if err != nil { WriteErr(w, 404, err); return }
|
||||
|
||||
WriteJSON(w, 200, map[string]any{
|
||||
"proxy": map[string]any{
|
||||
"id": lease.Proxy.ID,
|
||||
"protocol": lease.Proxy.Protocol,
|
||||
"host": lease.Proxy.Host,
|
||||
"port": lease.Proxy.Port,
|
||||
"username": lease.Proxy.Username,
|
||||
"password": lease.Proxy.Password, // 建议可配置是否返回
|
||||
},
|
||||
"lease_id": lease.LeaseID,
|
||||
"ttl_ms": int64(time.Until(lease.ExpireAt) / time.Millisecond),
|
||||
})
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 11. 安全与稳定性建议(强烈建议你落地)
|
||||
|
||||
### 11.1 SSRF 防护(测试目标 URL)
|
||||
|
||||
`/proxies/test` 允许指定 URL,必须做:
|
||||
|
||||
* 仅允许 `http/https`
|
||||
* 禁止解析到内网/私网 IP(10/8、172.16/12、192.168/16、127/8、169.254/16、::1、fc00::/7 等)
|
||||
* 可选:目标域名 allowlist(最稳妥)
|
||||
* 限制端口(80/443/自定义)
|
||||
|
||||
### 11.2 鉴权与审计
|
||||
|
||||
* 所有接口建议加 `API Key` 或 `JWT`
|
||||
* 对导入/测试/分发/上报做访问日志与速率限制(尤其 `/next`)
|
||||
|
||||
### 11.3 测试与分发的资源控制
|
||||
|
||||
* concurrency 上限(例如 <= 200)
|
||||
* 单次测试 limit 上限(例如 <= 2000)
|
||||
* HTTP 超时、TLS 握手超时、最大响应体大小(ReadLimited)
|
||||
* 为 `/next` 做简单缓存(例如缓存 alive 列表 5~30 秒)以减轻 DB 压力(后续也方便升级 Redis)
|
||||
|
||||
---
|
||||
|
||||
## 12. 关键流程(端到端)
|
||||
|
||||
1. 导入代理
|
||||
`POST /v1/proxies/import/text` 或 `/import/file` → UpsertMany → proxies 表
|
||||
|
||||
2. 测试代理
|
||||
`POST /v1/proxies/test` → List(unknown/alive) → Tester 并发测试 → UpdateHealth(可选 InsertTestLog)
|
||||
|
||||
3. 分发代理
|
||||
`GET /v1/proxies/next` → List(alive) → NextIndex(rr_key) → chosen → CreateLease → 返回
|
||||
|
||||
4. 上报结果
|
||||
`POST /v1/proxies/report` → UpdateHealth(成功加分,失败扣分/标 dead)
|
||||
|
||||
---
|
||||
|
||||
7
envexmaple
Normal file
7
envexmaple
Normal file
@@ -0,0 +1,7 @@
|
||||
DATABASE_URL=postgres://postgres:psw@localhost:5432/proxyrotator
|
||||
LISTEN_ADDR=0.0.0.0:9987
|
||||
API_KEY=your-secret-key
|
||||
RETURN_SECRET=true
|
||||
MAX_CONCURRENCY=200
|
||||
MAX_TEST_LIMIT=2000
|
||||
LEASE_TTL=60s
|
||||
18
go.mod
Normal file
18
go.mod
Normal file
@@ -0,0 +1,18 @@
|
||||
module proxyrotator
|
||||
|
||||
go 1.25.5
|
||||
|
||||
require (
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/jackc/pgx/v5 v5.8.0
|
||||
golang.org/x/net v0.48.0
|
||||
gopkg.in/telebot.v3 v3.3.8
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
||||
golang.org/x/sync v0.19.0 // indirect
|
||||
golang.org/x/text v0.32.0 // indirect
|
||||
)
|
||||
872
go.sum
Normal file
872
go.sum
Normal file
@@ -0,0 +1,872 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
|
||||
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
|
||||
cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
|
||||
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
|
||||
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
|
||||
cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
|
||||
cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
|
||||
cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
|
||||
cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
|
||||
cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk=
|
||||
cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
|
||||
cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc=
|
||||
cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
|
||||
cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI=
|
||||
cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk=
|
||||
cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY=
|
||||
cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg=
|
||||
cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8=
|
||||
cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0=
|
||||
cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY=
|
||||
cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM=
|
||||
cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY=
|
||||
cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ=
|
||||
cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI=
|
||||
cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4=
|
||||
cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc=
|
||||
cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA=
|
||||
cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A=
|
||||
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
|
||||
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
|
||||
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
|
||||
cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
|
||||
cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
|
||||
cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
|
||||
cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow=
|
||||
cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM=
|
||||
cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M=
|
||||
cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s=
|
||||
cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU=
|
||||
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
|
||||
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
|
||||
cloud.google.com/go/firestore v1.6.1/go.mod h1:asNXNOzBdyVQmEU+ggO8UPodTkEVFW5Qx+rwHnAz+EY=
|
||||
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
||||
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
|
||||
cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
|
||||
cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
|
||||
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
||||
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
|
||||
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
|
||||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
||||
github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc=
|
||||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
|
||||
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
|
||||
github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po=
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
|
||||
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
|
||||
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
|
||||
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
|
||||
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/goccy/go-yaml v1.9.5/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
||||
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
|
||||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||
github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk=
|
||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||
github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0=
|
||||
github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM=
|
||||
github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM=
|
||||
github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM=
|
||||
github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c=
|
||||
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
||||
github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0=
|
||||
github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
|
||||
github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
|
||||
github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
|
||||
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
|
||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||
github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA=
|
||||
github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
|
||||
github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
|
||||
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
|
||||
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
|
||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||
github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc=
|
||||
github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE=
|
||||
github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4=
|
||||
github.com/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||
github.com/jackc/pgx/v5 v5.8.0 h1:TYPDoleBBme0xGSAX3/+NujXXtpZn9HBONkQC7IEZSo=
|
||||
github.com/jackc/pgx/v5 v5.8.0/go.mod h1:QVeDInX2m9VyzvNeiCJVjCkNFqzsNb43204HshNSZKw=
|
||||
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
||||
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
|
||||
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
|
||||
github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI=
|
||||
github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
||||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
||||
github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
|
||||
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/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
|
||||
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||
github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
|
||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
||||
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/sagikazarmark/crypt v0.6.0/go.mod h1:U8+INwJo3nBv1m6A/8OBXAq7Jnpspk5AxSgDyEQcea8=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo=
|
||||
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
|
||||
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.13.0/go.mod h1:Icm2xNL3/8uyh/wFuB1jI7TiTNKp8632Nwegu+zgdYw=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
|
||||
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A=
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.4/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
|
||||
go.etcd.io/etcd/client/v2 v2.305.4/go.mod h1:Ud+VUwIi9/uQHOMA+4ekToJ12lTxlv0zB/+DHwTGEbU=
|
||||
go.etcd.io/etcd/client/v3 v3.5.4/go.mod h1:ZaRkVgBZC+L+dLCjTcF1hRXpgZXQPOvnA/Ak/gq3kiY=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
||||
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
|
||||
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
|
||||
golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
|
||||
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8=
|
||||
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
|
||||
golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
|
||||
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
|
||||
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
||||
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
|
||||
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
||||
golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
||||
golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
|
||||
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE=
|
||||
golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
|
||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
||||
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
||||
google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
||||
google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
|
||||
google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
|
||||
google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg=
|
||||
google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE=
|
||||
google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8=
|
||||
google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU=
|
||||
google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94=
|
||||
google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo=
|
||||
google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4=
|
||||
google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw=
|
||||
google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU=
|
||||
google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k=
|
||||
google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE=
|
||||
google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE=
|
||||
google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI=
|
||||
google.golang.org/api v0.59.0/go.mod h1:sT2boj7M9YJxZzgeZqXogmhfmRWDtPzT31xkieUbuZU=
|
||||
google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I=
|
||||
google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo=
|
||||
google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g=
|
||||
google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA=
|
||||
google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8=
|
||||
google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs=
|
||||
google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA=
|
||||
google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw=
|
||||
google.golang.org/api v0.81.0/go.mod h1:FA6Mb/bZxj706H2j+j2d6mHEEaHBmbbWnkfvmorOCko=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
||||
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
|
||||
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
|
||||
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A=
|
||||
google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A=
|
||||
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
|
||||
google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
|
||||
google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
|
||||
google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24=
|
||||
google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k=
|
||||
google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k=
|
||||
google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48=
|
||||
google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48=
|
||||
google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w=
|
||||
google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
|
||||
google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
|
||||
google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
|
||||
google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
|
||||
google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
|
||||
google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20211028162531-8db9c33dc351/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI=
|
||||
google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI=
|
||||
google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI=
|
||||
google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI=
|
||||
google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E=
|
||||
google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo=
|
||||
google.golang.org/genproto v0.0.0-20220413183235-5e96e2839df9/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo=
|
||||
google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo=
|
||||
google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo=
|
||||
google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo=
|
||||
google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4=
|
||||
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
|
||||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||
google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8=
|
||||
google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
||||
google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
||||
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
||||
google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE=
|
||||
google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE=
|
||||
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
|
||||
google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
|
||||
google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
|
||||
google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ=
|
||||
google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
|
||||
google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/telebot.v3 v3.3.8 h1:uVDGjak9l824FN9YARWUHMsiNZnlohAVwUycw21k6t8=
|
||||
gopkg.in/telebot.v3 v3.3.8/go.mod h1:1mlbqcLTVSfK9dx7fdp+Nb5HZsy4LLPtpZTKmwhwtzM=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||
643
internal/api/handlers.go
Normal file
643
internal/api/handlers.go
Normal file
@@ -0,0 +1,643 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"proxyrotator/internal/config"
|
||||
"proxyrotator/internal/importer"
|
||||
"proxyrotator/internal/model"
|
||||
"proxyrotator/internal/security"
|
||||
"proxyrotator/internal/selector"
|
||||
"proxyrotator/internal/store"
|
||||
"proxyrotator/internal/tester"
|
||||
)
|
||||
|
||||
// Handlers API 处理器集合
|
||||
type Handlers struct {
|
||||
store store.ProxyStore
|
||||
importer *importer.Importer
|
||||
tester *tester.HTTPTester
|
||||
selector *selector.Selector
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
// NewHandlers 创建处理器
|
||||
func NewHandlers(
|
||||
store store.ProxyStore,
|
||||
importer *importer.Importer,
|
||||
tester *tester.HTTPTester,
|
||||
selector *selector.Selector,
|
||||
cfg *config.Config,
|
||||
) *Handlers {
|
||||
return &Handlers{
|
||||
store: store,
|
||||
importer: importer,
|
||||
tester: tester,
|
||||
selector: selector,
|
||||
cfg: cfg,
|
||||
}
|
||||
}
|
||||
|
||||
// HandleImportText 文本导入处理器
|
||||
// POST /v1/proxies/import/text
|
||||
func (h *Handlers) HandleImportText(w http.ResponseWriter, r *http.Request) {
|
||||
var req model.ImportTextRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", "invalid JSON body")
|
||||
return
|
||||
}
|
||||
|
||||
if req.Text == "" {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", "text is required")
|
||||
return
|
||||
}
|
||||
|
||||
input := model.ImportInput{
|
||||
Group: coalesce(req.Group, "default"),
|
||||
Tags: req.Tags,
|
||||
ProtocolHint: req.ProtocolHint,
|
||||
}
|
||||
|
||||
proxies, invalid := h.importer.ParseText(r.Context(), input, req.Text)
|
||||
|
||||
imported, duplicated := 0, 0
|
||||
if len(proxies) > 0 {
|
||||
var err error
|
||||
imported, duplicated, err = h.store.UpsertMany(r.Context(), proxies)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, "internal_error", err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, model.ImportResult{
|
||||
Imported: imported,
|
||||
Duplicated: duplicated,
|
||||
Invalid: len(invalid),
|
||||
InvalidItems: invalid,
|
||||
})
|
||||
}
|
||||
|
||||
// HandleImportFile 文件上传导入处理器
|
||||
// POST /v1/proxies/import/file
|
||||
func (h *Handlers) HandleImportFile(w http.ResponseWriter, r *http.Request) {
|
||||
if err := r.ParseMultipartForm(10 << 20); err != nil { // 10MB 限制
|
||||
writeError(w, http.StatusBadRequest, "bad_request", "failed to parse multipart form")
|
||||
return
|
||||
}
|
||||
|
||||
file, header, err := r.FormFile("file")
|
||||
if err != nil {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", "file is required")
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
group := coalesce(r.FormValue("group"), "default")
|
||||
tagsStr := r.FormValue("tags")
|
||||
var tags []string
|
||||
if tagsStr != "" {
|
||||
tags = strings.Split(tagsStr, ",")
|
||||
for i := range tags {
|
||||
tags[i] = strings.TrimSpace(tags[i])
|
||||
}
|
||||
}
|
||||
|
||||
input := model.ImportInput{
|
||||
Group: group,
|
||||
Tags: tags,
|
||||
ProtocolHint: r.FormValue("protocol_hint"),
|
||||
}
|
||||
|
||||
// 读取文件内容
|
||||
content, err := io.ReadAll(file)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, "internal_error", "failed to read file")
|
||||
return
|
||||
}
|
||||
|
||||
var proxies []model.Proxy
|
||||
var invalid []model.InvalidLine
|
||||
|
||||
// 根据文件类型解析
|
||||
fileType := r.FormValue("type")
|
||||
if fileType == "" {
|
||||
// 根据文件名推断
|
||||
if strings.HasSuffix(strings.ToLower(header.Filename), ".csv") {
|
||||
fileType = "csv"
|
||||
} else {
|
||||
fileType = "txt"
|
||||
}
|
||||
}
|
||||
|
||||
if fileType == "csv" {
|
||||
proxies, invalid = h.importer.ParseCSV(r.Context(), input, strings.NewReader(string(content)))
|
||||
} else {
|
||||
proxies, invalid = h.importer.ParseText(r.Context(), input, string(content))
|
||||
}
|
||||
|
||||
imported, duplicated := 0, 0
|
||||
if len(proxies) > 0 {
|
||||
imported, duplicated, err = h.store.UpsertMany(r.Context(), proxies)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, "internal_error", err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, model.ImportResult{
|
||||
Imported: imported,
|
||||
Duplicated: duplicated,
|
||||
Invalid: len(invalid),
|
||||
InvalidItems: invalid,
|
||||
})
|
||||
}
|
||||
|
||||
// HandleTest 测试代理处理器
|
||||
// POST /v1/proxies/test
|
||||
func (h *Handlers) HandleTest(w http.ResponseWriter, r *http.Request) {
|
||||
var req model.TestRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", "invalid JSON body")
|
||||
return
|
||||
}
|
||||
|
||||
// SSRF 防护
|
||||
if req.TestSpec.URL == "" {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", "test_spec.url is required")
|
||||
return
|
||||
}
|
||||
if err := security.ValidateTestURL(req.TestSpec.URL); err != nil {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 限制并发数
|
||||
concurrency := req.Concurrency
|
||||
if concurrency <= 0 {
|
||||
concurrency = 50
|
||||
}
|
||||
if concurrency > h.cfg.MaxConcurrency {
|
||||
concurrency = h.cfg.MaxConcurrency
|
||||
}
|
||||
|
||||
// 限制测试数量
|
||||
limit := req.Filter.Limit
|
||||
if limit <= 0 || limit > h.cfg.MaxTestLimit {
|
||||
limit = h.cfg.MaxTestLimit
|
||||
}
|
||||
|
||||
// 构建查询条件
|
||||
var statusIn []model.ProxyStatus
|
||||
for _, s := range req.Filter.Status {
|
||||
statusIn = append(statusIn, model.ProxyStatus(s))
|
||||
}
|
||||
if len(statusIn) == 0 {
|
||||
statusIn = []model.ProxyStatus{model.StatusUnknown, model.StatusAlive}
|
||||
}
|
||||
|
||||
proxies, err := h.store.List(r.Context(), model.ProxyQuery{
|
||||
Group: coalesce(req.Group, "default"),
|
||||
TagsAny: req.Filter.TagsAny,
|
||||
StatusIn: statusIn,
|
||||
OnlyEnabled: true,
|
||||
Limit: limit,
|
||||
})
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, "internal_error", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if len(proxies) == 0 {
|
||||
writeJSON(w, http.StatusOK, model.TestBatchResult{
|
||||
Summary: model.TestSummary{},
|
||||
Results: []model.TestResult{},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 构建测试规格
|
||||
timeout := time.Duration(req.TestSpec.TimeoutMs) * time.Millisecond
|
||||
if timeout <= 0 {
|
||||
timeout = 5 * time.Second
|
||||
}
|
||||
|
||||
spec := model.TestSpec{
|
||||
URL: req.TestSpec.URL,
|
||||
Method: coalesce(req.TestSpec.Method, "GET"),
|
||||
Timeout: timeout,
|
||||
ExpectStatus: req.TestSpec.ExpectStatus,
|
||||
ExpectContains: req.TestSpec.ExpectContains,
|
||||
}
|
||||
|
||||
// 执行测试
|
||||
results := h.tester.TestBatch(r.Context(), proxies, spec, concurrency)
|
||||
|
||||
// 统计结果
|
||||
summary := model.TestSummary{Tested: len(results)}
|
||||
for _, result := range results {
|
||||
if result.OK {
|
||||
summary.Alive++
|
||||
} else {
|
||||
summary.Dead++
|
||||
}
|
||||
|
||||
// 更新数据库
|
||||
if req.UpdateStore {
|
||||
now := result.CheckedAt
|
||||
if result.OK {
|
||||
status := model.StatusAlive
|
||||
_ = h.store.UpdateHealth(r.Context(), result.ProxyID, model.HealthPatch{
|
||||
Status: &status,
|
||||
ScoreDelta: 1,
|
||||
SuccessInc: 1,
|
||||
LatencyMs: &result.LatencyMs,
|
||||
CheckedAt: &now,
|
||||
})
|
||||
} else {
|
||||
status := model.StatusDead
|
||||
_ = h.store.UpdateHealth(r.Context(), result.ProxyID, model.HealthPatch{
|
||||
Status: &status,
|
||||
ScoreDelta: -3,
|
||||
FailInc: 1,
|
||||
CheckedAt: &now,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 写入测试日志
|
||||
if req.WriteLog {
|
||||
_ = h.store.InsertTestLog(r.Context(), result, req.TestSpec.URL)
|
||||
}
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, model.TestBatchResult{
|
||||
Summary: summary,
|
||||
Results: results,
|
||||
})
|
||||
}
|
||||
|
||||
// HandleNext 获取下一个可用代理
|
||||
// GET /v1/proxies/next
|
||||
func (h *Handlers) HandleNext(w http.ResponseWriter, r *http.Request) {
|
||||
req := model.SelectRequest{
|
||||
Group: coalesce(r.URL.Query().Get("group"), "default"),
|
||||
Site: r.URL.Query().Get("site"),
|
||||
Policy: r.URL.Query().Get("policy"),
|
||||
TagsAny: splitCSV(r.URL.Query().Get("tags_any")),
|
||||
}
|
||||
|
||||
lease, err := h.selector.Next(r.Context(), req)
|
||||
if err != nil {
|
||||
if err == model.ErrNoProxy {
|
||||
writeError(w, http.StatusNotFound, "not_found", "no available proxy")
|
||||
return
|
||||
}
|
||||
if err == model.ErrBadPolicy {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", "invalid policy")
|
||||
return
|
||||
}
|
||||
writeError(w, http.StatusInternalServerError, "internal_error", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := model.NextProxyResponse{
|
||||
Proxy: model.ProxyInfo{
|
||||
ID: lease.Proxy.ID,
|
||||
Protocol: lease.Proxy.Protocol,
|
||||
Host: lease.Proxy.Host,
|
||||
Port: lease.Proxy.Port,
|
||||
},
|
||||
LeaseID: lease.LeaseID,
|
||||
TTLMs: time.Until(lease.ExpireAt).Milliseconds(),
|
||||
}
|
||||
|
||||
// 根据配置决定是否返回凭证
|
||||
if h.cfg.ReturnSecret {
|
||||
resp.Proxy.Username = lease.Proxy.Username
|
||||
resp.Proxy.Password = lease.Proxy.Password
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// HandleReport 上报使用结果
|
||||
// POST /v1/proxies/report
|
||||
func (h *Handlers) HandleReport(w http.ResponseWriter, r *http.Request) {
|
||||
var req model.ReportRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", "invalid JSON body")
|
||||
return
|
||||
}
|
||||
|
||||
if req.ProxyID == "" {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", "proxy_id is required")
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.selector.Report(r.Context(), req.LeaseID, req.ProxyID, req.Success, req.LatencyMs, req.Error); err != nil {
|
||||
writeError(w, http.StatusInternalServerError, "internal_error", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, map[string]bool{"ok": true})
|
||||
}
|
||||
|
||||
// HandleListProxies 列出代理
|
||||
// GET /v1/proxies
|
||||
func (h *Handlers) HandleListProxies(w http.ResponseWriter, r *http.Request) {
|
||||
query := r.URL.Query()
|
||||
|
||||
// 解析分页参数
|
||||
offset, _ := strconv.Atoi(query.Get("offset"))
|
||||
limit, _ := strconv.Atoi(query.Get("limit"))
|
||||
if limit <= 0 {
|
||||
limit = 20
|
||||
}
|
||||
if limit > 100 {
|
||||
limit = 100
|
||||
}
|
||||
|
||||
// 解析过滤参数
|
||||
var statusIn []model.ProxyStatus
|
||||
if statusStr := query.Get("status"); statusStr != "" {
|
||||
for _, s := range strings.Split(statusStr, ",") {
|
||||
statusIn = append(statusIn, model.ProxyStatus(strings.TrimSpace(s)))
|
||||
}
|
||||
}
|
||||
|
||||
q := model.ProxyListQuery{
|
||||
Group: query.Get("group"),
|
||||
TagsAny: splitCSV(query.Get("tags")),
|
||||
StatusIn: statusIn,
|
||||
OnlyEnabled: query.Get("only_enabled") == "true",
|
||||
Offset: offset,
|
||||
Limit: limit,
|
||||
}
|
||||
|
||||
proxies, total, err := h.store.ListPaginated(r.Context(), q)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, "internal_error", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, model.ProxyListResponse{
|
||||
Data: proxies,
|
||||
Total: total,
|
||||
Offset: offset,
|
||||
Limit: limit,
|
||||
})
|
||||
}
|
||||
|
||||
// HandleGetProxy 获取单个代理
|
||||
// GET /v1/proxies/{id}
|
||||
func (h *Handlers) HandleGetProxy(w http.ResponseWriter, r *http.Request) {
|
||||
id := r.PathValue("id")
|
||||
if id == "" {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", "proxy id is required")
|
||||
return
|
||||
}
|
||||
|
||||
proxy, err := h.store.GetByID(r.Context(), id)
|
||||
if err != nil {
|
||||
if err == model.ErrProxyNotFound {
|
||||
writeError(w, http.StatusNotFound, "not_found", "proxy not found")
|
||||
return
|
||||
}
|
||||
writeError(w, http.StatusInternalServerError, "internal_error", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, proxy)
|
||||
}
|
||||
|
||||
// HandleDeleteProxy 删除单个代理
|
||||
// DELETE /v1/proxies/{id}
|
||||
func (h *Handlers) HandleDeleteProxy(w http.ResponseWriter, r *http.Request) {
|
||||
id := r.PathValue("id")
|
||||
if id == "" {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", "proxy id is required")
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.store.Delete(r.Context(), id); err != nil {
|
||||
if err == model.ErrProxyNotFound {
|
||||
writeError(w, http.StatusNotFound, "not_found", "proxy not found")
|
||||
return
|
||||
}
|
||||
writeError(w, http.StatusInternalServerError, "internal_error", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, map[string]bool{"ok": true})
|
||||
}
|
||||
|
||||
// HandleBulkDeleteProxies 批量删除代理
|
||||
// DELETE /v1/proxies
|
||||
func (h *Handlers) HandleBulkDeleteProxies(w http.ResponseWriter, r *http.Request) {
|
||||
var req model.BulkDeleteRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", "invalid JSON body")
|
||||
return
|
||||
}
|
||||
|
||||
deleted, err := h.store.DeleteMany(r.Context(), req)
|
||||
if err != nil {
|
||||
if err == model.ErrBulkDeleteEmpty {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", err.Error())
|
||||
return
|
||||
}
|
||||
writeError(w, http.StatusInternalServerError, "internal_error", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, model.BulkDeleteResponse{Deleted: int(deleted)})
|
||||
}
|
||||
|
||||
// HandleUpdateProxy 更新代理
|
||||
// PATCH /v1/proxies/{id}
|
||||
func (h *Handlers) HandleUpdateProxy(w http.ResponseWriter, r *http.Request) {
|
||||
id := r.PathValue("id")
|
||||
if id == "" {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", "proxy id is required")
|
||||
return
|
||||
}
|
||||
|
||||
var patch model.ProxyPatch
|
||||
if err := json.NewDecoder(r.Body).Decode(&patch); err != nil {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", "invalid JSON body")
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.store.Update(r.Context(), id, patch); err != nil {
|
||||
if err == model.ErrProxyNotFound {
|
||||
writeError(w, http.StatusNotFound, "not_found", "proxy not found")
|
||||
return
|
||||
}
|
||||
if err == model.ErrInvalidPatch {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", err.Error())
|
||||
return
|
||||
}
|
||||
writeError(w, http.StatusInternalServerError, "internal_error", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 返回更新后的代理
|
||||
proxy, err := h.store.GetByID(r.Context(), id)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, "internal_error", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, proxy)
|
||||
}
|
||||
|
||||
// HandleTestSingleProxy 测试单个代理
|
||||
// POST /v1/proxies/{id}/test
|
||||
func (h *Handlers) HandleTestSingleProxy(w http.ResponseWriter, r *http.Request) {
|
||||
id := r.PathValue("id")
|
||||
if id == "" {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", "proxy id is required")
|
||||
return
|
||||
}
|
||||
|
||||
var req model.SingleTestRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", "invalid JSON body")
|
||||
return
|
||||
}
|
||||
|
||||
// SSRF 防护
|
||||
if req.URL == "" {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", "url is required")
|
||||
return
|
||||
}
|
||||
if err := security.ValidateTestURL(req.URL); err != nil {
|
||||
writeError(w, http.StatusBadRequest, "bad_request", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 获取代理
|
||||
proxy, err := h.store.GetByID(r.Context(), id)
|
||||
if err != nil {
|
||||
if err == model.ErrProxyNotFound {
|
||||
writeError(w, http.StatusNotFound, "not_found", "proxy not found")
|
||||
return
|
||||
}
|
||||
writeError(w, http.StatusInternalServerError, "internal_error", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 构建测试规格
|
||||
timeout := time.Duration(req.TimeoutMs) * time.Millisecond
|
||||
if timeout <= 0 {
|
||||
timeout = 5 * time.Second
|
||||
}
|
||||
|
||||
spec := model.TestSpec{
|
||||
URL: req.URL,
|
||||
Method: coalesce(req.Method, "GET"),
|
||||
Timeout: timeout,
|
||||
ExpectStatus: req.ExpectStatus,
|
||||
ExpectContains: req.ExpectContains,
|
||||
}
|
||||
|
||||
// 执行测试
|
||||
results := h.tester.TestBatch(r.Context(), []model.Proxy{*proxy}, spec, 1)
|
||||
if len(results) == 0 {
|
||||
writeError(w, http.StatusInternalServerError, "internal_error", "test failed")
|
||||
return
|
||||
}
|
||||
|
||||
result := results[0]
|
||||
|
||||
// 更新数据库
|
||||
if req.UpdateStore {
|
||||
now := result.CheckedAt
|
||||
if result.OK {
|
||||
status := model.StatusAlive
|
||||
_ = h.store.UpdateHealth(r.Context(), result.ProxyID, model.HealthPatch{
|
||||
Status: &status,
|
||||
ScoreDelta: 1,
|
||||
SuccessInc: 1,
|
||||
LatencyMs: &result.LatencyMs,
|
||||
CheckedAt: &now,
|
||||
})
|
||||
} else {
|
||||
status := model.StatusDead
|
||||
_ = h.store.UpdateHealth(r.Context(), result.ProxyID, model.HealthPatch{
|
||||
Status: &status,
|
||||
ScoreDelta: -3,
|
||||
FailInc: 1,
|
||||
CheckedAt: &now,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 写入测试日志
|
||||
if req.WriteLog {
|
||||
_ = h.store.InsertTestLog(r.Context(), result, req.URL)
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, result)
|
||||
}
|
||||
|
||||
// HandleGetStats 获取代理统计信息
|
||||
// GET /v1/proxies/stats
|
||||
func (h *Handlers) HandleGetStats(w http.ResponseWriter, r *http.Request) {
|
||||
stats, err := h.store.GetStats(r.Context())
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, "internal_error", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
writeJSON(w, http.StatusOK, stats)
|
||||
}
|
||||
|
||||
// writeJSON 写入 JSON 响应
|
||||
func writeJSON(w http.ResponseWriter, status int, data any) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(status)
|
||||
json.NewEncoder(w).Encode(data)
|
||||
}
|
||||
|
||||
// writeError 写入错误响应
|
||||
func writeError(w http.ResponseWriter, status int, code, message string) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(status)
|
||||
json.NewEncoder(w).Encode(map[string]string{
|
||||
"error": code,
|
||||
"message": message,
|
||||
})
|
||||
}
|
||||
|
||||
// coalesce 返回第一个非空字符串
|
||||
func coalesce(values ...string) string {
|
||||
for _, v := range values {
|
||||
if v != "" {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// splitCSV 分割逗号分隔的字符串
|
||||
func splitCSV(s string) []string {
|
||||
if s == "" {
|
||||
return nil
|
||||
}
|
||||
parts := strings.Split(s, ",")
|
||||
result := make([]string, 0, len(parts))
|
||||
for _, p := range parts {
|
||||
p = strings.TrimSpace(p)
|
||||
if p != "" {
|
||||
result = append(result, p)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
136
internal/api/middleware.go
Normal file
136
internal/api/middleware.go
Normal file
@@ -0,0 +1,136 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// LoggingMiddleware 请求日志中间件
|
||||
func LoggingMiddleware(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
start := time.Now()
|
||||
|
||||
// 包装 ResponseWriter 以获取状态码
|
||||
wrapped := &responseWriter{ResponseWriter: w, statusCode: http.StatusOK}
|
||||
|
||||
next.ServeHTTP(wrapped, r)
|
||||
|
||||
slog.Info("request",
|
||||
"method", r.Method,
|
||||
"path", r.URL.Path,
|
||||
"status", wrapped.statusCode,
|
||||
"duration_ms", time.Since(start).Milliseconds(),
|
||||
"remote_addr", r.RemoteAddr,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// AuthMiddleware API Key 鉴权中间件
|
||||
func AuthMiddleware(next http.Handler, apiKey string) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// 如果没有配置 API Key,跳过鉴权
|
||||
if apiKey == "" {
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
// 检查 Authorization 头
|
||||
auth := r.Header.Get("Authorization")
|
||||
if auth != "" {
|
||||
if strings.HasPrefix(auth, "Bearer ") {
|
||||
token := strings.TrimPrefix(auth, "Bearer ")
|
||||
if token == apiKey {
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 X-API-Key 头
|
||||
key := r.Header.Get("X-API-Key")
|
||||
if key == apiKey {
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
http.Error(w, `{"error":"unauthorized","message":"invalid or missing API key"}`, http.StatusUnauthorized)
|
||||
})
|
||||
}
|
||||
|
||||
// RateLimitMiddleware 简单限流中间件(基于滑动窗口)
|
||||
type RateLimitMiddleware struct {
|
||||
requests map[string][]time.Time
|
||||
limit int
|
||||
window time.Duration
|
||||
}
|
||||
|
||||
// NewRateLimitMiddleware 创建限流中间件
|
||||
func NewRateLimitMiddleware(limit int, window time.Duration) *RateLimitMiddleware {
|
||||
return &RateLimitMiddleware{
|
||||
requests: make(map[string][]time.Time),
|
||||
limit: limit,
|
||||
window: window,
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap 包装处理器
|
||||
func (rl *RateLimitMiddleware) Wrap(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
ip := getClientIP(r)
|
||||
now := time.Now()
|
||||
|
||||
// 清理过期记录
|
||||
windowStart := now.Add(-rl.window)
|
||||
var valid []time.Time
|
||||
for _, t := range rl.requests[ip] {
|
||||
if t.After(windowStart) {
|
||||
valid = append(valid, t)
|
||||
}
|
||||
}
|
||||
rl.requests[ip] = valid
|
||||
|
||||
// 检查限制
|
||||
if len(rl.requests[ip]) >= rl.limit {
|
||||
http.Error(w, `{"error":"rate_limit","message":"too many requests"}`, http.StatusTooManyRequests)
|
||||
return
|
||||
}
|
||||
|
||||
// 记录请求
|
||||
rl.requests[ip] = append(rl.requests[ip], now)
|
||||
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
// getClientIP 获取客户端 IP
|
||||
func getClientIP(r *http.Request) string {
|
||||
// 检查代理头
|
||||
if xff := r.Header.Get("X-Forwarded-For"); xff != "" {
|
||||
parts := strings.Split(xff, ",")
|
||||
return strings.TrimSpace(parts[0])
|
||||
}
|
||||
|
||||
if xri := r.Header.Get("X-Real-IP"); xri != "" {
|
||||
return xri
|
||||
}
|
||||
|
||||
// 从 RemoteAddr 提取 IP
|
||||
ip := r.RemoteAddr
|
||||
if idx := strings.LastIndex(ip, ":"); idx != -1 {
|
||||
ip = ip[:idx]
|
||||
}
|
||||
return ip
|
||||
}
|
||||
|
||||
// responseWriter 包装 ResponseWriter 以获取状态码
|
||||
type responseWriter struct {
|
||||
http.ResponseWriter
|
||||
statusCode int
|
||||
}
|
||||
|
||||
func (rw *responseWriter) WriteHeader(code int) {
|
||||
rw.statusCode = code
|
||||
rw.ResponseWriter.WriteHeader(code)
|
||||
}
|
||||
53
internal/api/router.go
Normal file
53
internal/api/router.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"proxyrotator/internal/config"
|
||||
"proxyrotator/internal/importer"
|
||||
"proxyrotator/internal/selector"
|
||||
"proxyrotator/internal/store"
|
||||
"proxyrotator/internal/tester"
|
||||
)
|
||||
|
||||
// NewRouter 创建 HTTP 路由
|
||||
func NewRouter(
|
||||
store store.ProxyStore,
|
||||
importer *importer.Importer,
|
||||
tester *tester.HTTPTester,
|
||||
selector *selector.Selector,
|
||||
cfg *config.Config,
|
||||
) http.Handler {
|
||||
handlers := NewHandlers(store, importer, tester, selector, cfg)
|
||||
|
||||
mux := http.NewServeMux()
|
||||
|
||||
// 注册路由(Go 1.22+ 支持 METHOD /path 模式)
|
||||
mux.HandleFunc("POST /v1/proxies/import/text", handlers.HandleImportText)
|
||||
mux.HandleFunc("POST /v1/proxies/import/file", handlers.HandleImportFile)
|
||||
mux.HandleFunc("POST /v1/proxies/test", handlers.HandleTest)
|
||||
mux.HandleFunc("GET /v1/proxies/next", handlers.HandleNext)
|
||||
mux.HandleFunc("POST /v1/proxies/report", handlers.HandleReport)
|
||||
|
||||
// CRUD 路由(注意:/stats 需在 /{id} 之前注册)
|
||||
mux.HandleFunc("GET /v1/proxies/stats", handlers.HandleGetStats)
|
||||
mux.HandleFunc("GET /v1/proxies", handlers.HandleListProxies)
|
||||
mux.HandleFunc("GET /v1/proxies/{id}", handlers.HandleGetProxy)
|
||||
mux.HandleFunc("DELETE /v1/proxies/{id}", handlers.HandleDeleteProxy)
|
||||
mux.HandleFunc("DELETE /v1/proxies", handlers.HandleBulkDeleteProxies)
|
||||
mux.HandleFunc("PATCH /v1/proxies/{id}", handlers.HandleUpdateProxy)
|
||||
mux.HandleFunc("POST /v1/proxies/{id}/test", handlers.HandleTestSingleProxy)
|
||||
|
||||
// 健康检查
|
||||
mux.HandleFunc("GET /health", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte(`{"status":"ok"}`))
|
||||
})
|
||||
|
||||
// 应用中间件
|
||||
var handler http.Handler = mux
|
||||
handler = AuthMiddleware(handler, cfg.APIKey)
|
||||
handler = LoggingMiddleware(handler)
|
||||
|
||||
return handler
|
||||
}
|
||||
145
internal/config/config.go
Normal file
145
internal/config/config.go
Normal file
@@ -0,0 +1,145 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Config 应用配置
|
||||
type Config struct {
|
||||
DatabaseURL string
|
||||
ListenAddr string
|
||||
APIKey string
|
||||
ReturnSecret bool
|
||||
MaxConcurrency int
|
||||
MaxTestLimit int
|
||||
LeaseTTL time.Duration
|
||||
|
||||
// Telegram Bot 配置
|
||||
TelegramBotToken string
|
||||
TelegramAdminIDs []int64
|
||||
TelegramNotifyChatID string
|
||||
TelegramTestIntervalMin int
|
||||
TelegramAlertThreshold int
|
||||
TelegramTestURL string
|
||||
TelegramTestTimeoutMs int
|
||||
}
|
||||
|
||||
// Load 从环境变量加载配置
|
||||
func Load() *Config {
|
||||
cfg := &Config{
|
||||
DatabaseURL: getEnv("DATABASE_URL", "postgres://postgres:postgres@localhost:5432/proxyrotator?sslmode=disable"),
|
||||
ListenAddr: getEnv("LISTEN_ADDR", ":8080"),
|
||||
APIKey: getEnv("API_KEY", ""),
|
||||
ReturnSecret: getEnvBool("RETURN_SECRET", true),
|
||||
MaxConcurrency: getEnvInt("MAX_CONCURRENCY", 200),
|
||||
MaxTestLimit: getEnvInt("MAX_TEST_LIMIT", 2000),
|
||||
LeaseTTL: getEnvDuration("LEASE_TTL", 60*time.Second),
|
||||
|
||||
// Telegram
|
||||
TelegramBotToken: getEnv("TELEGRAM_BOT_TOKEN", ""),
|
||||
TelegramAdminIDs: getEnvInt64Slice("TELEGRAM_ADMIN_IDS", nil),
|
||||
TelegramNotifyChatID: getEnv("TELEGRAM_NOTIFY_CHAT_ID", ""),
|
||||
TelegramTestIntervalMin: getEnvInt("TELEGRAM_TEST_INTERVAL_MIN", 60),
|
||||
TelegramAlertThreshold: getEnvInt("TELEGRAM_ALERT_THRESHOLD", 50),
|
||||
TelegramTestURL: getEnv("TELEGRAM_TEST_URL", "https://httpbin.org/ip"),
|
||||
TelegramTestTimeoutMs: getEnvInt("TELEGRAM_TEST_TIMEOUT_MS", 5000),
|
||||
}
|
||||
return cfg
|
||||
}
|
||||
|
||||
func getEnv(key, defaultValue string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
func getEnvBool(key string, defaultValue bool) bool {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
b, err := strconv.ParseBool(v)
|
||||
if err == nil {
|
||||
return b
|
||||
}
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
func getEnvInt(key string, defaultValue int) int {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
i, err := strconv.Atoi(v)
|
||||
if err == nil {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
func getEnvDuration(key string, defaultValue time.Duration) time.Duration {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
d, err := time.ParseDuration(v)
|
||||
if err == nil {
|
||||
return d
|
||||
}
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
func getEnvInt64Slice(key string, defaultValue []int64) []int64 {
|
||||
v := os.Getenv(key)
|
||||
if v == "" {
|
||||
return defaultValue
|
||||
}
|
||||
parts := splitAndTrim(v, ",")
|
||||
result := make([]int64, 0, len(parts))
|
||||
for _, p := range parts {
|
||||
if p == "" {
|
||||
continue
|
||||
}
|
||||
i, err := strconv.ParseInt(p, 10, 64)
|
||||
if err == nil {
|
||||
result = append(result, i)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func splitAndTrim(s, sep string) []string {
|
||||
parts := make([]string, 0)
|
||||
for _, p := range stringsSplit(s, sep) {
|
||||
p = stringsTrim(p)
|
||||
if p != "" {
|
||||
parts = append(parts, p)
|
||||
}
|
||||
}
|
||||
return parts
|
||||
}
|
||||
|
||||
func stringsSplit(s, sep string) []string {
|
||||
if s == "" {
|
||||
return nil
|
||||
}
|
||||
result := make([]string, 0)
|
||||
start := 0
|
||||
for i := 0; i < len(s); i++ {
|
||||
if i+len(sep) <= len(s) && s[i:i+len(sep)] == sep {
|
||||
result = append(result, s[start:i])
|
||||
start = i + len(sep)
|
||||
i += len(sep) - 1
|
||||
}
|
||||
}
|
||||
result = append(result, s[start:])
|
||||
return result
|
||||
}
|
||||
|
||||
func stringsTrim(s string) string {
|
||||
start, end := 0, len(s)
|
||||
for start < end && (s[start] == ' ' || s[start] == '\t') {
|
||||
start++
|
||||
}
|
||||
for end > start && (s[end-1] == ' ' || s[end-1] == '\t') {
|
||||
end--
|
||||
}
|
||||
return s[start:end]
|
||||
}
|
||||
292
internal/importer/importer.go
Normal file
292
internal/importer/importer.go
Normal file
@@ -0,0 +1,292 @@
|
||||
package importer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/csv"
|
||||
"errors"
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"proxyrotator/internal/model"
|
||||
)
|
||||
|
||||
// Importer 代理导入器
|
||||
type Importer struct{}
|
||||
|
||||
// NewImporter 创建导入器
|
||||
func NewImporter() *Importer {
|
||||
return &Importer{}
|
||||
}
|
||||
|
||||
// ParseText 解析文本格式的代理列表
|
||||
func (im *Importer) ParseText(ctx context.Context, in model.ImportInput, text string) ([]model.Proxy, []model.InvalidLine) {
|
||||
lines := strings.Split(text, "\n")
|
||||
var proxies []model.Proxy
|
||||
var invalid []model.InvalidLine
|
||||
|
||||
seen := make(map[string]bool)
|
||||
|
||||
for _, raw := range lines {
|
||||
raw = strings.TrimSpace(raw)
|
||||
if raw == "" || strings.HasPrefix(raw, "#") {
|
||||
continue
|
||||
}
|
||||
|
||||
p, err := ParseProxyLine(raw, in.ProtocolHint)
|
||||
if err != nil {
|
||||
invalid = append(invalid, model.InvalidLine{
|
||||
Raw: raw,
|
||||
Reason: err.Error(),
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
// 设置默认值
|
||||
p.ID = uuid.New().String()
|
||||
p.Group = coalesce(p.Group, in.Group, "default")
|
||||
p.Tags = mergeTags(p.Tags, in.Tags)
|
||||
p.Status = model.StatusUnknown
|
||||
|
||||
// 内存去重
|
||||
key := dedupKey(p)
|
||||
if seen[key] {
|
||||
continue
|
||||
}
|
||||
seen[key] = true
|
||||
|
||||
proxies = append(proxies, *p)
|
||||
}
|
||||
|
||||
return proxies, invalid
|
||||
}
|
||||
|
||||
// ParseCSV 解析 CSV 格式的代理列表
|
||||
// 期望列: protocol,host,port,username,password,group,tags
|
||||
func (im *Importer) ParseCSV(ctx context.Context, in model.ImportInput, r io.Reader) ([]model.Proxy, []model.InvalidLine) {
|
||||
reader := csv.NewReader(r)
|
||||
reader.FieldsPerRecord = -1 // 允许不定列数
|
||||
reader.TrimLeadingSpace = true
|
||||
|
||||
var proxies []model.Proxy
|
||||
var invalid []model.InvalidLine
|
||||
seen := make(map[string]bool)
|
||||
|
||||
// 读取表头
|
||||
header, err := reader.Read()
|
||||
if err != nil {
|
||||
return nil, []model.InvalidLine{{Raw: "", Reason: "failed to read CSV header"}}
|
||||
}
|
||||
|
||||
// 解析列索引
|
||||
colIdx := parseHeader(header)
|
||||
|
||||
lineNum := 1
|
||||
for {
|
||||
record, err := reader.Read()
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
lineNum++
|
||||
|
||||
if err != nil {
|
||||
invalid = append(invalid, model.InvalidLine{
|
||||
Raw: strings.Join(record, ","),
|
||||
Reason: err.Error(),
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
p, err := parseCSVRecord(record, colIdx, in)
|
||||
if err != nil {
|
||||
invalid = append(invalid, model.InvalidLine{
|
||||
Raw: strings.Join(record, ","),
|
||||
Reason: err.Error(),
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
// 内存去重
|
||||
key := dedupKey(p)
|
||||
if seen[key] {
|
||||
continue
|
||||
}
|
||||
seen[key] = true
|
||||
|
||||
proxies = append(proxies, *p)
|
||||
}
|
||||
|
||||
return proxies, invalid
|
||||
}
|
||||
|
||||
// columnIndex CSV 列索引
|
||||
type columnIndex struct {
|
||||
protocol int
|
||||
host int
|
||||
port int
|
||||
username int
|
||||
password int
|
||||
group int
|
||||
tags int
|
||||
}
|
||||
|
||||
// parseHeader 解析 CSV 表头
|
||||
func parseHeader(header []string) columnIndex {
|
||||
idx := columnIndex{
|
||||
protocol: -1,
|
||||
host: -1,
|
||||
port: -1,
|
||||
username: -1,
|
||||
password: -1,
|
||||
group: -1,
|
||||
tags: -1,
|
||||
}
|
||||
|
||||
for i, col := range header {
|
||||
switch strings.ToLower(strings.TrimSpace(col)) {
|
||||
case "protocol":
|
||||
idx.protocol = i
|
||||
case "host":
|
||||
idx.host = i
|
||||
case "port":
|
||||
idx.port = i
|
||||
case "username", "user":
|
||||
idx.username = i
|
||||
case "password", "pass":
|
||||
idx.password = i
|
||||
case "group":
|
||||
idx.group = i
|
||||
case "tags":
|
||||
idx.tags = i
|
||||
}
|
||||
}
|
||||
|
||||
return idx
|
||||
}
|
||||
|
||||
// parseCSVRecord 解析 CSV 记录
|
||||
func parseCSVRecord(record []string, idx columnIndex, in model.ImportInput) (*model.Proxy, error) {
|
||||
get := func(i int) string {
|
||||
if i >= 0 && i < len(record) {
|
||||
return strings.TrimSpace(record[i])
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// 如果没有表头,尝试按位置解析
|
||||
if idx.host == -1 && len(record) >= 2 {
|
||||
// 假设格式: host,port 或 host,port,username,password
|
||||
line := strings.Join(record, ":")
|
||||
if len(record) >= 4 {
|
||||
line = record[2] + ":" + record[3] + "@" + record[0] + ":" + record[1]
|
||||
} else {
|
||||
line = record[0] + ":" + record[1]
|
||||
}
|
||||
p, err := ParseProxyLine(line, in.ProtocolHint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p.ID = uuid.New().String()
|
||||
p.Group = coalesce(in.Group, "default")
|
||||
p.Tags = in.Tags
|
||||
p.Status = model.StatusUnknown
|
||||
return p, nil
|
||||
}
|
||||
|
||||
// 根据表头解析
|
||||
protocol := get(idx.protocol)
|
||||
host := get(idx.host)
|
||||
portStr := get(idx.port)
|
||||
|
||||
if host == "" {
|
||||
return nil, errors.New("missing host")
|
||||
}
|
||||
|
||||
var p model.Proxy
|
||||
p.ID = uuid.New().String()
|
||||
p.Host = host
|
||||
p.Status = model.StatusUnknown
|
||||
|
||||
// 解析协议
|
||||
switch strings.ToLower(protocol) {
|
||||
case "http":
|
||||
p.Protocol = model.ProtoHTTP
|
||||
case "https":
|
||||
p.Protocol = model.ProtoHTTPS
|
||||
case "socks5":
|
||||
p.Protocol = model.ProtoSOCKS5
|
||||
default:
|
||||
p.Protocol = model.ProtoHTTP
|
||||
}
|
||||
|
||||
// 解析端口
|
||||
if portStr != "" {
|
||||
port := 0
|
||||
for _, c := range portStr {
|
||||
if c >= '0' && c <= '9' {
|
||||
port = port*10 + int(c-'0')
|
||||
}
|
||||
}
|
||||
if port > 0 && port < 65536 {
|
||||
p.Port = port
|
||||
} else {
|
||||
p.Port = 80
|
||||
}
|
||||
} else {
|
||||
p.Port = 80
|
||||
}
|
||||
|
||||
p.Username = get(idx.username)
|
||||
p.Password = get(idx.password)
|
||||
p.Group = coalesce(get(idx.group), in.Group, "default")
|
||||
|
||||
// 解析 tags
|
||||
tagsStr := get(idx.tags)
|
||||
if tagsStr != "" {
|
||||
p.Tags = strings.Split(tagsStr, ";")
|
||||
}
|
||||
p.Tags = mergeTags(p.Tags, in.Tags)
|
||||
|
||||
return &p, nil
|
||||
}
|
||||
|
||||
// dedupKey 生成去重键
|
||||
func dedupKey(p *model.Proxy) string {
|
||||
return string(p.Protocol) + ":" + p.Host + ":" + strconv.Itoa(p.Port) + ":" + p.Username
|
||||
}
|
||||
|
||||
// coalesce 返回第一个非空字符串
|
||||
func coalesce(values ...string) string {
|
||||
for _, v := range values {
|
||||
if v != "" {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// mergeTags 合并去重 tags
|
||||
func mergeTags(a, b []string) []string {
|
||||
seen := make(map[string]bool)
|
||||
var result []string
|
||||
|
||||
for _, t := range a {
|
||||
t = strings.TrimSpace(t)
|
||||
if t != "" && !seen[t] {
|
||||
seen[t] = true
|
||||
result = append(result, t)
|
||||
}
|
||||
}
|
||||
|
||||
for _, t := range b {
|
||||
t = strings.TrimSpace(t)
|
||||
if t != "" && !seen[t] {
|
||||
seen[t] = true
|
||||
result = append(result, t)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
171
internal/importer/parser.go
Normal file
171
internal/importer/parser.go
Normal file
@@ -0,0 +1,171 @@
|
||||
package importer
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"proxyrotator/internal/model"
|
||||
)
|
||||
|
||||
var (
|
||||
// 匹配 host:port 格式
|
||||
hostPortRegex = regexp.MustCompile(`^([a-zA-Z0-9.-]+):(\d+)$`)
|
||||
// 匹配 user:pass@host:port 格式
|
||||
userPassHostPortRegex = regexp.MustCompile(`^([^:@]+):([^@]+)@([a-zA-Z0-9.-]+):(\d+)$`)
|
||||
// 匹配 host:port:user:pass 格式
|
||||
hostPortUserPassRegex = regexp.MustCompile(`^([a-zA-Z0-9.-]+):(\d+):([^:]+):(.+)$`)
|
||||
)
|
||||
|
||||
// ParseProxyLine 解析单行代理格式
|
||||
// 支持格式:
|
||||
// - host:port
|
||||
// - user:pass@host:port
|
||||
// - host:port:user:pass
|
||||
// - http://host:port
|
||||
// - http://user:pass@host:port
|
||||
// - socks5://host:port
|
||||
// - socks5://user:pass@host:port
|
||||
func ParseProxyLine(raw string, protocolHint string) (*model.Proxy, error) {
|
||||
raw = strings.TrimSpace(raw)
|
||||
if raw == "" {
|
||||
return nil, fmt.Errorf("empty line")
|
||||
}
|
||||
|
||||
// 尝试解析为 URL
|
||||
if strings.Contains(raw, "://") {
|
||||
return parseAsURL(raw)
|
||||
}
|
||||
|
||||
// 尝试解析 host:port:user:pass 格式
|
||||
if matches := hostPortUserPassRegex.FindStringSubmatch(raw); matches != nil {
|
||||
port, err := strconv.Atoi(matches[2])
|
||||
if err != nil || port <= 0 || port >= 65536 {
|
||||
return nil, fmt.Errorf("invalid port: %s", matches[2])
|
||||
}
|
||||
|
||||
protocol := inferProtocol(protocolHint, port)
|
||||
return &model.Proxy{
|
||||
Protocol: protocol,
|
||||
Host: matches[1],
|
||||
Port: port,
|
||||
Username: matches[3],
|
||||
Password: matches[4],
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 尝试解析 user:pass@host:port 格式
|
||||
if matches := userPassHostPortRegex.FindStringSubmatch(raw); matches != nil {
|
||||
port, err := strconv.Atoi(matches[4])
|
||||
if err != nil || port <= 0 || port >= 65536 {
|
||||
return nil, fmt.Errorf("invalid port: %s", matches[4])
|
||||
}
|
||||
|
||||
protocol := inferProtocol(protocolHint, port)
|
||||
return &model.Proxy{
|
||||
Protocol: protocol,
|
||||
Host: matches[3],
|
||||
Port: port,
|
||||
Username: matches[1],
|
||||
Password: matches[2],
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 尝试解析 host:port 格式
|
||||
if matches := hostPortRegex.FindStringSubmatch(raw); matches != nil {
|
||||
port, err := strconv.Atoi(matches[2])
|
||||
if err != nil || port <= 0 || port >= 65536 {
|
||||
return nil, fmt.Errorf("invalid port: %s", matches[2])
|
||||
}
|
||||
|
||||
protocol := inferProtocol(protocolHint, port)
|
||||
return &model.Proxy{
|
||||
Protocol: protocol,
|
||||
Host: matches[1],
|
||||
Port: port,
|
||||
}, nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("unrecognized format")
|
||||
}
|
||||
|
||||
// parseAsURL 解析 URL 格式的代理
|
||||
func parseAsURL(raw string) (*model.Proxy, error) {
|
||||
u, err := url.Parse(raw)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid URL: %w", err)
|
||||
}
|
||||
|
||||
var protocol model.ProxyProtocol
|
||||
switch strings.ToLower(u.Scheme) {
|
||||
case "http":
|
||||
protocol = model.ProtoHTTP
|
||||
case "https":
|
||||
protocol = model.ProtoHTTPS
|
||||
case "socks5":
|
||||
protocol = model.ProtoSOCKS5
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported protocol: %s", u.Scheme)
|
||||
}
|
||||
|
||||
host := u.Hostname()
|
||||
if host == "" {
|
||||
return nil, fmt.Errorf("missing host")
|
||||
}
|
||||
|
||||
portStr := u.Port()
|
||||
if portStr == "" {
|
||||
// 默认端口
|
||||
switch protocol {
|
||||
case model.ProtoHTTP:
|
||||
portStr = "80"
|
||||
case model.ProtoHTTPS:
|
||||
portStr = "443"
|
||||
case model.ProtoSOCKS5:
|
||||
portStr = "1080"
|
||||
}
|
||||
}
|
||||
|
||||
port, err := strconv.Atoi(portStr)
|
||||
if err != nil || port <= 0 || port >= 65536 {
|
||||
return nil, fmt.Errorf("invalid port: %s", portStr)
|
||||
}
|
||||
|
||||
var username, password string
|
||||
if u.User != nil {
|
||||
username = u.User.Username()
|
||||
password, _ = u.User.Password()
|
||||
}
|
||||
|
||||
return &model.Proxy{
|
||||
Protocol: protocol,
|
||||
Host: host,
|
||||
Port: port,
|
||||
Username: username,
|
||||
Password: password,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// inferProtocol 根据提示和端口推断协议
|
||||
func inferProtocol(hint string, port int) model.ProxyProtocol {
|
||||
switch strings.ToLower(hint) {
|
||||
case "http":
|
||||
return model.ProtoHTTP
|
||||
case "https":
|
||||
return model.ProtoHTTPS
|
||||
case "socks5":
|
||||
return model.ProtoSOCKS5
|
||||
}
|
||||
|
||||
// 根据端口推断
|
||||
switch port {
|
||||
case 443:
|
||||
return model.ProtoHTTPS
|
||||
case 1080:
|
||||
return model.ProtoSOCKS5
|
||||
default:
|
||||
return model.ProtoHTTP
|
||||
}
|
||||
}
|
||||
16
internal/model/errors.go
Normal file
16
internal/model/errors.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package model
|
||||
|
||||
import "errors"
|
||||
|
||||
var (
|
||||
ErrNoProxy = errors.New("no available proxy")
|
||||
ErrBadModulo = errors.New("modulo must be positive")
|
||||
ErrBadPolicy = errors.New("unknown selection policy")
|
||||
ErrLeaseExpired = errors.New("lease expired or not found")
|
||||
ErrProxyNotFound = errors.New("proxy not found")
|
||||
ErrInvalidURL = errors.New("invalid URL")
|
||||
ErrPrivateIP = errors.New("private IP address not allowed")
|
||||
ErrUnsafeScheme = errors.New("only http and https schemes are allowed")
|
||||
ErrInvalidPatch = errors.New("invalid patch: no fields to update")
|
||||
ErrBulkDeleteEmpty = errors.New("bulk delete requires at least one condition")
|
||||
)
|
||||
258
internal/model/types.go
Normal file
258
internal/model/types.go
Normal file
@@ -0,0 +1,258 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// ProxyProtocol 代理协议类型
|
||||
type ProxyProtocol string
|
||||
|
||||
const (
|
||||
ProtoHTTP ProxyProtocol = "http"
|
||||
ProtoHTTPS ProxyProtocol = "https"
|
||||
ProtoSOCKS5 ProxyProtocol = "socks5"
|
||||
)
|
||||
|
||||
// ProxyStatus 代理状态
|
||||
type ProxyStatus string
|
||||
|
||||
const (
|
||||
StatusUnknown ProxyStatus = "unknown"
|
||||
StatusAlive ProxyStatus = "alive"
|
||||
StatusDead ProxyStatus = "dead"
|
||||
)
|
||||
|
||||
// Proxy 代理实体
|
||||
type Proxy struct {
|
||||
ID string // uuid
|
||||
|
||||
Protocol ProxyProtocol
|
||||
Host string
|
||||
Port int
|
||||
Username string
|
||||
Password string
|
||||
|
||||
Group string
|
||||
Tags []string
|
||||
|
||||
Status ProxyStatus
|
||||
Score int
|
||||
LatencyMs int64
|
||||
LastCheckAt time.Time
|
||||
|
||||
FailCount int
|
||||
SuccessCount int
|
||||
Disabled bool
|
||||
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
// HealthPatch 健康度更新补丁
|
||||
type HealthPatch struct {
|
||||
Status *ProxyStatus
|
||||
ScoreDelta int
|
||||
LatencyMs *int64
|
||||
CheckedAt *time.Time
|
||||
FailInc int
|
||||
SuccessInc int
|
||||
}
|
||||
|
||||
// TestSpec 测试规格
|
||||
type TestSpec struct {
|
||||
URL string
|
||||
Method string
|
||||
Timeout time.Duration
|
||||
ExpectStatus []int
|
||||
ExpectContains string
|
||||
}
|
||||
|
||||
// TestResult 测试结果
|
||||
type TestResult struct {
|
||||
ProxyID string
|
||||
OK bool
|
||||
LatencyMs int64
|
||||
ErrorText string
|
||||
CheckedAt time.Time
|
||||
}
|
||||
|
||||
// Lease 租约
|
||||
type Lease struct {
|
||||
LeaseID string
|
||||
ProxyID string
|
||||
Proxy Proxy
|
||||
ExpireAt time.Time
|
||||
Group string
|
||||
Site string
|
||||
}
|
||||
|
||||
// ProxyQuery 代理查询条件
|
||||
type ProxyQuery struct {
|
||||
Group string
|
||||
TagsAny []string
|
||||
StatusIn []ProxyStatus
|
||||
OnlyEnabled bool
|
||||
Limit int
|
||||
OrderBy string // "random", "score", "latency",默认按 score 降序
|
||||
}
|
||||
|
||||
// InvalidLine 无效行记录
|
||||
type InvalidLine struct {
|
||||
Raw string `json:"raw"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
// SelectRequest 代理选择请求
|
||||
type SelectRequest struct {
|
||||
Group string
|
||||
Site string
|
||||
Policy string // round_robin, random, weighted
|
||||
TagsAny []string
|
||||
}
|
||||
|
||||
// ImportInput 导入输入参数
|
||||
type ImportInput struct {
|
||||
Group string
|
||||
Tags []string
|
||||
ProtocolHint string // auto, http, https, socks5
|
||||
}
|
||||
|
||||
// ImportResult 导入结果
|
||||
type ImportResult struct {
|
||||
Imported int `json:"imported"`
|
||||
Duplicated int `json:"duplicated"`
|
||||
Invalid int `json:"invalid"`
|
||||
InvalidItems []InvalidLine `json:"invalid_items,omitempty"`
|
||||
}
|
||||
|
||||
// TestSummary 测试摘要
|
||||
type TestSummary struct {
|
||||
Tested int `json:"tested"`
|
||||
Alive int `json:"alive"`
|
||||
Dead int `json:"dead"`
|
||||
}
|
||||
|
||||
// TestBatchResult 批量测试结果
|
||||
type TestBatchResult struct {
|
||||
Summary TestSummary `json:"summary"`
|
||||
Results []TestResult `json:"results"`
|
||||
}
|
||||
|
||||
// NextProxyResponse 获取下一个代理的响应
|
||||
type NextProxyResponse struct {
|
||||
Proxy ProxyInfo `json:"proxy"`
|
||||
LeaseID string `json:"lease_id"`
|
||||
TTLMs int64 `json:"ttl_ms"`
|
||||
}
|
||||
|
||||
// ProxyInfo 代理信息(用于 API 响应)
|
||||
type ProxyInfo struct {
|
||||
ID string `json:"id"`
|
||||
Protocol ProxyProtocol `json:"protocol"`
|
||||
Host string `json:"host"`
|
||||
Port int `json:"port"`
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
}
|
||||
|
||||
// ReportRequest 上报请求
|
||||
type ReportRequest struct {
|
||||
LeaseID string `json:"lease_id"`
|
||||
ProxyID string `json:"proxy_id"`
|
||||
Success bool `json:"success"`
|
||||
Error string `json:"error,omitempty"`
|
||||
LatencyMs int64 `json:"latency_ms"`
|
||||
}
|
||||
|
||||
// TestRequest 测试请求
|
||||
type TestRequest struct {
|
||||
Group string `json:"group"`
|
||||
Filter ProxyFilter `json:"filter"`
|
||||
TestSpec TestSpecReq `json:"test_spec"`
|
||||
Concurrency int `json:"concurrency"`
|
||||
UpdateStore bool `json:"update_store"`
|
||||
WriteLog bool `json:"write_log"`
|
||||
}
|
||||
|
||||
// ProxyFilter 代理过滤条件
|
||||
type ProxyFilter struct {
|
||||
Status []string `json:"status"`
|
||||
TagsAny []string `json:"tags_any"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
// TestSpecReq 测试规格请求
|
||||
type TestSpecReq struct {
|
||||
URL string `json:"url"`
|
||||
Method string `json:"method"`
|
||||
TimeoutMs int `json:"timeout_ms"`
|
||||
ExpectStatus []int `json:"expect_status"`
|
||||
ExpectContains string `json:"expect_contains"`
|
||||
}
|
||||
|
||||
// ImportTextRequest 文本导入请求
|
||||
type ImportTextRequest struct {
|
||||
Group string `json:"group"`
|
||||
Tags []string `json:"tags"`
|
||||
ProtocolHint string `json:"protocol_hint"`
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
// ProxyListQuery 代理列表查询条件(带分页)
|
||||
type ProxyListQuery struct {
|
||||
Group string
|
||||
TagsAny []string
|
||||
StatusIn []ProxyStatus
|
||||
OnlyEnabled bool
|
||||
Offset int
|
||||
Limit int
|
||||
}
|
||||
|
||||
// ProxyListResponse 代理列表分页响应
|
||||
type ProxyListResponse struct {
|
||||
Data []Proxy `json:"data"`
|
||||
Total int `json:"total"`
|
||||
Offset int `json:"offset"`
|
||||
Limit int `json:"limit"`
|
||||
}
|
||||
|
||||
// ProxyPatch 代理更新补丁
|
||||
type ProxyPatch struct {
|
||||
Group *string `json:"group,omitempty"`
|
||||
Tags *[]string `json:"tags,omitempty"`
|
||||
AddTags []string `json:"add_tags,omitempty"`
|
||||
Disabled *bool `json:"disabled,omitempty"`
|
||||
}
|
||||
|
||||
// BulkDeleteRequest 批量删除请求
|
||||
type BulkDeleteRequest struct {
|
||||
IDs []string `json:"ids,omitempty"`
|
||||
Status ProxyStatus `json:"status,omitempty"`
|
||||
Group string `json:"group,omitempty"`
|
||||
Disabled *bool `json:"disabled,omitempty"`
|
||||
}
|
||||
|
||||
// BulkDeleteResponse 批量删除响应
|
||||
type BulkDeleteResponse struct {
|
||||
Deleted int `json:"deleted"`
|
||||
}
|
||||
|
||||
// SingleTestRequest 单个代理测试请求
|
||||
type SingleTestRequest struct {
|
||||
URL string `json:"url"`
|
||||
Method string `json:"method,omitempty"`
|
||||
TimeoutMs int `json:"timeout_ms,omitempty"`
|
||||
ExpectStatus []int `json:"expect_status,omitempty"`
|
||||
ExpectContains string `json:"expect_contains,omitempty"`
|
||||
UpdateStore bool `json:"update_store"`
|
||||
WriteLog bool `json:"write_log"`
|
||||
}
|
||||
|
||||
// ProxyStats 代理统计信息
|
||||
type ProxyStats struct {
|
||||
Total int `json:"total"`
|
||||
ByStatus map[ProxyStatus]int `json:"by_status"`
|
||||
ByGroup map[string]int `json:"by_group"`
|
||||
ByProtocol map[ProxyProtocol]int `json:"by_protocol"`
|
||||
Disabled int `json:"disabled"`
|
||||
AvgLatencyMs int64 `json:"avg_latency_ms"`
|
||||
AvgScore float64 `json:"avg_score"`
|
||||
}
|
||||
71
internal/security/validate_url.go
Normal file
71
internal/security/validate_url.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package security
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/url"
|
||||
|
||||
"proxyrotator/internal/model"
|
||||
)
|
||||
|
||||
// ValidateTestURL 校验测试目标 URL,防止 SSRF
|
||||
func ValidateTestURL(rawURL string) error {
|
||||
u, err := url.Parse(rawURL)
|
||||
if err != nil {
|
||||
return model.ErrInvalidURL
|
||||
}
|
||||
|
||||
// 只允许 http/https
|
||||
if u.Scheme != "http" && u.Scheme != "https" {
|
||||
return model.ErrUnsafeScheme
|
||||
}
|
||||
|
||||
// 解析主机名
|
||||
host := u.Hostname()
|
||||
if host == "" {
|
||||
return model.ErrInvalidURL
|
||||
}
|
||||
|
||||
// 解析 IP 地址
|
||||
ips, err := net.LookupIP(host)
|
||||
if err != nil {
|
||||
return model.ErrInvalidURL
|
||||
}
|
||||
|
||||
// 检查是否为私网 IP
|
||||
for _, ip := range ips {
|
||||
if IsPrivateIP(ip) {
|
||||
return model.ErrPrivateIP
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsPrivateIP 判断是否为私网 IP
|
||||
func IsPrivateIP(ip net.IP) bool {
|
||||
if ip == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// 回环地址
|
||||
if ip.IsLoopback() {
|
||||
return true
|
||||
}
|
||||
|
||||
// 链路本地地址
|
||||
if ip.IsLinkLocalUnicast() || ip.IsLinkLocalMulticast() {
|
||||
return true
|
||||
}
|
||||
|
||||
// 私有地址
|
||||
if ip.IsPrivate() {
|
||||
return true
|
||||
}
|
||||
|
||||
// 未指定地址
|
||||
if ip.IsUnspecified() {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
177
internal/selector/selector.go
Normal file
177
internal/selector/selector.go
Normal file
@@ -0,0 +1,177 @@
|
||||
package selector
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"math/big"
|
||||
mathrand "math/rand"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"proxyrotator/internal/model"
|
||||
"proxyrotator/internal/store"
|
||||
)
|
||||
|
||||
// Selector 代理选择器
|
||||
type Selector struct {
|
||||
store store.ProxyStore
|
||||
leaseTTL time.Duration
|
||||
}
|
||||
|
||||
// NewSelector 创建选择器
|
||||
func NewSelector(store store.ProxyStore, leaseTTL time.Duration) *Selector {
|
||||
if leaseTTL <= 0 {
|
||||
leaseTTL = 60 * time.Second
|
||||
}
|
||||
return &Selector{
|
||||
store: store,
|
||||
leaseTTL: leaseTTL,
|
||||
}
|
||||
}
|
||||
|
||||
// Next 获取下一个可用代理
|
||||
func (s *Selector) Next(ctx context.Context, req model.SelectRequest) (*model.Lease, error) {
|
||||
policy := req.Policy
|
||||
if policy == "" {
|
||||
policy = "round_robin"
|
||||
}
|
||||
|
||||
// 查询可用代理
|
||||
proxies, err := s.store.List(ctx, model.ProxyQuery{
|
||||
Group: req.Group,
|
||||
TagsAny: req.TagsAny,
|
||||
StatusIn: []model.ProxyStatus{model.StatusAlive},
|
||||
OnlyEnabled: true,
|
||||
Limit: 5000,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(proxies) == 0 {
|
||||
return nil, model.ErrNoProxy
|
||||
}
|
||||
|
||||
// 根据策略选择
|
||||
var chosen model.Proxy
|
||||
switch policy {
|
||||
case "round_robin":
|
||||
key := "rr:" + req.Group + ":" + normalizeSite(req.Site)
|
||||
idx, err := s.store.NextIndex(ctx, key, len(proxies))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
chosen = proxies[idx]
|
||||
|
||||
case "random":
|
||||
idx := mathrand.Intn(len(proxies))
|
||||
chosen = proxies[idx]
|
||||
|
||||
case "weighted":
|
||||
chosen = weightedPickByScore(proxies)
|
||||
|
||||
default:
|
||||
return nil, model.ErrBadPolicy
|
||||
}
|
||||
|
||||
// 创建租约
|
||||
lease := model.Lease{
|
||||
LeaseID: newLeaseID(),
|
||||
ProxyID: chosen.ID,
|
||||
Proxy: chosen,
|
||||
Group: req.Group,
|
||||
Site: req.Site,
|
||||
ExpireAt: time.Now().Add(s.leaseTTL),
|
||||
}
|
||||
|
||||
// 尝试保存租约(失败也可降级不存)
|
||||
_ = s.store.CreateLease(ctx, lease)
|
||||
|
||||
return &lease, nil
|
||||
}
|
||||
|
||||
// Report 上报使用结果
|
||||
func (s *Selector) Report(ctx context.Context, leaseID, proxyID string, success bool, latencyMs int64, errText string) error {
|
||||
now := time.Now()
|
||||
|
||||
if success {
|
||||
status := model.StatusAlive
|
||||
return s.store.UpdateHealth(ctx, proxyID, model.HealthPatch{
|
||||
Status: &status,
|
||||
ScoreDelta: 1,
|
||||
SuccessInc: 1,
|
||||
LatencyMs: &latencyMs,
|
||||
CheckedAt: &now,
|
||||
})
|
||||
}
|
||||
|
||||
status := model.StatusDead
|
||||
return s.store.UpdateHealth(ctx, proxyID, model.HealthPatch{
|
||||
Status: &status,
|
||||
ScoreDelta: -3,
|
||||
FailInc: 1,
|
||||
CheckedAt: &now,
|
||||
})
|
||||
}
|
||||
|
||||
// normalizeSite 规范化站点 URL(提取域名)
|
||||
func normalizeSite(site string) string {
|
||||
if site == "" {
|
||||
return "default"
|
||||
}
|
||||
|
||||
u, err := url.Parse(site)
|
||||
if err != nil {
|
||||
return site
|
||||
}
|
||||
|
||||
host := u.Hostname()
|
||||
if host == "" {
|
||||
return site
|
||||
}
|
||||
|
||||
// 去除 www 前缀
|
||||
host = strings.TrimPrefix(host, "www.")
|
||||
return host
|
||||
}
|
||||
|
||||
// weightedPickByScore 按分数加权随机选择
|
||||
func weightedPickByScore(proxies []model.Proxy) model.Proxy {
|
||||
// 计算权重(分数 + 偏移量确保正数)
|
||||
const offset = 100
|
||||
totalWeight := 0
|
||||
weights := make([]int, len(proxies))
|
||||
|
||||
for i, p := range proxies {
|
||||
w := p.Score + offset
|
||||
if w < 1 {
|
||||
w = 1
|
||||
}
|
||||
weights[i] = w
|
||||
totalWeight += w
|
||||
}
|
||||
|
||||
// 随机选择
|
||||
r := mathrand.Intn(totalWeight)
|
||||
for i, w := range weights {
|
||||
r -= w
|
||||
if r < 0 {
|
||||
return proxies[i]
|
||||
}
|
||||
}
|
||||
|
||||
return proxies[0]
|
||||
}
|
||||
|
||||
// newLeaseID 生成租约 ID
|
||||
func newLeaseID() string {
|
||||
b := make([]byte, 16)
|
||||
if _, err := rand.Read(b); err != nil {
|
||||
// fallback
|
||||
n, _ := rand.Int(rand.Reader, big.NewInt(1<<62))
|
||||
return "lease_" + n.String()
|
||||
}
|
||||
return "lease_" + hex.EncodeToString(b)
|
||||
}
|
||||
698
internal/store/pg_store.go
Normal file
698
internal/store/pg_store.go
Normal file
@@ -0,0 +1,698 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
|
||||
"proxyrotator/internal/model"
|
||||
)
|
||||
|
||||
// PgStore PostgreSQL 存储实现
|
||||
type PgStore struct {
|
||||
pool *pgxpool.Pool
|
||||
}
|
||||
|
||||
// NewPgStore 创建 PostgreSQL 存储
|
||||
func NewPgStore(ctx context.Context, connString string) (*PgStore, error) {
|
||||
pool, err := pgxpool.New(ctx, connString)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create connection pool: %w", err)
|
||||
}
|
||||
|
||||
if err := pool.Ping(ctx); err != nil {
|
||||
pool.Close()
|
||||
return nil, fmt.Errorf("failed to ping database: %w", err)
|
||||
}
|
||||
|
||||
return &PgStore{pool: pool}, nil
|
||||
}
|
||||
|
||||
// Close 关闭连接池
|
||||
func (s *PgStore) Close() error {
|
||||
s.pool.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
// Pool 返回连接池(用于其他模块共享)
|
||||
func (s *PgStore) Pool() *pgxpool.Pool {
|
||||
return s.pool
|
||||
}
|
||||
|
||||
// UpsertMany 批量导入代理
|
||||
func (s *PgStore) UpsertMany(ctx context.Context, proxies []model.Proxy) (imported, duplicated int, err error) {
|
||||
if len(proxies) == 0 {
|
||||
return 0, 0, nil
|
||||
}
|
||||
|
||||
const sqlUpsert = `
|
||||
INSERT INTO proxies (id, protocol, host, port, username, password, "group", tags)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
ON CONFLICT (protocol, host, port, username)
|
||||
DO UPDATE SET
|
||||
password = EXCLUDED.password,
|
||||
"group" = EXCLUDED."group",
|
||||
tags = (
|
||||
SELECT ARRAY(
|
||||
SELECT DISTINCT unnest(proxies.tags || EXCLUDED.tags)
|
||||
)
|
||||
)
|
||||
RETURNING (xmax = 0) AS inserted
|
||||
`
|
||||
|
||||
tx, err := s.pool.Begin(ctx)
|
||||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("failed to begin transaction: %w", err)
|
||||
}
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
for _, p := range proxies {
|
||||
var inserted bool
|
||||
err := tx.QueryRow(ctx, sqlUpsert,
|
||||
p.ID, p.Protocol, p.Host, p.Port, p.Username, p.Password, p.Group, p.Tags,
|
||||
).Scan(&inserted)
|
||||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("failed to upsert proxy: %w", err)
|
||||
}
|
||||
if inserted {
|
||||
imported++
|
||||
} else {
|
||||
duplicated++
|
||||
}
|
||||
}
|
||||
|
||||
if err := tx.Commit(ctx); err != nil {
|
||||
return 0, 0, fmt.Errorf("failed to commit transaction: %w", err)
|
||||
}
|
||||
|
||||
return imported, duplicated, nil
|
||||
}
|
||||
|
||||
// List 查询代理列表
|
||||
func (s *PgStore) List(ctx context.Context, q model.ProxyQuery) ([]model.Proxy, error) {
|
||||
var conditions []string
|
||||
var args []any
|
||||
argIdx := 1
|
||||
|
||||
if q.Group != "" {
|
||||
conditions = append(conditions, fmt.Sprintf(`"group" = $%d`, argIdx))
|
||||
args = append(args, q.Group)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
if q.OnlyEnabled {
|
||||
conditions = append(conditions, "disabled = false")
|
||||
}
|
||||
|
||||
if len(q.StatusIn) > 0 {
|
||||
placeholders := make([]string, len(q.StatusIn))
|
||||
for i, status := range q.StatusIn {
|
||||
placeholders[i] = fmt.Sprintf("$%d", argIdx)
|
||||
args = append(args, status)
|
||||
argIdx++
|
||||
}
|
||||
conditions = append(conditions, fmt.Sprintf("status IN (%s)", strings.Join(placeholders, ",")))
|
||||
}
|
||||
|
||||
if len(q.TagsAny) > 0 {
|
||||
conditions = append(conditions, fmt.Sprintf("tags && $%d", argIdx))
|
||||
args = append(args, q.TagsAny)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
sql := `SELECT id, protocol, host, port, username, password, "group", tags,
|
||||
status, score, latency_ms, last_check_at, fail_count, success_count,
|
||||
disabled, created_at, updated_at
|
||||
FROM proxies`
|
||||
|
||||
if len(conditions) > 0 {
|
||||
sql += " WHERE " + strings.Join(conditions, " AND ")
|
||||
}
|
||||
|
||||
// 排序方式
|
||||
switch q.OrderBy {
|
||||
case "random":
|
||||
sql += " ORDER BY RANDOM()"
|
||||
case "latency":
|
||||
sql += " ORDER BY latency_ms ASC NULLS LAST"
|
||||
default:
|
||||
sql += " ORDER BY score DESC, last_check_at DESC NULLS LAST"
|
||||
}
|
||||
|
||||
if q.Limit > 0 {
|
||||
sql += fmt.Sprintf(" LIMIT %d", q.Limit)
|
||||
}
|
||||
|
||||
rows, err := s.pool.Query(ctx, sql, args...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to query proxies: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
return scanProxies(rows)
|
||||
}
|
||||
|
||||
// GetByID 根据 ID 获取代理
|
||||
func (s *PgStore) GetByID(ctx context.Context, id string) (*model.Proxy, error) {
|
||||
const sql = `SELECT id, protocol, host, port, username, password, "group", tags,
|
||||
status, score, latency_ms, last_check_at, fail_count, success_count,
|
||||
disabled, created_at, updated_at
|
||||
FROM proxies WHERE id = $1`
|
||||
|
||||
row := s.pool.QueryRow(ctx, sql, id)
|
||||
p, err := scanProxy(row)
|
||||
if err != nil {
|
||||
if err == pgx.ErrNoRows {
|
||||
return nil, model.ErrProxyNotFound
|
||||
}
|
||||
return nil, fmt.Errorf("failed to get proxy: %w", err)
|
||||
}
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
||||
// UpdateHealth 更新代理健康度
|
||||
func (s *PgStore) UpdateHealth(ctx context.Context, proxyID string, patch model.HealthPatch) error {
|
||||
var sets []string
|
||||
var args []any
|
||||
argIdx := 1
|
||||
|
||||
if patch.Status != nil {
|
||||
sets = append(sets, fmt.Sprintf("status = $%d", argIdx))
|
||||
args = append(args, *patch.Status)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
if patch.ScoreDelta != 0 {
|
||||
sets = append(sets, fmt.Sprintf("score = GREATEST(-1000, LEAST(1000, score + $%d))", argIdx))
|
||||
args = append(args, patch.ScoreDelta)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
if patch.LatencyMs != nil {
|
||||
sets = append(sets, fmt.Sprintf("latency_ms = $%d", argIdx))
|
||||
args = append(args, *patch.LatencyMs)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
if patch.CheckedAt != nil {
|
||||
sets = append(sets, fmt.Sprintf("last_check_at = $%d", argIdx))
|
||||
args = append(args, *patch.CheckedAt)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
if patch.FailInc > 0 {
|
||||
sets = append(sets, fmt.Sprintf("fail_count = fail_count + $%d", argIdx))
|
||||
args = append(args, patch.FailInc)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
if patch.SuccessInc > 0 {
|
||||
sets = append(sets, fmt.Sprintf("success_count = success_count + $%d", argIdx))
|
||||
args = append(args, patch.SuccessInc)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
if len(sets) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
sql := fmt.Sprintf("UPDATE proxies SET %s WHERE id = $%d", strings.Join(sets, ", "), argIdx)
|
||||
args = append(args, proxyID)
|
||||
|
||||
_, err := s.pool.Exec(ctx, sql, args...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update health: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NextIndex RR 原子游标
|
||||
func (s *PgStore) NextIndex(ctx context.Context, key string, modulo int) (int, error) {
|
||||
if modulo <= 0 {
|
||||
return 0, model.ErrBadModulo
|
||||
}
|
||||
|
||||
const sql = `
|
||||
INSERT INTO rr_cursors (k, v)
|
||||
VALUES ($1, 0)
|
||||
ON CONFLICT (k)
|
||||
DO UPDATE SET v = rr_cursors.v + 1, updated_at = now()
|
||||
RETURNING v
|
||||
`
|
||||
|
||||
var v int64
|
||||
err := s.pool.QueryRow(ctx, sql, key).Scan(&v)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to get next index: %w", err)
|
||||
}
|
||||
|
||||
idx := int(v % int64(modulo))
|
||||
if idx < 0 {
|
||||
idx = -idx
|
||||
}
|
||||
return idx, nil
|
||||
}
|
||||
|
||||
// CreateLease 创建租约
|
||||
func (s *PgStore) CreateLease(ctx context.Context, lease model.Lease) error {
|
||||
const sql = `
|
||||
INSERT INTO proxy_leases (lease_id, proxy_id, expire_at, site, "group")
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
`
|
||||
|
||||
_, err := s.pool.Exec(ctx, sql,
|
||||
lease.LeaseID, lease.ProxyID, lease.ExpireAt, lease.Site, lease.Group,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create lease: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetLease 获取租约
|
||||
func (s *PgStore) GetLease(ctx context.Context, leaseID string) (*model.Lease, error) {
|
||||
const sql = `
|
||||
SELECT lease_id, proxy_id, expire_at, site, "group"
|
||||
FROM proxy_leases
|
||||
WHERE lease_id = $1 AND expire_at > now()
|
||||
`
|
||||
|
||||
var lease model.Lease
|
||||
err := s.pool.QueryRow(ctx, sql, leaseID).Scan(
|
||||
&lease.LeaseID, &lease.ProxyID, &lease.ExpireAt, &lease.Site, &lease.Group,
|
||||
)
|
||||
if err != nil {
|
||||
if err == pgx.ErrNoRows {
|
||||
return nil, model.ErrLeaseExpired
|
||||
}
|
||||
return nil, fmt.Errorf("failed to get lease: %w", err)
|
||||
}
|
||||
|
||||
return &lease, nil
|
||||
}
|
||||
|
||||
// DeleteExpiredLeases 删除过期租约
|
||||
func (s *PgStore) DeleteExpiredLeases(ctx context.Context) (int64, error) {
|
||||
const sql = `DELETE FROM proxy_leases WHERE expire_at <= now()`
|
||||
|
||||
result, err := s.pool.Exec(ctx, sql)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to delete expired leases: %w", err)
|
||||
}
|
||||
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
// InsertTestLog 插入测试日志
|
||||
func (s *PgStore) InsertTestLog(ctx context.Context, r model.TestResult, site string) error {
|
||||
const sql = `
|
||||
INSERT INTO proxy_test_logs (proxy_id, site, ok, latency_ms, error_text, checked_at)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
`
|
||||
|
||||
_, err := s.pool.Exec(ctx, sql,
|
||||
r.ProxyID, site, r.OK, r.LatencyMs, r.ErrorText, r.CheckedAt,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to insert test log: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ListPaginated 分页查询代理列表
|
||||
func (s *PgStore) ListPaginated(ctx context.Context, q model.ProxyListQuery) ([]model.Proxy, int, error) {
|
||||
var conditions []string
|
||||
var args []any
|
||||
argIdx := 1
|
||||
|
||||
if q.Group != "" {
|
||||
conditions = append(conditions, fmt.Sprintf(`"group" = $%d`, argIdx))
|
||||
args = append(args, q.Group)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
if q.OnlyEnabled {
|
||||
conditions = append(conditions, "disabled = false")
|
||||
}
|
||||
|
||||
if len(q.StatusIn) > 0 {
|
||||
placeholders := make([]string, len(q.StatusIn))
|
||||
for i, status := range q.StatusIn {
|
||||
placeholders[i] = fmt.Sprintf("$%d", argIdx)
|
||||
args = append(args, status)
|
||||
argIdx++
|
||||
}
|
||||
conditions = append(conditions, fmt.Sprintf("status IN (%s)", strings.Join(placeholders, ",")))
|
||||
}
|
||||
|
||||
if len(q.TagsAny) > 0 {
|
||||
conditions = append(conditions, fmt.Sprintf("tags && $%d", argIdx))
|
||||
args = append(args, q.TagsAny)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
whereClause := ""
|
||||
if len(conditions) > 0 {
|
||||
whereClause = " WHERE " + strings.Join(conditions, " AND ")
|
||||
}
|
||||
|
||||
// 查询总数
|
||||
countSQL := "SELECT COUNT(*) FROM proxies" + whereClause
|
||||
var total int
|
||||
if err := s.pool.QueryRow(ctx, countSQL, args...).Scan(&total); err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to count proxies: %w", err)
|
||||
}
|
||||
|
||||
// 查询数据
|
||||
dataSQL := `SELECT id, protocol, host, port, username, password, "group", tags,
|
||||
status, score, latency_ms, last_check_at, fail_count, success_count,
|
||||
disabled, created_at, updated_at FROM proxies` + whereClause +
|
||||
" ORDER BY score DESC, last_check_at DESC NULLS LAST"
|
||||
|
||||
dataSQL += fmt.Sprintf(" LIMIT $%d OFFSET $%d", argIdx, argIdx+1)
|
||||
args = append(args, q.Limit, q.Offset)
|
||||
|
||||
rows, err := s.pool.Query(ctx, dataSQL, args...)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to query proxies: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
proxies, err := scanProxies(rows)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
return proxies, total, nil
|
||||
}
|
||||
|
||||
// Update 更新代理字段
|
||||
func (s *PgStore) Update(ctx context.Context, id string, patch model.ProxyPatch) error {
|
||||
var sets []string
|
||||
var args []any
|
||||
argIdx := 1
|
||||
|
||||
if patch.Group != nil {
|
||||
sets = append(sets, fmt.Sprintf(`"group" = $%d`, argIdx))
|
||||
args = append(args, *patch.Group)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
if patch.Tags != nil {
|
||||
sets = append(sets, fmt.Sprintf("tags = $%d", argIdx))
|
||||
args = append(args, *patch.Tags)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
if len(patch.AddTags) > 0 {
|
||||
sets = append(sets, fmt.Sprintf(`tags = (
|
||||
SELECT ARRAY(SELECT DISTINCT unnest(tags || $%d))
|
||||
)`, argIdx))
|
||||
args = append(args, patch.AddTags)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
if patch.Disabled != nil {
|
||||
sets = append(sets, fmt.Sprintf("disabled = $%d", argIdx))
|
||||
args = append(args, *patch.Disabled)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
if len(sets) == 0 {
|
||||
return model.ErrInvalidPatch
|
||||
}
|
||||
|
||||
sql := fmt.Sprintf("UPDATE proxies SET %s WHERE id = $%d", strings.Join(sets, ", "), argIdx)
|
||||
args = append(args, id)
|
||||
|
||||
result, err := s.pool.Exec(ctx, sql, args...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update proxy: %w", err)
|
||||
}
|
||||
|
||||
if result.RowsAffected() == 0 {
|
||||
return model.ErrProxyNotFound
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete 删除单个代理
|
||||
func (s *PgStore) Delete(ctx context.Context, id string) error {
|
||||
tx, err := s.pool.Begin(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to begin transaction: %w", err)
|
||||
}
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
// 删除租约
|
||||
if _, err := tx.Exec(ctx, "DELETE FROM proxy_leases WHERE proxy_id = $1", id); err != nil {
|
||||
return fmt.Errorf("failed to delete leases: %w", err)
|
||||
}
|
||||
|
||||
// 删除测试日志
|
||||
if _, err := tx.Exec(ctx, "DELETE FROM proxy_test_logs WHERE proxy_id = $1", id); err != nil {
|
||||
return fmt.Errorf("failed to delete test logs: %w", err)
|
||||
}
|
||||
|
||||
// 删除代理
|
||||
result, err := tx.Exec(ctx, "DELETE FROM proxies WHERE id = $1", id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to delete proxy: %w", err)
|
||||
}
|
||||
|
||||
if result.RowsAffected() == 0 {
|
||||
return model.ErrProxyNotFound
|
||||
}
|
||||
|
||||
return tx.Commit(ctx)
|
||||
}
|
||||
|
||||
// DeleteMany 批量删除代理
|
||||
func (s *PgStore) DeleteMany(ctx context.Context, req model.BulkDeleteRequest) (int64, error) {
|
||||
var conditions []string
|
||||
var args []any
|
||||
argIdx := 1
|
||||
|
||||
if len(req.IDs) > 0 {
|
||||
conditions = append(conditions, fmt.Sprintf("id = ANY($%d)", argIdx))
|
||||
args = append(args, req.IDs)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
if req.Status != "" {
|
||||
conditions = append(conditions, fmt.Sprintf("status = $%d", argIdx))
|
||||
args = append(args, req.Status)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
if req.Group != "" {
|
||||
conditions = append(conditions, fmt.Sprintf(`"group" = $%d`, argIdx))
|
||||
args = append(args, req.Group)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
if req.Disabled != nil {
|
||||
conditions = append(conditions, fmt.Sprintf("disabled = $%d", argIdx))
|
||||
args = append(args, *req.Disabled)
|
||||
argIdx++
|
||||
}
|
||||
|
||||
if len(conditions) == 0 {
|
||||
return 0, model.ErrBulkDeleteEmpty
|
||||
}
|
||||
|
||||
whereClause := strings.Join(conditions, " AND ")
|
||||
|
||||
tx, err := s.pool.Begin(ctx)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to begin transaction: %w", err)
|
||||
}
|
||||
defer tx.Rollback(ctx)
|
||||
|
||||
// 先获取要删除的代理 ID 列表
|
||||
selectSQL := "SELECT id FROM proxies WHERE " + whereClause
|
||||
rows, err := tx.Query(ctx, selectSQL, args...)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to select proxies: %w", err)
|
||||
}
|
||||
|
||||
var ids []string
|
||||
for rows.Next() {
|
||||
var id string
|
||||
if err := rows.Scan(&id); err != nil {
|
||||
rows.Close()
|
||||
return 0, err
|
||||
}
|
||||
ids = append(ids, id)
|
||||
}
|
||||
rows.Close()
|
||||
|
||||
if len(ids) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// 删除关联数据
|
||||
if _, err := tx.Exec(ctx, "DELETE FROM proxy_leases WHERE proxy_id = ANY($1)", ids); err != nil {
|
||||
return 0, fmt.Errorf("failed to delete leases: %w", err)
|
||||
}
|
||||
|
||||
if _, err := tx.Exec(ctx, "DELETE FROM proxy_test_logs WHERE proxy_id = ANY($1)", ids); err != nil {
|
||||
return 0, fmt.Errorf("failed to delete test logs: %w", err)
|
||||
}
|
||||
|
||||
// 删除代理
|
||||
result, err := tx.Exec(ctx, "DELETE FROM proxies WHERE id = ANY($1)", ids)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to delete proxies: %w", err)
|
||||
}
|
||||
|
||||
if err := tx.Commit(ctx); err != nil {
|
||||
return 0, fmt.Errorf("failed to commit: %w", err)
|
||||
}
|
||||
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
// GetStats 获取代理统计信息
|
||||
func (s *PgStore) GetStats(ctx context.Context) (*model.ProxyStats, error) {
|
||||
stats := &model.ProxyStats{
|
||||
ByStatus: make(map[model.ProxyStatus]int),
|
||||
ByGroup: make(map[string]int),
|
||||
ByProtocol: make(map[model.ProxyProtocol]int),
|
||||
}
|
||||
|
||||
// 总数和禁用数
|
||||
const sqlBasic = `
|
||||
SELECT
|
||||
COUNT(*) AS total,
|
||||
COUNT(*) FILTER (WHERE disabled = true) AS disabled,
|
||||
COALESCE(ROUND(AVG(latency_ms) FILTER (WHERE status = 'alive' AND latency_ms > 0)), 0)::BIGINT AS avg_latency,
|
||||
COALESCE(AVG(score), 0)::DOUBLE PRECISION AS avg_score
|
||||
FROM proxies;
|
||||
`
|
||||
if err := s.pool.QueryRow(ctx, sqlBasic).Scan(
|
||||
&stats.Total, &stats.Disabled, &stats.AvgLatencyMs, &stats.AvgScore,
|
||||
); err != nil {
|
||||
return nil, fmt.Errorf("failed to get basic stats: %w", err)
|
||||
}
|
||||
|
||||
// 按状态统计
|
||||
const sqlByStatus = `SELECT status, COUNT(*) FROM proxies GROUP BY status`
|
||||
rows, err := s.pool.Query(ctx, sqlByStatus)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get status stats: %w", err)
|
||||
}
|
||||
for rows.Next() {
|
||||
var status model.ProxyStatus
|
||||
var count int
|
||||
if err := rows.Scan(&status, &count); err != nil {
|
||||
rows.Close()
|
||||
return nil, err
|
||||
}
|
||||
stats.ByStatus[status] = count
|
||||
}
|
||||
rows.Close()
|
||||
|
||||
// 按分组统计
|
||||
const sqlByGroup = `SELECT "group", COUNT(*) FROM proxies GROUP BY "group"`
|
||||
rows, err = s.pool.Query(ctx, sqlByGroup)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get group stats: %w", err)
|
||||
}
|
||||
for rows.Next() {
|
||||
var group string
|
||||
var count int
|
||||
if err := rows.Scan(&group, &count); err != nil {
|
||||
rows.Close()
|
||||
return nil, err
|
||||
}
|
||||
stats.ByGroup[group] = count
|
||||
}
|
||||
rows.Close()
|
||||
|
||||
// 按协议统计
|
||||
const sqlByProtocol = `SELECT protocol, COUNT(*) FROM proxies GROUP BY protocol`
|
||||
rows, err = s.pool.Query(ctx, sqlByProtocol)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get protocol stats: %w", err)
|
||||
}
|
||||
for rows.Next() {
|
||||
var protocol model.ProxyProtocol
|
||||
var count int
|
||||
if err := rows.Scan(&protocol, &count); err != nil {
|
||||
rows.Close()
|
||||
return nil, err
|
||||
}
|
||||
stats.ByProtocol[protocol] = count
|
||||
}
|
||||
rows.Close()
|
||||
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
// scanProxies 扫描多条代理记录
|
||||
func scanProxies(rows pgx.Rows) ([]model.Proxy, error) {
|
||||
var proxies []model.Proxy
|
||||
for rows.Next() {
|
||||
p, err := scanProxyRow(rows)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
proxies = append(proxies, *p)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, fmt.Errorf("error iterating rows: %w", err)
|
||||
}
|
||||
return proxies, nil
|
||||
}
|
||||
|
||||
// scanProxy 扫描单条代理记录
|
||||
func scanProxy(row pgx.Row) (*model.Proxy, error) {
|
||||
var p model.Proxy
|
||||
var lastCheckAt *time.Time
|
||||
|
||||
err := row.Scan(
|
||||
&p.ID, &p.Protocol, &p.Host, &p.Port, &p.Username, &p.Password,
|
||||
&p.Group, &p.Tags, &p.Status, &p.Score, &p.LatencyMs, &lastCheckAt,
|
||||
&p.FailCount, &p.SuccessCount, &p.Disabled, &p.CreatedAt, &p.UpdatedAt,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if lastCheckAt != nil {
|
||||
p.LastCheckAt = *lastCheckAt
|
||||
}
|
||||
|
||||
return &p, nil
|
||||
}
|
||||
|
||||
// scanProxyRow 从 Rows 扫描单条代理记录
|
||||
func scanProxyRow(rows pgx.Rows) (*model.Proxy, error) {
|
||||
var p model.Proxy
|
||||
var lastCheckAt *time.Time
|
||||
|
||||
err := rows.Scan(
|
||||
&p.ID, &p.Protocol, &p.Host, &p.Port, &p.Username, &p.Password,
|
||||
&p.Group, &p.Tags, &p.Status, &p.Score, &p.LatencyMs, &lastCheckAt,
|
||||
&p.FailCount, &p.SuccessCount, &p.Disabled, &p.CreatedAt, &p.UpdatedAt,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if lastCheckAt != nil {
|
||||
p.LastCheckAt = *lastCheckAt
|
||||
}
|
||||
|
||||
return &p, nil
|
||||
}
|
||||
55
internal/store/store.go
Normal file
55
internal/store/store.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"proxyrotator/internal/model"
|
||||
)
|
||||
|
||||
// ProxyStore 代理存储接口
|
||||
type ProxyStore interface {
|
||||
// UpsertMany 批量导入代理(upsert + 去重统计)
|
||||
UpsertMany(ctx context.Context, proxies []model.Proxy) (imported, duplicated int, err error)
|
||||
|
||||
// List 查询代理列表
|
||||
List(ctx context.Context, q model.ProxyQuery) ([]model.Proxy, error)
|
||||
|
||||
// ListPaginated 分页查询代理列表,返回数据和总数
|
||||
ListPaginated(ctx context.Context, q model.ProxyListQuery) ([]model.Proxy, int, error)
|
||||
|
||||
// GetByID 根据 ID 获取代理
|
||||
GetByID(ctx context.Context, id string) (*model.Proxy, error)
|
||||
|
||||
// UpdateHealth 更新代理健康度
|
||||
UpdateHealth(ctx context.Context, proxyID string, patch model.HealthPatch) error
|
||||
|
||||
// Update 更新代理字段
|
||||
Update(ctx context.Context, id string, patch model.ProxyPatch) error
|
||||
|
||||
// Delete 删除单个代理
|
||||
Delete(ctx context.Context, id string) error
|
||||
|
||||
// DeleteMany 批量删除代理
|
||||
DeleteMany(ctx context.Context, req model.BulkDeleteRequest) (int64, error)
|
||||
|
||||
// GetStats 获取代理统计信息
|
||||
GetStats(ctx context.Context) (*model.ProxyStats, error)
|
||||
|
||||
// NextIndex RR 原子游标:返回 [0, modulo) 的索引
|
||||
NextIndex(ctx context.Context, key string, modulo int) (int, error)
|
||||
|
||||
// CreateLease 创建租约
|
||||
CreateLease(ctx context.Context, lease model.Lease) error
|
||||
|
||||
// GetLease 获取租约
|
||||
GetLease(ctx context.Context, leaseID string) (*model.Lease, error)
|
||||
|
||||
// DeleteExpiredLeases 删除过期租约
|
||||
DeleteExpiredLeases(ctx context.Context) (int64, error)
|
||||
|
||||
// InsertTestLog 插入测试日志
|
||||
InsertTestLog(ctx context.Context, r model.TestResult, site string) error
|
||||
|
||||
// Close 关闭连接
|
||||
Close() error
|
||||
}
|
||||
197
internal/telegram/bot.go
Normal file
197
internal/telegram/bot.go
Normal file
@@ -0,0 +1,197 @@
|
||||
package telegram
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"proxyrotator/internal/config"
|
||||
"proxyrotator/internal/store"
|
||||
|
||||
tele "gopkg.in/telebot.v3"
|
||||
)
|
||||
|
||||
// Bot Telegram Bot 管理器
|
||||
type Bot struct {
|
||||
mu sync.RWMutex
|
||||
bot *tele.Bot
|
||||
cfg *config.Config
|
||||
store store.ProxyStore
|
||||
|
||||
scheduler *Scheduler
|
||||
notifier *Notifier
|
||||
|
||||
running bool
|
||||
stopChan chan struct{}
|
||||
}
|
||||
|
||||
// Status Bot 状态
|
||||
type Status struct {
|
||||
Running bool `json:"running"`
|
||||
Connected bool `json:"connected"`
|
||||
Username string `json:"username,omitempty"`
|
||||
}
|
||||
|
||||
// NewBot 创建 Bot 实例
|
||||
func NewBot(cfg *config.Config, proxyStore store.ProxyStore) *Bot {
|
||||
return &Bot{
|
||||
cfg: cfg,
|
||||
store: proxyStore,
|
||||
stopChan: make(chan struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
// Start 启动 Bot
|
||||
func (b *Bot) Start(ctx context.Context) error {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
|
||||
if b.running {
|
||||
return nil
|
||||
}
|
||||
|
||||
if b.cfg.TelegramBotToken == "" {
|
||||
slog.Info("telegram bot token not configured, skipping")
|
||||
return nil
|
||||
}
|
||||
|
||||
return b.startInternal()
|
||||
}
|
||||
|
||||
// startInternal 内部启动(需要持有锁)
|
||||
func (b *Bot) startInternal() error {
|
||||
pref := tele.Settings{
|
||||
Token: b.cfg.TelegramBotToken,
|
||||
Poller: &tele.LongPoller{Timeout: 10 * time.Second},
|
||||
}
|
||||
|
||||
bot, err := tele.NewBot(pref)
|
||||
if err != nil {
|
||||
slog.Error("failed to create telegram bot", "error", err)
|
||||
return err
|
||||
}
|
||||
|
||||
b.bot = bot
|
||||
b.notifier = NewNotifier(bot, b.cfg.TelegramNotifyChatID)
|
||||
b.scheduler = NewScheduler(b.store, b.notifier, b.cfg)
|
||||
|
||||
// 注册命令处理器
|
||||
b.registerCommands(b.cfg.TelegramAdminIDs)
|
||||
|
||||
// 启动调度器
|
||||
b.scheduler.Start()
|
||||
|
||||
// 注册命令菜单
|
||||
commands := []tele.Command{
|
||||
{Text: "stats", Description: "查看代理池统计"},
|
||||
{Text: "groups", Description: "查看分组统计"},
|
||||
{Text: "get", Description: "获取可用代理 (默认1个,如 /get 5)"},
|
||||
{Text: "import", Description: "导入代理 (如 /import groupname)"},
|
||||
{Text: "test", Description: "触发测活 (如 /test groupname)"},
|
||||
{Text: "purge", Description: "清理死代理"},
|
||||
{Text: "help", Description: "显示帮助信息"},
|
||||
}
|
||||
if err := bot.SetCommands(commands); err != nil {
|
||||
slog.Warn("failed to set bot commands", "error", err)
|
||||
}
|
||||
|
||||
// 启动 Bot
|
||||
b.stopChan = make(chan struct{})
|
||||
go func() {
|
||||
slog.Info("telegram bot started", "username", bot.Me.Username)
|
||||
bot.Start()
|
||||
}()
|
||||
|
||||
b.running = true
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stop 停止 Bot
|
||||
func (b *Bot) Stop() {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
|
||||
b.stopInternal()
|
||||
}
|
||||
|
||||
// stopInternal 内部停止(需要持有锁)
|
||||
func (b *Bot) stopInternal() {
|
||||
if !b.running {
|
||||
return
|
||||
}
|
||||
|
||||
if b.scheduler != nil {
|
||||
b.scheduler.Stop()
|
||||
}
|
||||
|
||||
if b.bot != nil {
|
||||
b.bot.Stop()
|
||||
slog.Info("telegram bot stopped")
|
||||
}
|
||||
|
||||
close(b.stopChan)
|
||||
b.running = false
|
||||
}
|
||||
|
||||
// Status 获取 Bot 状态
|
||||
func (b *Bot) Status() Status {
|
||||
b.mu.RLock()
|
||||
defer b.mu.RUnlock()
|
||||
|
||||
status := Status{
|
||||
Running: b.running,
|
||||
}
|
||||
|
||||
if b.bot != nil && b.running {
|
||||
status.Connected = true
|
||||
status.Username = b.bot.Me.Username
|
||||
}
|
||||
|
||||
return status
|
||||
}
|
||||
|
||||
// TriggerTest 手动触发测活
|
||||
func (b *Bot) TriggerTest(ctx context.Context) error {
|
||||
b.mu.RLock()
|
||||
defer b.mu.RUnlock()
|
||||
|
||||
if b.scheduler == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return b.scheduler.RunTest(ctx)
|
||||
}
|
||||
|
||||
// registerCommands 注册命令
|
||||
func (b *Bot) registerCommands(adminIDs []int64) {
|
||||
// 管理员权限中间件
|
||||
adminOnly := func(next tele.HandlerFunc) tele.HandlerFunc {
|
||||
return func(c tele.Context) error {
|
||||
if len(adminIDs) == 0 {
|
||||
return next(c)
|
||||
}
|
||||
userID := c.Sender().ID
|
||||
for _, id := range adminIDs {
|
||||
if id == userID {
|
||||
return next(c)
|
||||
}
|
||||
}
|
||||
return c.Send("⛔ 无权限访问")
|
||||
}
|
||||
}
|
||||
|
||||
// 创建命令处理器
|
||||
cmds := NewCommands(b.store, b.scheduler)
|
||||
|
||||
b.bot.Handle("/start", adminOnly(cmds.HandleStart))
|
||||
b.bot.Handle("/help", adminOnly(cmds.HandleHelp))
|
||||
b.bot.Handle("/stats", adminOnly(cmds.HandleStats))
|
||||
b.bot.Handle("/groups", adminOnly(cmds.HandleGroups))
|
||||
b.bot.Handle("/get", adminOnly(cmds.HandleGet))
|
||||
b.bot.Handle("/test", adminOnly(cmds.HandleTest))
|
||||
b.bot.Handle("/purge", adminOnly(cmds.HandlePurge))
|
||||
b.bot.Handle("/import", adminOnly(cmds.HandleImport))
|
||||
b.bot.Handle(tele.OnDocument, adminOnly(cmds.HandleDocument))
|
||||
b.bot.Handle(tele.OnText, adminOnly(cmds.HandleText))
|
||||
}
|
||||
365
internal/telegram/commands.go
Normal file
365
internal/telegram/commands.go
Normal file
@@ -0,0 +1,365 @@
|
||||
package telegram
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"proxyrotator/internal/importer"
|
||||
"proxyrotator/internal/model"
|
||||
"proxyrotator/internal/store"
|
||||
|
||||
tele "gopkg.in/telebot.v3"
|
||||
)
|
||||
|
||||
// Commands 命令处理器
|
||||
type Commands struct {
|
||||
store store.ProxyStore
|
||||
scheduler *Scheduler
|
||||
importer *importer.Importer
|
||||
|
||||
// 导入状态
|
||||
importState map[int64]*importSession
|
||||
}
|
||||
|
||||
type importSession struct {
|
||||
Group string
|
||||
Tags []string
|
||||
}
|
||||
|
||||
// NewCommands 创建命令处理器
|
||||
func NewCommands(store store.ProxyStore, scheduler *Scheduler) *Commands {
|
||||
return &Commands{
|
||||
store: store,
|
||||
scheduler: scheduler,
|
||||
importer: importer.NewImporter(),
|
||||
importState: make(map[int64]*importSession),
|
||||
}
|
||||
}
|
||||
|
||||
// HandleStart /start 命令
|
||||
func (c *Commands) HandleStart(ctx tele.Context) error {
|
||||
return ctx.Send(`🚀 *ProxyRotator Bot*
|
||||
|
||||
欢迎使用代理池管理机器人!
|
||||
|
||||
使用 /help 查看可用命令`, &tele.SendOptions{ParseMode: tele.ModeMarkdown})
|
||||
}
|
||||
|
||||
// HandleHelp /help 命令
|
||||
func (c *Commands) HandleHelp(ctx tele.Context) error {
|
||||
help := `📖 *可用命令*
|
||||
|
||||
*查询类*
|
||||
/stats - 代理池统计(总数/存活/死亡/未知)
|
||||
/groups - 分组统计
|
||||
/get [n] - 获取 n 个可用代理(默认 5)
|
||||
|
||||
*操作类*
|
||||
/import [group] - 导入代理(之后发送文本或文件)
|
||||
/test [group] - 触发测活
|
||||
/purge - 清理死代理
|
||||
|
||||
*其他*
|
||||
/help - 显示帮助信息`
|
||||
|
||||
return ctx.Send(help, &tele.SendOptions{ParseMode: tele.ModeMarkdown})
|
||||
}
|
||||
|
||||
// HandleStats /stats 命令
|
||||
func (c *Commands) HandleStats(ctx tele.Context) error {
|
||||
stats, err := c.store.GetStats(context.Background())
|
||||
if err != nil {
|
||||
return ctx.Send(fmt.Sprintf("❌ 获取统计失败: %v", err))
|
||||
}
|
||||
|
||||
alive := stats.ByStatus[model.StatusAlive]
|
||||
dead := stats.ByStatus[model.StatusDead]
|
||||
unknown := stats.ByStatus[model.StatusUnknown]
|
||||
|
||||
var alivePercent float64
|
||||
if stats.Total > 0 {
|
||||
alivePercent = float64(alive) / float64(stats.Total) * 100
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf(`📊 *代理池统计*
|
||||
|
||||
*总数:* %d
|
||||
*存活:* %d (%.1f%%)
|
||||
*死亡:* %d
|
||||
*未知:* %d
|
||||
*禁用:* %d
|
||||
|
||||
*平均延迟:* %d ms
|
||||
*平均分数:* %.1f`,
|
||||
stats.Total,
|
||||
alive, alivePercent,
|
||||
dead,
|
||||
unknown,
|
||||
stats.Disabled,
|
||||
stats.AvgLatencyMs,
|
||||
stats.AvgScore,
|
||||
)
|
||||
|
||||
return ctx.Send(msg, &tele.SendOptions{ParseMode: tele.ModeMarkdown})
|
||||
}
|
||||
|
||||
// HandleGroups /groups 命令
|
||||
func (c *Commands) HandleGroups(ctx tele.Context) error {
|
||||
stats, err := c.store.GetStats(context.Background())
|
||||
if err != nil {
|
||||
return ctx.Send(fmt.Sprintf("❌ 获取统计失败: %v", err))
|
||||
}
|
||||
|
||||
if len(stats.ByGroup) == 0 {
|
||||
return ctx.Send("📁 暂无分组数据")
|
||||
}
|
||||
|
||||
var sb strings.Builder
|
||||
sb.WriteString("📁 *分组统计*\n\n")
|
||||
for group, count := range stats.ByGroup {
|
||||
sb.WriteString(fmt.Sprintf("• `%s`: %d\n", group, count))
|
||||
}
|
||||
|
||||
return ctx.Send(sb.String(), &tele.SendOptions{ParseMode: tele.ModeMarkdown})
|
||||
}
|
||||
|
||||
// IPInfo ipinfo.io 返回结构
|
||||
type IPInfo struct {
|
||||
IP string `json:"ip"`
|
||||
City string `json:"city"`
|
||||
Region string `json:"region"`
|
||||
Country string `json:"country"`
|
||||
Org string `json:"org"`
|
||||
}
|
||||
|
||||
// HandleGet /get [n] 命令
|
||||
func (c *Commands) HandleGet(ctx tele.Context) error {
|
||||
n := 1
|
||||
args := ctx.Args()
|
||||
if len(args) > 0 {
|
||||
if parsed, err := strconv.Atoi(args[0]); err == nil && parsed > 0 {
|
||||
n = parsed
|
||||
}
|
||||
}
|
||||
if n > 20 {
|
||||
n = 20
|
||||
}
|
||||
|
||||
proxies, err := c.store.List(context.Background(), model.ProxyQuery{
|
||||
StatusIn: []model.ProxyStatus{model.StatusAlive},
|
||||
OnlyEnabled: true,
|
||||
OrderBy: "random",
|
||||
Limit: n,
|
||||
})
|
||||
if err != nil {
|
||||
return ctx.Send(fmt.Sprintf("❌ 获取代理失败: %v", err))
|
||||
}
|
||||
|
||||
if len(proxies) == 0 {
|
||||
return ctx.Send("😢 没有可用代理")
|
||||
}
|
||||
|
||||
var sb strings.Builder
|
||||
sb.WriteString(fmt.Sprintf("🔗 *可用代理 (%d)*\n\n", len(proxies)))
|
||||
|
||||
for _, p := range proxies {
|
||||
var proxyURL string
|
||||
if p.Username != "" {
|
||||
proxyURL = fmt.Sprintf("%s://%s:%s@%s:%d", p.Protocol, p.Username, p.Password, p.Host, p.Port)
|
||||
} else {
|
||||
proxyURL = fmt.Sprintf("%s://%s:%d", p.Protocol, p.Host, p.Port)
|
||||
}
|
||||
|
||||
// 获取 IP 位置信息
|
||||
ipInfo := fetchIPInfo(proxyURL)
|
||||
|
||||
sb.WriteString(fmt.Sprintf("`%s`\n", proxyURL))
|
||||
if ipInfo != nil {
|
||||
location := fmt.Sprintf("%s, %s, %s", ipInfo.City, ipInfo.Region, ipInfo.Country)
|
||||
sb.WriteString(fmt.Sprintf(" 📍 %s | %s\n", location, ipInfo.Org))
|
||||
} else {
|
||||
sb.WriteString(" 📍 位置获取失败\n")
|
||||
}
|
||||
sb.WriteString("\n")
|
||||
}
|
||||
|
||||
return ctx.Send(sb.String(), &tele.SendOptions{ParseMode: tele.ModeMarkdown})
|
||||
}
|
||||
|
||||
// fetchIPInfo 通过代理获取 IP 信息
|
||||
func fetchIPInfo(proxyURL string) *IPInfo {
|
||||
proxy, err := url.Parse(proxyURL)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
client := &http.Client{
|
||||
Transport: &http.Transport{
|
||||
Proxy: http.ProxyURL(proxy),
|
||||
},
|
||||
Timeout: 10 * time.Second,
|
||||
}
|
||||
|
||||
resp, err := client.Get("https://ipinfo.io/json")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
var info IPInfo
|
||||
if err := json.NewDecoder(resp.Body).Decode(&info); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &info
|
||||
}
|
||||
|
||||
// HandleTest /test [group] 命令
|
||||
func (c *Commands) HandleTest(ctx tele.Context) error {
|
||||
if c.scheduler == nil {
|
||||
return ctx.Send("❌ 调度器未初始化")
|
||||
}
|
||||
|
||||
group := ""
|
||||
args := ctx.Args()
|
||||
if len(args) > 0 {
|
||||
group = args[0]
|
||||
}
|
||||
|
||||
_ = ctx.Send("🔄 正在执行测活...")
|
||||
|
||||
err := c.scheduler.RunTestWithGroup(context.Background(), group)
|
||||
if err != nil {
|
||||
return ctx.Send(fmt.Sprintf("❌ 测活失败: %v", err))
|
||||
}
|
||||
|
||||
return ctx.Send("✅ 测活完成")
|
||||
}
|
||||
|
||||
// HandlePurge /purge 命令
|
||||
func (c *Commands) HandlePurge(ctx tele.Context) error {
|
||||
deleted, err := c.store.DeleteMany(context.Background(), model.BulkDeleteRequest{
|
||||
Status: model.StatusDead,
|
||||
})
|
||||
if err != nil {
|
||||
return ctx.Send(fmt.Sprintf("❌ 清理失败: %v", err))
|
||||
}
|
||||
|
||||
return ctx.Send(fmt.Sprintf("🗑️ 已清理 %d 个死代理", deleted))
|
||||
}
|
||||
|
||||
// HandleImport /import [group] 命令
|
||||
func (c *Commands) HandleImport(ctx tele.Context) error {
|
||||
group := "default"
|
||||
args := ctx.Args()
|
||||
if len(args) > 0 {
|
||||
group = args[0]
|
||||
}
|
||||
|
||||
userID := ctx.Sender().ID
|
||||
c.importState[userID] = &importSession{
|
||||
Group: group,
|
||||
Tags: []string{"telegram"},
|
||||
}
|
||||
|
||||
return ctx.Send(fmt.Sprintf(`📥 *导入模式已开启*
|
||||
|
||||
分组: `+"`%s`"+`
|
||||
|
||||
请发送代理列表(文本或文件),支持格式:
|
||||
• host:port
|
||||
• host:port:user:pass
|
||||
• protocol://host:port
|
||||
• protocol://user:pass@host:port
|
||||
|
||||
发送 /cancel 取消导入`, group), &tele.SendOptions{ParseMode: tele.ModeMarkdown})
|
||||
}
|
||||
|
||||
// HandleDocument 处理文件上传
|
||||
func (c *Commands) HandleDocument(ctx tele.Context) error {
|
||||
userID := ctx.Sender().ID
|
||||
session, ok := c.importState[userID]
|
||||
if !ok {
|
||||
return nil // 不在导入模式,忽略
|
||||
}
|
||||
|
||||
doc := ctx.Message().Document
|
||||
if doc == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 下载文件
|
||||
reader, err := ctx.Bot().File(&doc.File)
|
||||
if err != nil {
|
||||
return ctx.Send(fmt.Sprintf("❌ 获取文件失败: %v", err))
|
||||
}
|
||||
defer reader.Close()
|
||||
|
||||
content, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
return ctx.Send(fmt.Sprintf("❌ 读取文件失败: %v", err))
|
||||
}
|
||||
|
||||
return c.doImport(ctx, session, string(content))
|
||||
}
|
||||
|
||||
// HandleText 处理文本消息(用于导入)
|
||||
func (c *Commands) HandleText(ctx tele.Context) error {
|
||||
userID := ctx.Sender().ID
|
||||
session, ok := c.importState[userID]
|
||||
if !ok {
|
||||
return nil // 不在导入模式,忽略
|
||||
}
|
||||
|
||||
text := ctx.Text()
|
||||
if text == "/cancel" {
|
||||
delete(c.importState, userID)
|
||||
return ctx.Send("❌ 已取消导入")
|
||||
}
|
||||
|
||||
// 检查是否像代理格式
|
||||
if !strings.Contains(text, ":") {
|
||||
return nil // 不像代理,忽略
|
||||
}
|
||||
|
||||
return c.doImport(ctx, session, text)
|
||||
}
|
||||
|
||||
// doImport 执行导入
|
||||
func (c *Commands) doImport(ctx tele.Context, session *importSession, text string) error {
|
||||
userID := ctx.Sender().ID
|
||||
defer delete(c.importState, userID)
|
||||
|
||||
input := model.ImportInput{
|
||||
Group: session.Group,
|
||||
Tags: session.Tags,
|
||||
}
|
||||
|
||||
proxies, invalid := c.importer.ParseText(context.Background(), input, text)
|
||||
|
||||
if len(proxies) == 0 {
|
||||
return ctx.Send(fmt.Sprintf("❌ 未解析到有效代理\n无效行: %d", len(invalid)))
|
||||
}
|
||||
|
||||
imported, duplicated, err := c.store.UpsertMany(context.Background(), proxies)
|
||||
if err != nil {
|
||||
return ctx.Send(fmt.Sprintf("❌ 导入失败: %v", err))
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf(`✅ *导入完成*
|
||||
|
||||
• 新增: %d
|
||||
• 重复: %d
|
||||
• 无效: %d
|
||||
• 分组: `+"`%s`",
|
||||
imported, duplicated, len(invalid), session.Group)
|
||||
|
||||
return ctx.Send(msg, &tele.SendOptions{ParseMode: tele.ModeMarkdown})
|
||||
}
|
||||
83
internal/telegram/notifier.go
Normal file
83
internal/telegram/notifier.go
Normal file
@@ -0,0 +1,83 @@
|
||||
package telegram
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"strconv"
|
||||
|
||||
tele "gopkg.in/telebot.v3"
|
||||
)
|
||||
|
||||
// Notifier 告警通知器
|
||||
type Notifier struct {
|
||||
bot *tele.Bot
|
||||
chatID string
|
||||
}
|
||||
|
||||
// NewNotifier 创建通知器
|
||||
func NewNotifier(bot *tele.Bot, chatID string) *Notifier {
|
||||
return &Notifier{
|
||||
bot: bot,
|
||||
chatID: chatID,
|
||||
}
|
||||
}
|
||||
|
||||
// SendAlert 发送告警
|
||||
func (n *Notifier) SendAlert(ctx context.Context, alive, dead, total int, alivePercent float64) {
|
||||
if n.chatID == "" {
|
||||
slog.Warn("notify_chat_id not configured, skipping alert")
|
||||
return
|
||||
}
|
||||
|
||||
chatID, err := strconv.ParseInt(n.chatID, 10, 64)
|
||||
if err != nil {
|
||||
slog.Error("invalid chat_id", "chat_id", n.chatID, "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf(`🚨 *代理池告警*
|
||||
|
||||
存活率低于阈值!
|
||||
|
||||
*统计:*
|
||||
• 存活: %d (%.1f%%)
|
||||
• 死亡: %d
|
||||
• 总数: %d
|
||||
|
||||
请及时补充代理或检查网络状况。`, alive, alivePercent, dead, total)
|
||||
|
||||
chat, err := n.bot.ChatByID(chatID)
|
||||
if err != nil {
|
||||
slog.Error("failed to get chat", "chat_id", n.chatID, "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = n.bot.Send(chat, msg, &tele.SendOptions{ParseMode: tele.ModeMarkdown})
|
||||
if err != nil {
|
||||
slog.Error("failed to send alert", "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
slog.Info("alert sent", "chat_id", n.chatID, "alive_percent", alivePercent)
|
||||
}
|
||||
|
||||
// SendMessage 发送普通消息
|
||||
func (n *Notifier) SendMessage(ctx context.Context, message string) error {
|
||||
if n.chatID == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
chatID, err := strconv.ParseInt(n.chatID, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
chat, err := n.bot.ChatByID(chatID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = n.bot.Send(chat, message, &tele.SendOptions{ParseMode: tele.ModeMarkdown})
|
||||
return err
|
||||
}
|
||||
167
internal/telegram/scheduler.go
Normal file
167
internal/telegram/scheduler.go
Normal file
@@ -0,0 +1,167 @@
|
||||
package telegram
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"proxyrotator/internal/config"
|
||||
"proxyrotator/internal/model"
|
||||
"proxyrotator/internal/store"
|
||||
"proxyrotator/internal/tester"
|
||||
)
|
||||
|
||||
// Scheduler 定时测活调度器
|
||||
type Scheduler struct {
|
||||
mu sync.Mutex
|
||||
store store.ProxyStore
|
||||
notifier *Notifier
|
||||
tester *tester.HTTPTester
|
||||
cfg *config.Config
|
||||
|
||||
ticker *time.Ticker
|
||||
stopChan chan struct{}
|
||||
running bool
|
||||
}
|
||||
|
||||
// NewScheduler 创建调度器
|
||||
func NewScheduler(store store.ProxyStore, notifier *Notifier, cfg *config.Config) *Scheduler {
|
||||
return &Scheduler{
|
||||
store: store,
|
||||
notifier: notifier,
|
||||
tester: tester.NewHTTPTester(),
|
||||
cfg: cfg,
|
||||
stopChan: make(chan struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
// Start 启动调度器
|
||||
func (s *Scheduler) Start() {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
if s.running {
|
||||
return
|
||||
}
|
||||
|
||||
interval := time.Duration(s.cfg.TelegramTestIntervalMin) * time.Minute
|
||||
if interval < 5*time.Minute {
|
||||
interval = 5 * time.Minute
|
||||
}
|
||||
|
||||
s.ticker = time.NewTicker(interval)
|
||||
s.stopChan = make(chan struct{})
|
||||
s.running = true
|
||||
|
||||
go s.loop()
|
||||
slog.Info("telegram scheduler started", "interval", interval)
|
||||
}
|
||||
|
||||
// Stop 停止调度器
|
||||
func (s *Scheduler) Stop() {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
if !s.running {
|
||||
return
|
||||
}
|
||||
|
||||
if s.ticker != nil {
|
||||
s.ticker.Stop()
|
||||
}
|
||||
close(s.stopChan)
|
||||
s.running = false
|
||||
slog.Info("telegram scheduler stopped")
|
||||
}
|
||||
|
||||
// loop 调度循环
|
||||
func (s *Scheduler) loop() {
|
||||
for {
|
||||
select {
|
||||
case <-s.stopChan:
|
||||
return
|
||||
case <-s.ticker.C:
|
||||
if err := s.RunTest(context.Background()); err != nil {
|
||||
slog.Error("scheduled test failed", "error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RunTest 执行测活(所有分组)
|
||||
func (s *Scheduler) RunTest(ctx context.Context) error {
|
||||
return s.RunTestWithGroup(ctx, "")
|
||||
}
|
||||
|
||||
// RunTestWithGroup 执行测活(指定分组)
|
||||
func (s *Scheduler) RunTestWithGroup(ctx context.Context, group string) error {
|
||||
slog.Info("running scheduled proxy test", "group", group)
|
||||
|
||||
// 获取待测试代理
|
||||
query := model.ProxyQuery{
|
||||
Group: group,
|
||||
StatusIn: []model.ProxyStatus{model.StatusUnknown, model.StatusAlive},
|
||||
OnlyEnabled: true,
|
||||
Limit: 1000,
|
||||
}
|
||||
|
||||
proxies, err := s.store.List(ctx, query)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(proxies) == 0 {
|
||||
slog.Info("no proxies to test")
|
||||
return nil
|
||||
}
|
||||
|
||||
// 构建测试规格
|
||||
spec := model.TestSpec{
|
||||
URL: s.cfg.TelegramTestURL,
|
||||
Method: "GET",
|
||||
Timeout: time.Duration(s.cfg.TelegramTestTimeoutMs) * time.Millisecond,
|
||||
}
|
||||
|
||||
// 执行测试
|
||||
results := s.tester.TestBatch(ctx, proxies, spec, 50)
|
||||
|
||||
// 统计结果
|
||||
alive, dead := 0, 0
|
||||
for _, r := range results {
|
||||
now := r.CheckedAt
|
||||
if r.OK {
|
||||
alive++
|
||||
status := model.StatusAlive
|
||||
_ = s.store.UpdateHealth(ctx, r.ProxyID, model.HealthPatch{
|
||||
Status: &status,
|
||||
ScoreDelta: 1,
|
||||
SuccessInc: 1,
|
||||
LatencyMs: &r.LatencyMs,
|
||||
CheckedAt: &now,
|
||||
})
|
||||
} else {
|
||||
dead++
|
||||
status := model.StatusDead
|
||||
_ = s.store.UpdateHealth(ctx, r.ProxyID, model.HealthPatch{
|
||||
Status: &status,
|
||||
ScoreDelta: -3,
|
||||
FailInc: 1,
|
||||
CheckedAt: &now,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
slog.Info("scheduled test completed", "tested", len(results), "alive", alive, "dead", dead)
|
||||
|
||||
// 检查是否需要告警
|
||||
total := len(results)
|
||||
if total > 0 {
|
||||
alivePercent := float64(alive) / float64(total) * 100
|
||||
if alivePercent < float64(s.cfg.TelegramAlertThreshold) {
|
||||
s.notifier.SendAlert(ctx, alive, dead, total, alivePercent)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
246
internal/tester/http_tester.go
Normal file
246
internal/tester/http_tester.go
Normal file
@@ -0,0 +1,246 @@
|
||||
package tester
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/proxy"
|
||||
|
||||
"proxyrotator/internal/model"
|
||||
)
|
||||
|
||||
// HTTPTester HTTP 代理测试器
|
||||
type HTTPTester struct {
|
||||
maxBodySize int64
|
||||
}
|
||||
|
||||
// NewHTTPTester 创建测试器
|
||||
func NewHTTPTester() *HTTPTester {
|
||||
return &HTTPTester{
|
||||
maxBodySize: 1024 * 1024, // 1MB
|
||||
}
|
||||
}
|
||||
|
||||
// TestOne 测试单个代理
|
||||
func (t *HTTPTester) TestOne(ctx context.Context, p model.Proxy, spec model.TestSpec) model.TestResult {
|
||||
result := model.TestResult{
|
||||
ProxyID: p.ID,
|
||||
CheckedAt: time.Now(),
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
|
||||
// 创建 HTTP 客户端
|
||||
client, err := t.createClient(p, spec.Timeout)
|
||||
if err != nil {
|
||||
result.ErrorText = err.Error()
|
||||
result.LatencyMs = time.Since(start).Milliseconds()
|
||||
return result
|
||||
}
|
||||
|
||||
// 创建请求
|
||||
method := spec.Method
|
||||
if method == "" {
|
||||
method = "GET"
|
||||
}
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, method, spec.URL, nil)
|
||||
if err != nil {
|
||||
result.ErrorText = fmt.Sprintf("create request failed: %v", err)
|
||||
result.LatencyMs = time.Since(start).Milliseconds()
|
||||
return result
|
||||
}
|
||||
|
||||
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36")
|
||||
|
||||
// 发起请求
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
result.ErrorText = err.Error()
|
||||
result.LatencyMs = time.Since(start).Milliseconds()
|
||||
return result
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
result.LatencyMs = time.Since(start).Milliseconds()
|
||||
|
||||
// 检查状态码
|
||||
if len(spec.ExpectStatus) > 0 {
|
||||
found := false
|
||||
for _, s := range spec.ExpectStatus {
|
||||
if resp.StatusCode == s {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
result.ErrorText = fmt.Sprintf("unexpected status: %d", resp.StatusCode)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
// 检查响应体关键字
|
||||
if spec.ExpectContains != "" {
|
||||
body, err := io.ReadAll(io.LimitReader(resp.Body, t.maxBodySize))
|
||||
if err != nil {
|
||||
result.ErrorText = fmt.Sprintf("read body failed: %v", err)
|
||||
return result
|
||||
}
|
||||
if !strings.Contains(string(body), spec.ExpectContains) {
|
||||
result.ErrorText = "expected content not found"
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
result.OK = true
|
||||
return result
|
||||
}
|
||||
|
||||
// TestBatch 并发测试多个代理
|
||||
func (t *HTTPTester) TestBatch(ctx context.Context, proxies []model.Proxy, spec model.TestSpec, concurrency int) []model.TestResult {
|
||||
if concurrency <= 0 {
|
||||
concurrency = 10
|
||||
}
|
||||
|
||||
jobs := make(chan model.Proxy, len(proxies))
|
||||
results := make(chan model.TestResult, len(proxies))
|
||||
|
||||
// 启动 worker
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < concurrency; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for p := range jobs {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
results <- model.TestResult{
|
||||
ProxyID: p.ID,
|
||||
ErrorText: "context cancelled",
|
||||
CheckedAt: time.Now(),
|
||||
}
|
||||
default:
|
||||
results <- t.TestOne(ctx, p, spec)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// 发送任务
|
||||
go func() {
|
||||
for _, p := range proxies {
|
||||
jobs <- p
|
||||
}
|
||||
close(jobs)
|
||||
}()
|
||||
|
||||
// 等待完成
|
||||
go func() {
|
||||
wg.Wait()
|
||||
close(results)
|
||||
}()
|
||||
|
||||
// 收集结果
|
||||
out := make([]model.TestResult, 0, len(proxies))
|
||||
for r := range results {
|
||||
out = append(out, r)
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
// createClient 根据代理类型创建 HTTP 客户端
|
||||
func (t *HTTPTester) createClient(p model.Proxy, timeout time.Duration) (*http.Client, error) {
|
||||
if timeout <= 0 {
|
||||
timeout = 10 * time.Second
|
||||
}
|
||||
|
||||
transport := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
},
|
||||
DisableKeepAlives: true,
|
||||
TLSHandshakeTimeout: timeout,
|
||||
ResponseHeaderTimeout: timeout,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
// 代理连接设置
|
||||
ProxyConnectHeader: http.Header{},
|
||||
}
|
||||
|
||||
switch p.Protocol {
|
||||
case model.ProtoHTTP, model.ProtoHTTPS:
|
||||
proxyURL := t.buildProxyURL(p)
|
||||
transport.Proxy = http.ProxyURL(proxyURL)
|
||||
|
||||
case model.ProtoSOCKS5:
|
||||
dialer, err := t.createSOCKS5Dialer(p, timeout)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
transport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
return dialer.Dial(network, addr)
|
||||
}
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported protocol: %s", p.Protocol)
|
||||
}
|
||||
|
||||
return &http.Client{
|
||||
Transport: transport,
|
||||
Timeout: timeout,
|
||||
// 不自动跟随重定向,让我们检查原始响应
|
||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
if len(via) >= 10 {
|
||||
return fmt.Errorf("too many redirects")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// buildProxyURL 构建代理 URL
|
||||
func (t *HTTPTester) buildProxyURL(p model.Proxy) *url.URL {
|
||||
scheme := "http"
|
||||
if p.Protocol == model.ProtoHTTPS {
|
||||
scheme = "https"
|
||||
}
|
||||
|
||||
u := &url.URL{
|
||||
Scheme: scheme,
|
||||
Host: fmt.Sprintf("%s:%d", p.Host, p.Port),
|
||||
}
|
||||
|
||||
if p.Username != "" {
|
||||
u.User = url.UserPassword(p.Username, p.Password)
|
||||
}
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
// createSOCKS5Dialer 创建 SOCKS5 拨号器
|
||||
func (t *HTTPTester) createSOCKS5Dialer(p model.Proxy, timeout time.Duration) (proxy.Dialer, error) {
|
||||
addr := fmt.Sprintf("%s:%d", p.Host, p.Port)
|
||||
|
||||
var auth *proxy.Auth
|
||||
if p.Username != "" {
|
||||
auth = &proxy.Auth{
|
||||
User: p.Username,
|
||||
Password: p.Password,
|
||||
}
|
||||
}
|
||||
|
||||
// 创建基础拨号器带超时
|
||||
baseDialer := &net.Dialer{
|
||||
Timeout: timeout,
|
||||
}
|
||||
|
||||
return proxy.SOCKS5("tcp", addr, auth, baseDialer)
|
||||
}
|
||||
95
migrations/001_init.sql
Normal file
95
migrations/001_init.sql
Normal file
@@ -0,0 +1,95 @@
|
||||
-- 代理池管理系统数据库初始化脚本
|
||||
|
||||
-- 创建枚举类型
|
||||
CREATE TYPE proxy_protocol AS ENUM ('http', 'https', 'socks5');
|
||||
CREATE TYPE proxy_status AS ENUM ('unknown', 'alive', 'dead');
|
||||
|
||||
-- 代理主表
|
||||
CREATE TABLE proxies (
|
||||
id uuid PRIMARY KEY,
|
||||
|
||||
protocol proxy_protocol NOT NULL,
|
||||
host text NOT NULL,
|
||||
port int NOT NULL CHECK (port > 0 AND port < 65536),
|
||||
username text NOT NULL DEFAULT '',
|
||||
password text NOT NULL DEFAULT '',
|
||||
|
||||
"group" text NOT NULL DEFAULT 'default',
|
||||
tags text[] NOT NULL DEFAULT ARRAY[]::text[],
|
||||
|
||||
status proxy_status NOT NULL DEFAULT 'unknown',
|
||||
score int NOT NULL DEFAULT 0,
|
||||
latency_ms bigint NOT NULL DEFAULT 0,
|
||||
last_check_at timestamptz,
|
||||
|
||||
fail_count int NOT NULL DEFAULT 0,
|
||||
success_count int NOT NULL DEFAULT 0,
|
||||
|
||||
disabled boolean NOT NULL DEFAULT false,
|
||||
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
|
||||
CONSTRAINT uq_proxy UNIQUE (protocol, host, port, username)
|
||||
);
|
||||
|
||||
-- 常用索引
|
||||
CREATE INDEX idx_proxies_group_status_disabled
|
||||
ON proxies ("group", status, disabled);
|
||||
|
||||
-- tags 查询索引
|
||||
CREATE INDEX idx_proxies_tags_gin
|
||||
ON proxies USING gin (tags);
|
||||
|
||||
-- 可用代理热点查询索引
|
||||
CREATE INDEX idx_proxies_alive_fast
|
||||
ON proxies ("group", disabled, score DESC, last_check_at DESC)
|
||||
WHERE status = 'alive';
|
||||
|
||||
-- updated_at 自动维护触发器
|
||||
CREATE OR REPLACE FUNCTION touch_updated_at()
|
||||
RETURNS trigger AS $$
|
||||
BEGIN
|
||||
NEW.updated_at = now();
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE TRIGGER trg_touch_updated_at
|
||||
BEFORE UPDATE ON proxies
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION touch_updated_at();
|
||||
|
||||
-- RR 游标表
|
||||
CREATE TABLE rr_cursors (
|
||||
k text PRIMARY KEY,
|
||||
v bigint NOT NULL DEFAULT 0,
|
||||
updated_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
-- 租约表
|
||||
CREATE TABLE proxy_leases (
|
||||
lease_id text PRIMARY KEY,
|
||||
proxy_id uuid NOT NULL REFERENCES proxies(id),
|
||||
expire_at timestamptz NOT NULL,
|
||||
|
||||
site text NOT NULL DEFAULT '',
|
||||
"group" text NOT NULL DEFAULT 'default',
|
||||
|
||||
created_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX idx_leases_expire ON proxy_leases(expire_at);
|
||||
|
||||
-- 测试日志表
|
||||
CREATE TABLE proxy_test_logs (
|
||||
id bigserial PRIMARY KEY,
|
||||
proxy_id uuid NOT NULL REFERENCES proxies(id),
|
||||
site text NOT NULL,
|
||||
ok boolean NOT NULL,
|
||||
latency_ms bigint NOT NULL,
|
||||
error_text text NOT NULL DEFAULT '',
|
||||
checked_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX idx_test_logs_proxy_time ON proxy_test_logs(proxy_id, checked_at DESC);
|
||||
23
migrations/002_settings.sql
Normal file
23
migrations/002_settings.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
-- 系统设置表
|
||||
|
||||
CREATE TABLE settings (
|
||||
key text PRIMARY KEY,
|
||||
value jsonb NOT NULL,
|
||||
updated_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE TRIGGER trg_settings_updated_at
|
||||
BEFORE UPDATE ON settings
|
||||
FOR EACH ROW EXECUTE FUNCTION touch_updated_at();
|
||||
|
||||
-- 初始化 Telegram 配置
|
||||
INSERT INTO settings (key, value) VALUES ('telegram', '{
|
||||
"enabled": false,
|
||||
"bot_token": "",
|
||||
"admin_ids": [],
|
||||
"notify_chat_id": "",
|
||||
"test_interval_minutes": 60,
|
||||
"alert_threshold_percent": 50,
|
||||
"test_url": "https://httpbin.org/ip",
|
||||
"test_timeout_ms": 5000
|
||||
}'::jsonb);
|
||||
596
postman_collection.json
Normal file
596
postman_collection.json
Normal file
@@ -0,0 +1,596 @@
|
||||
{
|
||||
"info": {
|
||||
"_postman_id": "b5a9c4d2-1e8f-4a3b-9c5d-6e7f8a9b0c1d",
|
||||
"name": "ProxyRotator API",
|
||||
"description": "Postman collection for ProxyRotator API",
|
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
||||
},
|
||||
"item": [
|
||||
{
|
||||
"name": "System",
|
||||
"item": [
|
||||
{
|
||||
"name": "Health Check",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/health",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"health"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Get Stats",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/v1/proxies/stats",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"v1",
|
||||
"proxies",
|
||||
"stats"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Import",
|
||||
"item": [
|
||||
{
|
||||
"name": "Import Text",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"group\": \"default\",\n \"tags\": [\"datacenter\", \"fast\"],\n \"protocol_hint\": \"http\",\n \"text\": \"127.0.0.1:8080\n192.168.1.1:3128:user:pass\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/v1/proxies/import/text",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"v1",
|
||||
"proxies",
|
||||
"import",
|
||||
"text"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Import File",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "formdata",
|
||||
"formdata": [
|
||||
{
|
||||
"key": "file",
|
||||
"type": "file",
|
||||
"src": []
|
||||
},
|
||||
{
|
||||
"key": "group",
|
||||
"value": "default",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "tags",
|
||||
"value": "source_a,imported",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"key": "protocol_hint",
|
||||
"value": "http",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/v1/proxies/import/file",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"v1",
|
||||
"proxies",
|
||||
"import",
|
||||
"file"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Proxies",
|
||||
"item": [
|
||||
{
|
||||
"name": "List Proxies",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/v1/proxies?offset=0&limit=20",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"v1",
|
||||
"proxies"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "offset",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"key": "limit",
|
||||
"value": "20"
|
||||
},
|
||||
{
|
||||
"key": "group",
|
||||
"value": "default",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"key": "status",
|
||||
"value": "alive,unknown",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"key": "tags",
|
||||
"value": "fast,datacenter",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"key": "only_enabled",
|
||||
"value": "true",
|
||||
"disabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Get Proxy",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/v1/proxies/{{proxyId}}",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"v1",
|
||||
"proxies",
|
||||
"{{proxyId}}"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Update Proxy",
|
||||
"request": {
|
||||
"method": "PATCH",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"group\": \"premium\",\n \"add_tags\": [\"verified\"],\n \"disabled\": false\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/v1/proxies/{{proxyId}}",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"v1",
|
||||
"proxies",
|
||||
"{{proxyId}}"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Delete Proxy",
|
||||
"request": {
|
||||
"method": "DELETE",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/v1/proxies/{{proxyId}}",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"v1",
|
||||
"proxies",
|
||||
"{{proxyId}}"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Bulk Delete Proxies",
|
||||
"request": {
|
||||
"method": "DELETE",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"status\": \"dead\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/v1/proxies",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"v1",
|
||||
"proxies"
|
||||
]
|
||||
},
|
||||
"description": "Bulk delete proxies by condition. Options:\n- ids: array of proxy IDs\n- status: \"dead\", \"alive\", \"unknown\"\n- group: group name\n- disabled: true/false"
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Testing",
|
||||
"item": [
|
||||
{
|
||||
"name": "Test Proxies (Batch)",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"group\": \"default\",\n \"filter\": {\n \"status\": [\"unknown\", \"alive\"],\n \"limit\": 100\n },\n \"test_spec\": {\n \"url\": \"http://httpbin.org/ip\",\n \"method\": \"GET\",\n \"timeout_ms\": 5000,\n \"expect_status\": [200]\n },\n \"concurrency\": 20,\n \"update_store\": true,\n \"write_log\": true\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/v1/proxies/test",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"v1",
|
||||
"proxies",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Test Single Proxy",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"url\": \"http://httpbin.org/ip\",\n \"method\": \"GET\",\n \"timeout_ms\": 5000,\n \"expect_status\": [200],\n \"update_store\": true,\n \"write_log\": true\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/v1/proxies/{{proxyId}}/test",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"v1",
|
||||
"proxies",
|
||||
"{{proxyId}}",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Telegram",
|
||||
"item": [
|
||||
{
|
||||
"name": "Get Config",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/v1/telegram/config",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"v1",
|
||||
"telegram",
|
||||
"config"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Update Config",
|
||||
"request": {
|
||||
"method": "PUT",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"enabled\": true,\n \"bot_token\": \"123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11\",\n \"admin_ids\": [123456789],\n \"notify_chat_id\": \"-1001234567890\",\n \"test_interval_minutes\": 60,\n \"alert_threshold_percent\": 50,\n \"test_url\": \"https://httpbin.org/ip\",\n \"test_timeout_ms\": 5000\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/v1/telegram/config",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"v1",
|
||||
"telegram",
|
||||
"config"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Test Connection",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"token\": \"123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11\"\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/v1/telegram/test",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"v1",
|
||||
"telegram",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Get Status",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/v1/telegram/status",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"v1",
|
||||
"telegram",
|
||||
"status"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Trigger Test",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/v1/telegram/trigger-test",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"v1",
|
||||
"telegram",
|
||||
"trigger-test"
|
||||
]
|
||||
},
|
||||
"description": "Manually trigger proxy health check"
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Selection",
|
||||
"item": [
|
||||
{
|
||||
"name": "Get Next Proxy",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/v1/proxies/next?group=default&policy=random",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"v1",
|
||||
"proxies",
|
||||
"next"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "group",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"key": "site",
|
||||
"value": "",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"key": "policy",
|
||||
"value": "random",
|
||||
"description": "round_robin, random, weighted"
|
||||
},
|
||||
{
|
||||
"key": "tags_any",
|
||||
"value": "fast",
|
||||
"disabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "Report Status",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"lease_id\": \"{{leaseId}}\",\n \"proxy_id\": \"{{proxyId}}\",\n \"success\": true,\n \"latency_ms\": 150\n}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{baseUrl}}/v1/proxies/report",
|
||||
"host": [
|
||||
"{{baseUrl}}"
|
||||
],
|
||||
"path": [
|
||||
"v1",
|
||||
"proxies",
|
||||
"report"
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"auth": {
|
||||
"type": "apikey",
|
||||
"apikey": [
|
||||
{
|
||||
"key": "value",
|
||||
"value": "{{apiKey}}",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"key": "key",
|
||||
"value": "X-API-Key",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"event": [
|
||||
{
|
||||
"listen": "prerequest",
|
||||
"script": {
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"type": "text/javascript",
|
||||
"exec": [
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"variable": [
|
||||
{
|
||||
"key": "baseUrl",
|
||||
"value": "http://localhost:8080",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"key": "apiKey",
|
||||
"value": "",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"key": "leaseId",
|
||||
"value": "",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"key": "proxyId",
|
||||
"value": "",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
128
readme.md
Normal file
128
readme.md
Normal file
@@ -0,0 +1,128 @@
|
||||
# ProxyRotator
|
||||
|
||||
ProxyRotator 是一个全栈应用程序,旨在管理、验证和轮换 HTTP/SOCKS 代理。它提供了一个高性能的 Go 后端用于处理代理逻辑,以及一个现代化的 React 前端用于直观的管理和监控。
|
||||
|
||||
## ✨ 功能特性
|
||||
|
||||
- **代理管理**:支持批量导入、解析多种格式的代理。
|
||||
- **健康检查**:内置高性能测试器,验证代理的连通性、延迟和匿名度。
|
||||
- **智能轮换**:提供策略选择器,根据评分和状态分发最佳代理。
|
||||
- **现代化 UI**:基于 React 19 和 Tailwind CSS 构建的仪表盘,支持暗色模式。
|
||||
- **持久化存储**:使用 PostgreSQL 存储代理数据和历史记录。
|
||||
|
||||
## 🛠️ 技术栈
|
||||
|
||||
### Backend (后端)
|
||||
- **语言**: Go (1.25+)
|
||||
- **数据库**: PostgreSQL
|
||||
- **驱动/ORM**: pgx/v5
|
||||
- **核心模块**:
|
||||
- `importer`: 代理导入与解析
|
||||
- `tester`: 连通性测试
|
||||
- `selector`: 代理选择策略
|
||||
- `store`: 数据库持久化
|
||||
|
||||
### Frontend (前端)
|
||||
- **框架**: React 19 + Vite
|
||||
- **语言**: TypeScript
|
||||
- **样式**: Tailwind CSS v4
|
||||
- **组件库**: Shadcn UI (基于 Radix UI)
|
||||
- **图标**: Lucide React
|
||||
|
||||
## 🚀 快速开始
|
||||
|
||||
### 前置要求
|
||||
- Go 1.25 或更高版本
|
||||
- Node.js & pnpm
|
||||
- PostgreSQL 数据库
|
||||
|
||||
### 1. 数据库设置
|
||||
|
||||
首先,创建一个 PostgreSQL 数据库(例如 `proxyrotator`)。然后运行迁移脚本初始化表结构。
|
||||
|
||||
```bash
|
||||
# 进入后端目录
|
||||
cd backend
|
||||
|
||||
# 确保你有 psql 客户端,或者使用你喜欢的数据库工具执行 SQL
|
||||
# 默认迁移文件位于 migrations/001_init.sql
|
||||
psql "postgres://username:password@localhost:5432/proxyrotator" -f migrations/001_init.sql
|
||||
```
|
||||
|
||||
### 2. 后端设置
|
||||
|
||||
配置环境变量并启动 API 服务器。
|
||||
|
||||
```bash
|
||||
cd backend
|
||||
|
||||
# 复制示例环境变量文件
|
||||
cp envexmaple .env
|
||||
|
||||
# 编辑 .env 文件,填入你的数据库连接信息和其他配置
|
||||
# DATABASE_URL=postgres://postgres:psw@localhost:5432/proxyrotator
|
||||
# ...
|
||||
|
||||
# 安装依赖
|
||||
go mod tidy
|
||||
|
||||
# 启动服务器 (注意:Makefile 中的路径可能需要调整,直接使用 go run)
|
||||
go run server/main.go
|
||||
```
|
||||
|
||||
服务器默认监听在 `0.0.0.0:9987`。
|
||||
|
||||
### 3. 前端设置
|
||||
|
||||
启动 Web 界面。
|
||||
|
||||
```bash
|
||||
cd front
|
||||
|
||||
# 安装依赖
|
||||
pnpm install
|
||||
|
||||
# 启动开发服务器
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
访问终端中显示的地址(通常是 `http://localhost:5173`)即可进入控制台。
|
||||
|
||||
## ⚙️ 环境变量配置
|
||||
|
||||
在 `backend/.env` 中配置以下关键变量:
|
||||
|
||||
| 变量名 | 描述 | 示例 |
|
||||
|--------|------|------|
|
||||
| `DATABASE_URL` | PostgreSQL 连接字符串 | `postgres://user:pass@localhost:5432/db` |
|
||||
| `LISTEN_ADDR` | 后端监听地址 | `0.0.0.0:9987` |
|
||||
| `API_KEY` | API 访问密钥(如启用鉴权) | `your-secret-key` |
|
||||
| `MAX_CONCURRENCY` | 代理测试的最大并发数 | `200` |
|
||||
| `LEASE_TTL` | 代理租约/有效时间 | `60s` |
|
||||
|
||||
## 📂 项目结构
|
||||
|
||||
```
|
||||
proxyrotator/
|
||||
├── backend/ # Go 后端代码
|
||||
│ ├── internal/ # 核心业务逻辑
|
||||
│ │ ├── api/ # HTTP API 处理
|
||||
│ │ ├── importer/ # 代理导入器
|
||||
│ │ ├── tester/ # 代理测试器
|
||||
│ │ └── store/ # 数据库操作
|
||||
│ ├── migrations/ # SQL 迁移文件
|
||||
│ └── server/ # 入口文件
|
||||
└── front/ # React 前端代码
|
||||
├── src/
|
||||
│ ├── components/ # UI 组件
|
||||
│ └── lib/ # 工具函数与 API 客户端
|
||||
```
|
||||
|
||||
## 📝 开发指南
|
||||
|
||||
- **后端开发**: 核心逻辑位于 `backend/internal`。添加新功能时,请确保更新 `docs/developdoc.md`(如果存在)。
|
||||
- **前端开发**: 组件位于 `front/src/components`。使用了 Shadcn UI 风格的组件架构。
|
||||
|
||||
## 📄 License
|
||||
|
||||
[MIT](LICENSE)
|
||||
122
server/main.go
Normal file
122
server/main.go
Normal file
@@ -0,0 +1,122 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"proxyrotator/internal/api"
|
||||
"proxyrotator/internal/config"
|
||||
"proxyrotator/internal/importer"
|
||||
"proxyrotator/internal/selector"
|
||||
"proxyrotator/internal/store"
|
||||
"proxyrotator/internal/telegram"
|
||||
"proxyrotator/internal/tester"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 配置日志
|
||||
slog.SetDefault(slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
|
||||
Level: slog.LevelInfo,
|
||||
})))
|
||||
|
||||
// 加载配置
|
||||
cfg := config.Load()
|
||||
|
||||
slog.Info("starting proxyrotator",
|
||||
"listen_addr", cfg.ListenAddr,
|
||||
"max_concurrency", cfg.MaxConcurrency,
|
||||
"max_test_limit", cfg.MaxTestLimit,
|
||||
"lease_ttl", cfg.LeaseTTL,
|
||||
"telegram_enabled", cfg.TelegramBotToken != "",
|
||||
)
|
||||
|
||||
// 连接数据库
|
||||
ctx := context.Background()
|
||||
pgStore, err := store.NewPgStore(ctx, cfg.DatabaseURL)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to connect to database: %v", err)
|
||||
}
|
||||
defer pgStore.Close()
|
||||
|
||||
slog.Info("connected to database")
|
||||
|
||||
// 初始化组件
|
||||
imp := importer.NewImporter()
|
||||
tst := tester.NewHTTPTester()
|
||||
sel := selector.NewSelector(pgStore, cfg.LeaseTTL)
|
||||
|
||||
// 初始化 Telegram Bot
|
||||
bot := telegram.NewBot(cfg, pgStore)
|
||||
|
||||
// 启动 Telegram Bot
|
||||
if err := bot.Start(ctx); err != nil {
|
||||
slog.Warn("failed to start telegram bot", "error", err)
|
||||
}
|
||||
defer bot.Stop()
|
||||
|
||||
// 创建路由
|
||||
router := api.NewRouter(pgStore, imp, tst, sel, cfg)
|
||||
|
||||
// 创建 HTTP 服务器
|
||||
server := &http.Server{
|
||||
Addr: cfg.ListenAddr,
|
||||
Handler: router,
|
||||
ReadTimeout: 30 * time.Second,
|
||||
WriteTimeout: 120 * time.Second,
|
||||
IdleTimeout: 60 * time.Second,
|
||||
}
|
||||
|
||||
// 启动后台任务:清理过期租约
|
||||
go cleanupLoop(ctx, pgStore)
|
||||
|
||||
// 启动服务器(在 goroutine 中)
|
||||
go func() {
|
||||
slog.Info("server listening", "addr", cfg.ListenAddr)
|
||||
if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||
log.Fatalf("server error: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
// 等待中断信号
|
||||
quit := make(chan os.Signal, 1)
|
||||
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
||||
<-quit
|
||||
|
||||
slog.Info("shutting down server...")
|
||||
|
||||
// 优雅关闭
|
||||
shutdownCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
if err := server.Shutdown(shutdownCtx); err != nil {
|
||||
log.Fatalf("server shutdown error: %v", err)
|
||||
}
|
||||
|
||||
slog.Info("server stopped")
|
||||
}
|
||||
|
||||
// cleanupLoop 定期清理过期租约
|
||||
func cleanupLoop(ctx context.Context, s *store.PgStore) {
|
||||
ticker := time.NewTicker(1 * time.Minute)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
deleted, err := s.DeleteExpiredLeases(ctx)
|
||||
if err != nil {
|
||||
slog.Error("failed to cleanup expired leases", "error", err)
|
||||
} else if deleted > 0 {
|
||||
slog.Info("cleaned up expired leases", "count", deleted)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user