Documentation
¶
Overview ¶
Package ss implements replay attack protection for Shadowsocks. It uses a Bloom filter to efficiently detect and reject replayed packets.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter is a time-based Bloom filter for replay attack detection
type FilterConfig ¶
type FilterConfig struct {
// Size is the number of bits in the Bloom filter
Size uint32
// HashCount is the number of hash functions
HashCount uint32
// Interval is the rotation interval
Interval time.Duration
}
FilterConfig configures the replay filter
func DefaultFilterConfig ¶
func DefaultFilterConfig() *FilterConfig
DefaultFilterConfig returns the default configuration
type NonceFilter ¶
type NonceFilter struct {
// contains filtered or unexported fields
}
NonceFilter is a replay filter specifically for AEAD nonces
func NewNonceFilter ¶
func NewNonceFilter(ttl time.Duration) *NonceFilter
NewNonceFilter creates a new nonce-based replay filter
func (*NonceFilter) Check ¶
func (nf *NonceFilter) Check(nonce []byte) bool
Check checks if the nonce has been seen
func (*NonceFilter) Size ¶
func (nf *NonceFilter) Size() int
Size returns the number of stored nonces
type SaltFilter ¶
type SaltFilter struct {
// contains filtered or unexported fields
}
SaltFilter is a replay filter that uses salt + IV for detection
func NewSaltFilter ¶
func NewSaltFilter(config *FilterConfig) *SaltFilter
NewSaltFilter creates a new salt-based replay filter
func (*SaltFilter) Check ¶
func (sf *SaltFilter) Check(salt, iv []byte) bool
Check checks if the salt+IV combination has been seen
type Stats ¶
type Stats struct {
CurrentCount uint64
PreviousCount uint64
Size uint32
HashCount uint32
LastRotate time.Time
}
Stats returns statistics about the filter
type UDPHandler ¶
type UDPHandler struct {
// contains filtered or unexported fields
}
UDPHandler handles Shadowsocks UDP relay
func NewUDPHandler ¶
func NewUDPHandler(method, password string, log logger.Logger) (*UDPHandler, error)
NewUDPHandler creates a new Shadowsocks UDP handler
func (*UDPHandler) HandlePacket ¶
func (h *UDPHandler) HandlePacket(ctx context.Context, conn net.PacketConn) error
HandlePacket implements protocol.PacketHandler interface