48 lines
897 B
Go
48 lines
897 B
Go
package goproxy
|
|
|
|
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
|
|
}
|