mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-23 03:31:53 +08:00
## 架构重构
- 全局变量消除,迁移至 Config/State 对象
- SMB 插件融合(smb/smb2/smbghost/smbinfo)
- 服务探测重构,实现 Nmap 风格 fallback 机制
- 输出系统重构,TXT 实时刷盘 + 双写机制
- i18n 框架升级至 go-i18n
## 性能优化
- 正则表达式预编译
- 内存优化 map[string]struct{}
- 并发指纹匹配
- SOCKS5 连接复用
- 滑动窗口调度 + 自适应线程池
## 新功能
- Web 管理界面
- 多格式 POC 适配(xray/afrog)
- 增强指纹库(3139条)
- Favicon hash 指纹识别
- 插件选择性编译(Build Tags)
- fscan-lab 靶场环境
- 默认端口扩展(62→133)
## 构建系统
- 添加 no_local tag 支持排除本地插件
- 多版本构建:fscan/fscan-nolocal/fscan-web
- CI 添加 snapshot 模式支持仅测试构建
## Bug 修复
- 修复 120+ 个问题,包括 RDP panic、批量扫描漏报、
JSON 输出格式、Redis 检测、Context 超时等
## 测试增强
- 单元测试覆盖率 74-100%
- 并发安全测试
- 集成测试(Web/端口/服务/SSH/ICMP)
219 lines
7.7 KiB
Go
219 lines
7.7 KiB
Go
package proxy
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
/*
|
|
constants.go - 代理系统常量定义
|
|
|
|
统一管理common/proxy包中的所有常量,便于查看和编辑。
|
|
*/
|
|
|
|
// =============================================================================
|
|
// 代理类型常量 (从Types.go迁移)
|
|
// =============================================================================
|
|
|
|
const (
|
|
// ProxyTypeStringNone 代理类型字符串 - 无代理
|
|
ProxyTypeStringNone = "none"
|
|
// ProxyTypeStringHTTP HTTP代理
|
|
ProxyTypeStringHTTP = "http"
|
|
// ProxyTypeStringHTTPS HTTPS代理
|
|
ProxyTypeStringHTTPS = "https"
|
|
// ProxyTypeStringSOCKS5 SOCKS5代理
|
|
ProxyTypeStringSOCKS5 = "socks5"
|
|
// ProxyTypeStringUnknown 未知代理类型
|
|
ProxyTypeStringUnknown = "unknown"
|
|
)
|
|
|
|
// =============================================================================
|
|
// 默认配置常量 (从Types.go迁移)
|
|
// =============================================================================
|
|
|
|
const (
|
|
// DefaultProxyTimeout 默认代理配置值 - 默认超时时间
|
|
DefaultProxyTimeout = 30 * time.Second
|
|
// DefaultProxyMaxRetries 默认最大重试次数
|
|
DefaultProxyMaxRetries = 3
|
|
// DefaultProxyKeepAlive 默认保持连接时间
|
|
DefaultProxyKeepAlive = 30 * time.Second
|
|
// DefaultProxyIdleTimeout 默认空闲超时时间
|
|
DefaultProxyIdleTimeout = 90 * time.Second
|
|
// DefaultProxyMaxIdleConns 默认最大空闲连接数
|
|
DefaultProxyMaxIdleConns = 10
|
|
)
|
|
|
|
// =============================================================================
|
|
// 错误类型常量 (从Types.go迁移)
|
|
// =============================================================================
|
|
|
|
const (
|
|
// ErrTypeConfig 预定义错误类型 - 配置错误
|
|
ErrTypeConfig = "config_error"
|
|
// ErrTypeConnection 连接错误
|
|
ErrTypeConnection = "connection_error"
|
|
// ErrTypeAuth 认证错误
|
|
ErrTypeAuth = "auth_error"
|
|
// ErrTypeTimeout 超时错误
|
|
ErrTypeTimeout = "timeout_error"
|
|
// ErrTypeProtocol 协议错误
|
|
ErrTypeProtocol = "protocol_error"
|
|
)
|
|
|
|
// =============================================================================
|
|
// 缓存管理常量 (从Manager.go迁移)
|
|
// =============================================================================
|
|
|
|
const (
|
|
// DefaultCacheExpiry 缓存配置 - 默认缓存过期时间
|
|
DefaultCacheExpiry = 5 * time.Minute
|
|
)
|
|
|
|
// =============================================================================
|
|
// 错误代码常量 (从Manager.go和其他文件迁移)
|
|
// =============================================================================
|
|
|
|
const (
|
|
// ErrCodeUnsupportedProxyType Manager错误代码 - 不支持的代理类型
|
|
ErrCodeUnsupportedProxyType = 1001
|
|
// ErrCodeEmptyConfig 配置为空
|
|
ErrCodeEmptyConfig = 1002
|
|
|
|
// ErrCodeSOCKS5ParseFailed SOCKS5错误代码 - 地址解析失败
|
|
ErrCodeSOCKS5ParseFailed = 2001
|
|
// ErrCodeSOCKS5CreateFailed 拨号器创建失败
|
|
ErrCodeSOCKS5CreateFailed = 2002
|
|
|
|
// ErrCodeDirectConnFailed 直连错误代码 - 直连失败
|
|
ErrCodeDirectConnFailed = 3001
|
|
// ErrCodeSOCKS5ConnTimeout SOCKS5连接超时
|
|
ErrCodeSOCKS5ConnTimeout = 3002
|
|
// ErrCodeSOCKS5ConnFailed SOCKS5连接失败
|
|
ErrCodeSOCKS5ConnFailed = 3003
|
|
|
|
// ErrCodeHTTPConnFailed HTTP代理错误代码 - 连接失败
|
|
ErrCodeHTTPConnFailed = 4001
|
|
// ErrCodeHTTPSetWriteTimeout 设置写超时失败
|
|
ErrCodeHTTPSetWriteTimeout = 4002
|
|
// ErrCodeHTTPSendConnectFail 发送CONNECT请求失败
|
|
ErrCodeHTTPSendConnectFail = 4003
|
|
// ErrCodeHTTPSetReadTimeout 设置读超时失败
|
|
ErrCodeHTTPSetReadTimeout = 4004
|
|
// ErrCodeHTTPReadRespFailed 读取响应失败
|
|
ErrCodeHTTPReadRespFailed = 4005
|
|
// ErrCodeHTTPProxyAuthFailed 代理认证失败
|
|
ErrCodeHTTPProxyAuthFailed = 4006
|
|
|
|
// ErrCodeTLSTCPConnFailed TLS错误代码 - TCP连接失败
|
|
ErrCodeTLSTCPConnFailed = 5001
|
|
// ErrCodeTLSHandshakeFailed TLS握手失败
|
|
ErrCodeTLSHandshakeFailed = 5002
|
|
)
|
|
|
|
// =============================================================================
|
|
// HTTP协议常量 (从HTTPDialer.go迁移)
|
|
// =============================================================================
|
|
|
|
const (
|
|
// HTTPStatusOK HTTP响应状态码 - 成功状态码200
|
|
HTTPStatusOK = 200
|
|
|
|
// HTTPVersion HTTP协议常量 - HTTP版本
|
|
HTTPVersion = "HTTP/1.1"
|
|
// HTTPMethodConnect CONNECT方法
|
|
HTTPMethodConnect = "CONNECT"
|
|
|
|
// HTTPHeaderHost HTTP头部常量 - Host头
|
|
HTTPHeaderHost = "Host"
|
|
// HTTPHeaderProxyAuth Proxy-Authorization头
|
|
HTTPHeaderProxyAuth = "Proxy-Authorization"
|
|
// HTTPHeaderAuthBasic Basic认证方式
|
|
HTTPHeaderAuthBasic = "Basic"
|
|
)
|
|
|
|
// =============================================================================
|
|
// 网络协议常量 (从各文件迁移)
|
|
// =============================================================================
|
|
|
|
const (
|
|
// NetworkTCP 网络协议 - TCP协议
|
|
NetworkTCP = "tcp"
|
|
|
|
// ProxyProtocolSOCKS5 代理协议前缀 - SOCKS5协议
|
|
ProxyProtocolSOCKS5 = "socks5"
|
|
|
|
// AuthSeparator 认证分隔符 - 冒号分隔符
|
|
AuthSeparator = ":"
|
|
)
|
|
|
|
// =============================================================================
|
|
// 错误消息常量
|
|
// =============================================================================
|
|
|
|
const (
|
|
// ErrMsgUnsupportedProxyType Manager错误消息 - 不支持的代理类型
|
|
ErrMsgUnsupportedProxyType = "不支持的代理类型"
|
|
// ErrMsgEmptyConfig 配置不能为空
|
|
ErrMsgEmptyConfig = "配置不能为空"
|
|
|
|
// ErrMsgSOCKS5ParseFailed SOCKS5错误消息 - 地址解析失败
|
|
ErrMsgSOCKS5ParseFailed = "SOCKS5代理地址解析失败"
|
|
// ErrMsgSOCKS5CreateFailed 拨号器创建失败
|
|
ErrMsgSOCKS5CreateFailed = "SOCKS5拨号器创建失败"
|
|
// ErrMsgSOCKS5ConnTimeout 连接超时
|
|
ErrMsgSOCKS5ConnTimeout = "SOCKS5连接超时"
|
|
// ErrMsgSOCKS5ConnFailed 连接失败
|
|
ErrMsgSOCKS5ConnFailed = "SOCKS5连接失败"
|
|
|
|
// ErrMsgDirectConnFailed 直连错误消息 - 直连失败
|
|
ErrMsgDirectConnFailed = "直连失败"
|
|
|
|
// ErrMsgHTTPConnFailed HTTP代理错误消息 - 连接失败
|
|
ErrMsgHTTPConnFailed = "连接HTTP代理服务器失败"
|
|
// ErrMsgHTTPSetWriteTimeout 设置写超时失败
|
|
ErrMsgHTTPSetWriteTimeout = "设置写超时失败"
|
|
// ErrMsgHTTPSendConnectFail 发送CONNECT请求失败
|
|
ErrMsgHTTPSendConnectFail = "发送CONNECT请求失败"
|
|
// ErrMsgHTTPSetReadTimeout 设置读超时失败
|
|
ErrMsgHTTPSetReadTimeout = "设置读超时失败"
|
|
// ErrMsgHTTPReadRespFailed 读取响应失败
|
|
ErrMsgHTTPReadRespFailed = "读取HTTP响应失败"
|
|
// ErrMsgHTTPProxyAuthFailed 代理认证失败
|
|
ErrMsgHTTPProxyAuthFailed = "HTTP代理连接失败,状态码: %d"
|
|
|
|
// ErrMsgTLSTCPConnFailed TLS错误消息 - TCP连接失败
|
|
ErrMsgTLSTCPConnFailed = "建立TCP连接失败"
|
|
// ErrMsgTLSHandshakeFailed TLS握手失败
|
|
ErrMsgTLSHandshakeFailed = "TLS握手失败"
|
|
)
|
|
|
|
// =============================================================================
|
|
// 缓存键前缀常量 (从Manager.go迁移)
|
|
// =============================================================================
|
|
|
|
const (
|
|
// CacheKeySOCKS5 缓存键前缀 - SOCKS5代理缓存键格式
|
|
CacheKeySOCKS5 = "socks5_%s"
|
|
// CacheKeyHTTP HTTP代理缓存键格式
|
|
CacheKeyHTTP = "http_%s"
|
|
)
|
|
|
|
// =============================================================================
|
|
// 格式化字符串常量 (从各文件迁移)
|
|
// =============================================================================
|
|
|
|
const (
|
|
// SOCKS5URLFormat SOCKS5 URL格式 - 基本格式
|
|
SOCKS5URLFormat = "socks5://%s"
|
|
// SOCKS5URLAuthFormat 带认证的SOCKS5 URL格式
|
|
SOCKS5URLAuthFormat = "socks5://%s:%s@%s"
|
|
|
|
// HTTPConnectRequestFormat HTTP CONNECT请求格式 - CONNECT请求行
|
|
HTTPConnectRequestFormat = "CONNECT %s HTTP/1.1\r\nHost: %s\r\n"
|
|
// HTTPAuthHeaderFormat 认证头格式
|
|
HTTPAuthHeaderFormat = "Proxy-Authorization: Basic %s\r\n"
|
|
// HTTPRequestEndFormat 请求结束标记
|
|
HTTPRequestEndFormat = "\r\n"
|
|
)
|