Documentation
¶
Index ¶
- Variables
- func ParseSNI(data []byte) (string, error)
- func PeekClientHello(reader io.Reader) (sni string, data []byte, err error)
- type HTTPReporter
- type NoopReporter
- type Rule
- type RuleMatch
- type RuleTable
- func (rt *RuleTable) AddRule(rule *Rule)
- func (rt *RuleTable) GetRules() []*Rule
- func (rt *RuleTable) Match(sourceIP net.IP, sni string) *RuleMatch
- func (rt *RuleTable) RemoveRule(id string) bool
- func (rt *RuleTable) SetRules(rules []*Rule)
- func (rt *RuleTable) UpdateRule(id string, update func(*Rule)) bool
- type Server
- func (s *Server) GetRuleTable() *RuleTable
- func (s *Server) GetStats() *StatsCollector
- func (s *Server) SetACMEHandler(handler http.Handler)
- func (s *Server) SetDoHHandler(handler http.Handler)
- func (s *Server) SetStatsReporter(reporter StatsReporter)
- func (s *Server) SetTLSConfig(tlsConfig *tls.Config)
- func (s *Server) Start() error
- func (s *Server) Stop() error
- type Stats
- type StatsCollector
- func (sc *StatsCollector) EndConnection(connID string, err error)
- func (sc *StatsCollector) GetActiveConnections() []*Stats
- func (sc *StatsCollector) GetSummary() map[string]int64
- func (sc *StatsCollector) StartConnection(connID, sourceIP, sni, target, transport string) *Stats
- func (sc *StatsCollector) UpdateBytes(connID string, bytesRead, bytesWritten int64)
- type StatsReporter
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoSNI = errors.New("no SNI extension found") ErrInvalidTLS = errors.New("invalid TLS record") ErrTruncatedData = errors.New("truncated TLS data") ErrUnsupportedType = errors.New("unsupported TLS record type") )
SNI 解析相关错误
Functions ¶
Types ¶
type HTTPReporter ¶
type HTTPReporter struct {
// contains filtered or unexported fields
}
HTTPReporter HTTP上报器(预留实现)
func NewHTTPReporter ¶
func NewHTTPReporter(endpoint string) *HTTPReporter
NewHTTPReporter 创建HTTP上报器
func (*HTTPReporter) ReportBatch ¶
func (r *HTTPReporter) ReportBatch(stats []*Stats) error
ReportBatch 批量上报
type NoopReporter ¶
type NoopReporter struct{}
NoopReporter 空实现的上报器
func (*NoopReporter) Report ¶
func (n *NoopReporter) Report(stats *Stats) error
func (*NoopReporter) ReportBatch ¶
func (n *NoopReporter) ReportBatch(stats []*Stats) error
type Rule ¶
type Rule struct {
ID string `json:"id"`
SourceIP string `json:"source_ip"` // 源IP或CIDR,空表示匹配所有
SNIPattern string `json:"sni_pattern"` // SNI模式,支持通配符*
TargetAddress string `json:"target_address"` // 目标地址 (host:port)
Transport string `json:"transport"` // 传输类型: direct, socks5
Priority int `json:"priority"` // 优先级,数值越大优先级越高
Enabled bool `json:"enabled"` // 是否启用
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Rule SNI代理规则
type RuleTable ¶
type RuleTable struct {
// contains filtered or unexported fields
}
RuleTable 规则表管理器
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server SNI代理服务器
func (*Server) SetACMEHandler ¶
SetACMEHandler 设置ACME挑战处理器
func (*Server) SetDoHHandler ¶
SetDoHHandler 设置DoH处理器
func (*Server) SetStatsReporter ¶
func (s *Server) SetStatsReporter(reporter StatsReporter)
SetStatsReporter 设置统计上报器
func (*Server) SetTLSConfig ¶
SetTLSConfig 设置TLS配置(用于DoH)
type Stats ¶
type Stats struct {
SourceIP string `json:"source_ip"`
SNI string `json:"sni"`
TargetAddress string `json:"target_address"`
Transport string `json:"transport"`
BytesRead int64 `json:"bytes_read"`
BytesWritten int64 `json:"bytes_written"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time,omitempty"`
Duration int64 `json:"duration_ms"`
Status string `json:"status"` // active, completed, error
Error string `json:"error,omitempty"`
}
Stats 连接统计信息
type StatsCollector ¶
type StatsCollector struct {
// contains filtered or unexported fields
}
StatsCollector 流量统计收集器
func NewStatsCollector ¶
func NewStatsCollector(reporter StatsReporter) *StatsCollector
NewStatsCollector 创建统计收集器
func (*StatsCollector) EndConnection ¶
func (sc *StatsCollector) EndConnection(connID string, err error)
EndConnection 记录连接结束
func (*StatsCollector) GetActiveConnections ¶
func (sc *StatsCollector) GetActiveConnections() []*Stats
GetActiveConnections 获取活跃连接
func (*StatsCollector) GetSummary ¶
func (sc *StatsCollector) GetSummary() map[string]int64
GetSummary 获取统计摘要
func (*StatsCollector) StartConnection ¶
func (sc *StatsCollector) StartConnection(connID, sourceIP, sni, target, transport string) *Stats
StartConnection 记录连接开始
func (*StatsCollector) UpdateBytes ¶
func (sc *StatsCollector) UpdateBytes(connID string, bytesRead, bytesWritten int64)
UpdateBytes 更新字节统计
Click to show internal directories.
Click to hide internal directories.