- 添加 convertToReverseConfig 函数,将 config.Config 转换为 reverse.Config - 修正配置字段映射关系: - EnableHTTPS -> DecryptHTTPS - EnableWebSocket -> SupportWebSocketUpgrade - 保持其他配置字段映射不变 - 优化代码格式和注释 BREAKING CHANGE: 反向代理配置结构发生变化,需要更新相关配置
48 lines
895 B
Go
48 lines
895 B
Go
package proxy
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
// BaseProxy 基础代理接口
|
|
type BaseProxy interface {
|
|
// ServeHTTP 处理HTTP请求
|
|
ServeHTTP(w http.ResponseWriter, r *http.Request)
|
|
// Close 关闭代理
|
|
Close() error
|
|
}
|
|
|
|
// BaseConfig 基础配置
|
|
type BaseConfig struct {
|
|
// 监听地址
|
|
ListenAddr string
|
|
// 是否启用HTTPS
|
|
EnableHTTPS bool
|
|
// TLS配置
|
|
TLSConfig *TLSConfig
|
|
// 是否启用WebSocket
|
|
EnableWebSocket bool
|
|
// 是否启用压缩
|
|
EnableCompression bool
|
|
// 是否启用CORS
|
|
EnableCORS bool
|
|
// 是否保留客户端IP
|
|
PreserveClientIP bool
|
|
// 是否添加X-Forwarded-For头
|
|
AddXForwardedFor bool
|
|
// 是否添加X-Real-IP头
|
|
AddXRealIP bool
|
|
}
|
|
|
|
// TLSConfig TLS配置
|
|
type TLSConfig struct {
|
|
// 证书文件路径
|
|
CertFile string
|
|
// 密钥文件路径
|
|
KeyFile string
|
|
// 是否跳过证书验证
|
|
InsecureSkipVerify bool
|
|
// 是否使用ECDSA
|
|
UseECDSA bool
|
|
}
|