Documentation
¶
Overview ¶
core/protocol/protocol.go
Index ¶
- Constants
- func RegisterProtocol(name string, factory ProtocolFactory)
- type AuthAProtocol
- func (p *AuthAProtocol) Deobfuscate(data ProtocolData, ctx ProtocolContext) (ProtocolData, error)
- func (p *AuthAProtocol) Init(param string) error
- func (p *AuthAProtocol) Name() string
- func (p *AuthAProtocol) Obfuscate(data ProtocolData, ctx ProtocolContext) (ProtocolData, error)
- func (p *AuthAProtocol) ParamName() string
- type Protocol
- type ProtocolContext
- type ProtocolData
- type ProtocolFactory
Constants ¶
View Source
const (
// AuthAHeaderSize 定义了我们自定义头部的大小:CRC32 (4 字节) + 原始数据长度 (4 字节)
AuthAHeaderSize = 8
)
Variables ¶
This section is empty.
Functions ¶
func RegisterProtocol ¶
func RegisterProtocol(name string, factory ProtocolFactory)
RegisterProtocol registers a Protocol plugin.
Types ¶
type AuthAProtocol ¶ added in v0.4.1
type AuthAProtocol struct {
// contains filtered or unexported fields
}
AuthAProtocol 实现了 protocol_ext.Protocol 接口
func (*AuthAProtocol) Deobfuscate ¶ added in v0.4.1
func (p *AuthAProtocol) Deobfuscate(data ProtocolData, ctx ProtocolContext) (ProtocolData, error)
Deobfuscate 反转混淆逻辑。
func (*AuthAProtocol) Init ¶ added in v0.4.1
func (p *AuthAProtocol) Init(param string) error
Init 初始化插件。
func (*AuthAProtocol) Obfuscate ¶ added in v0.4.1
func (p *AuthAProtocol) Obfuscate(data ProtocolData, ctx ProtocolContext) (ProtocolData, error)
Obfuscate 施加混淆逻辑。
func (*AuthAProtocol) ParamName ¶ added in v0.4.1
func (p *AuthAProtocol) ParamName() string
ParamName 返回插件参数的名称。
type Protocol ¶
type Protocol interface { // Name returns the name of the plugin. Name() string // ParamName returns the name of the plugin's parameter, used for configuration. ParamName() string // Init initializes the protocol plugin. param is the ProtocolParam string configured by the user. // Returns an error if initialization fails. Init(param string) error // Obfuscate modifies internal protocol fields before data is sent (encrypted/encapsulated). // data is ProtocolData, context provides context information. // Returns the modified data. If an error is returned, the operation should be aborted. Obfuscate(data ProtocolData, context ProtocolContext) (ProtocolData, error) // Deobfuscate restores internal protocol fields after data is received (decrypted/de-encapsulated). // data is ProtocolData, context provides context information. // Returns the restored data. If an error is returned, the operation should be aborted. Deobfuscate(data ProtocolData, context ProtocolContext) (ProtocolData, error) }
Protocol is the interface that protocol plugins must implement. It provides methods to modify data before encryption/encapsulation and to restore data after decryption.
type ProtocolContext ¶
type ProtocolContext struct { // Type indicates the type of data being operated on, e.g., "tcp_request", "udp_message", "auth_request", "auth_response" // Plugins can use this field for type assertion. Type string // IsClient indicates whether the current operation is happening on the client side (true for client, false for server). IsClient bool // PeerAddr is the network address of the peer. PeerAddr net.Addr // SessionID is only valid for UDP messages. SessionID uint32 // StreamID is only valid for TCP Streams (QUIC Streams). StreamID uquic.StreamID }
ProtocolContext provides information about the current operation context.
type ProtocolData ¶
type ProtocolData interface{}
ProtocolData is a generic abstraction for data that protocol plugins can operate on. The specific type is asserted by the plugin based on the Context's Type field.
type ProtocolFactory ¶
type ProtocolFactory func() Protocol
ProtocolFactory is a function type for creating Protocol instances.
Click to show internal directories.
Click to hide internal directories.