shadowsocks2022

package
v5.15.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TCPHeaderTypeClientToServerStream = byte(0x00)
	TCPHeaderTypeServerToClientStream = byte(0x01)
	TCPMinPaddingLength               = 0
	TCPMaxPaddingLength               = 900
)
View Source
const (
	UDPHeaderTypeClientToServerStream = byte(0x00)
	UDPHeaderTypeServerToClientStream = byte(0x01)
)
View Source
const UDPConnectionState = "UDPConnectionState"

Variables

View Source
var File_proxy_shadowsocks2022_config_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type AEADChunkSizeParser added in v5.12.1

type AEADChunkSizeParser struct {
	Auth *crypto.AEADAuthenticator
}

func (*AEADChunkSizeParser) Decode added in v5.12.1

func (p *AEADChunkSizeParser) Decode(b []byte) (uint16, error)

func (*AEADChunkSizeParser) Encode added in v5.12.1

func (p *AEADChunkSizeParser) Encode(size uint16, b []byte) []byte

func (*AEADChunkSizeParser) HasConstantOffset added in v5.12.1

func (p *AEADChunkSizeParser) HasConstantOffset() uint16

func (*AEADChunkSizeParser) SizeBytes added in v5.12.1

func (p *AEADChunkSizeParser) SizeBytes() int32

type AES128GCMMethod

type AES128GCMMethod struct{}

func (AES128GCMMethod) GenerateEIH

func (a AES128GCMMethod) GenerateEIH(currentIdentitySubKey []byte, nextPskHash []byte, out []byte) error

func (AES128GCMMethod) GetSessionSubKeyAndSaltLength

func (a AES128GCMMethod) GetSessionSubKeyAndSaltLength() int

func (AES128GCMMethod) GetStreamAEAD

func (a AES128GCMMethod) GetStreamAEAD(sessionSubKey []byte) (cipher.AEAD, error)

func (AES128GCMMethod) GetUDPClientProcessor

func (a AES128GCMMethod) GetUDPClientProcessor(ipsk [][]byte, psk []byte, derivation KeyDerivation) (UDPClientPacketProcessor, error)

type AES256GCMMethod

type AES256GCMMethod struct{}

func (AES256GCMMethod) GenerateEIH

func (a AES256GCMMethod) GenerateEIH(currentIdentitySubKey []byte, nextPskHash []byte, out []byte) error

func (AES256GCMMethod) GetSessionSubKeyAndSaltLength

func (a AES256GCMMethod) GetSessionSubKeyAndSaltLength() int

func (AES256GCMMethod) GetStreamAEAD

func (a AES256GCMMethod) GetStreamAEAD(sessionSubKey []byte) (cipher.AEAD, error)

func (AES256GCMMethod) GetUDPClientProcessor

func (a AES256GCMMethod) GetUDPClientProcessor(ipsk [][]byte, psk []byte, derivation KeyDerivation) (UDPClientPacketProcessor, error)

type AESUDPClientPacketProcessor

type AESUDPClientPacketProcessor struct {
	EIHGenerator func([]byte) ExtensibleIdentityHeaders
	// contains filtered or unexported fields
}

func NewAESUDPClientPacketProcessor

func NewAESUDPClientPacketProcessor(requestSeparateHeaderBlockCipher, responseSeparateHeaderBlockCipher cipher.Block, mainPacketAEAD func([]byte) cipher.AEAD, eih func([]byte) ExtensibleIdentityHeaders) *AESUDPClientPacketProcessor

func (*AESUDPClientPacketProcessor) DecodeUDPResp

func (*AESUDPClientPacketProcessor) EncodeUDPRequest

type BLAKE3KeyDerivation

type BLAKE3KeyDerivation struct{}

func (BLAKE3KeyDerivation) GetIdentitySubKey

func (b BLAKE3KeyDerivation) GetIdentitySubKey(effectivePsk, salt []byte, outKey []byte) error

func (BLAKE3KeyDerivation) GetSessionSubKey

func (b BLAKE3KeyDerivation) GetSessionSubKey(effectivePsk, salt []byte, outKey []byte) error

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, config *ClientConfig) (*Client, error)

func (*Client) Process

func (c *Client) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error

type ClientConfig

type ClientConfig struct {
	Method  string          `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"`
	Psk     []byte          `protobuf:"bytes,2,opt,name=psk,proto3" json:"psk,omitempty"`
	Ipsk    [][]byte        `protobuf:"bytes,4,rep,name=ipsk,proto3" json:"ipsk,omitempty"`
	Address *net.IPOrDomain `protobuf:"bytes,5,opt,name=address,proto3" json:"address,omitempty"`
	Port    uint32          `protobuf:"varint,6,opt,name=port,proto3" json:"port,omitempty"`
	// contains filtered or unexported fields
}

func (*ClientConfig) Descriptor deprecated

func (*ClientConfig) Descriptor() ([]byte, []int)

Deprecated: Use ClientConfig.ProtoReflect.Descriptor instead.

func (*ClientConfig) GetAddress

func (x *ClientConfig) GetAddress() *net.IPOrDomain

func (*ClientConfig) GetIpsk

func (x *ClientConfig) GetIpsk() [][]byte

func (*ClientConfig) GetMethod

func (x *ClientConfig) GetMethod() string

func (*ClientConfig) GetPort

func (x *ClientConfig) GetPort() uint32

func (*ClientConfig) GetPsk

func (x *ClientConfig) GetPsk() []byte

func (*ClientConfig) ProtoMessage

func (*ClientConfig) ProtoMessage()

func (*ClientConfig) ProtoReflect

func (x *ClientConfig) ProtoReflect() protoreflect.Message

func (*ClientConfig) Reset

func (x *ClientConfig) Reset()

func (*ClientConfig) String

func (x *ClientConfig) String() string

type ClientUDPConnState

type ClientUDPConnState struct {
	// contains filtered or unexported fields
}

func NewClientUDPConnState

func NewClientUDPConnState() (*ClientUDPConnState, error)

func (*ClientUDPConnState) GetOrCreateSession

func (c *ClientUDPConnState) GetOrCreateSession(create func() (*ClientUDPSession, error)) (*ClientUDPSession, error)

type ClientUDPSession

type ClientUDPSession struct {
	// contains filtered or unexported fields
}

func NewClientUDPSession

func NewClientUDPSession(ctx context.Context, conn io.ReadWriteCloser, packetProcessor UDPClientPacketProcessor) *ClientUDPSession

func (*ClientUDPSession) Close

func (c *ClientUDPSession) Close() error

func (*ClientUDPSession) GetCachedServerState added in v5.12.1

func (c *ClientUDPSession) GetCachedServerState(serverSessionID string) UDPClientPacketProcessorCachedState

func (*ClientUDPSession) GetCachedState added in v5.12.1

func (c *ClientUDPSession) GetCachedState(sessionID string) UDPClientPacketProcessorCachedState

func (*ClientUDPSession) KeepReading

func (c *ClientUDPSession) KeepReading()

func (*ClientUDPSession) NewSessionConn

func (c *ClientUDPSession) NewSessionConn() (internet.AbstractPacketConn, error)

func (*ClientUDPSession) PutCachedServerState added in v5.12.1

func (c *ClientUDPSession) PutCachedServerState(serverSessionID string, cache UDPClientPacketProcessorCachedState)

func (*ClientUDPSession) PutCachedState added in v5.12.1

func (c *ClientUDPSession) PutCachedState(sessionID string, cache UDPClientPacketProcessorCachedState)

func (*ClientUDPSession) WriteUDPRequest

func (c *ClientUDPSession) WriteUDPRequest(request *UDPRequest) error

type ClientUDPSessionConn

type ClientUDPSessionConn struct {
	// contains filtered or unexported fields
}

func (*ClientUDPSessionConn) Close

func (c *ClientUDPSessionConn) Close() error

func (*ClientUDPSessionConn) ReadFrom

func (c *ClientUDPSessionConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)

func (*ClientUDPSessionConn) WriteTo

func (c *ClientUDPSessionConn) WriteTo(p []byte, addr gonet.Addr) (n int, err error)

type ClientUDPSessionServerTracker added in v5.12.1

type ClientUDPSessionServerTracker struct {
	// contains filtered or unexported fields
}

type DestinationAddress

type DestinationAddress interface {
	net.Address
}

type ExtensibleIdentityHeaders

type ExtensibleIdentityHeaders interface {
	struc.Custom
}

type KeyDerivation

type KeyDerivation interface {
	GetSessionSubKey(effectivePsk, Salt []byte, OutKey []byte) error
	GetIdentitySubKey(effectivePsk, Salt []byte, OutKey []byte) error
}

type Method

type Method interface {
	GetSessionSubKeyAndSaltLength() int
	GetStreamAEAD(SessionSubKey []byte) (cipher.AEAD, error)
	GenerateEIH(CurrentIdentitySubKey []byte, nextPskHash []byte, out []byte) error
	GetUDPClientProcessor(ipsk [][]byte, psk []byte, derivation KeyDerivation) (UDPClientPacketProcessor, error)
}

type RequestSalt

type RequestSalt interface {
	struc.Custom

	Bytes() []byte
	FillAllFrom(reader io.Reader) error
	// contains filtered or unexported methods
}

type TCPRequest

type TCPRequest struct {
	// contains filtered or unexported fields
}

func (*TCPRequest) CheckC2SConnectionConstraint

func (t *TCPRequest) CheckC2SConnectionConstraint() error

func (*TCPRequest) CreateClientC2SWriter

func (t *TCPRequest) CreateClientC2SWriter(writer io.Writer) buf.Writer

func (*TCPRequest) CreateClientS2CReader

func (t *TCPRequest) CreateClientS2CReader(in io.Reader, initialPayload *buf.Buffer) (buf.Reader, error)

func (*TCPRequest) DecodeTCPResponseHeader

func (t *TCPRequest) DecodeTCPResponseHeader(effectivePsk []byte, in io.Reader) error

func (*TCPRequest) EncodeTCPRequestHeader

func (t *TCPRequest) EncodeTCPRequestHeader(effectivePsk []byte,
	eih [][]byte, address DestinationAddress, destPort int, initialPayload []byte, out *buf.Buffer,
) error

type TCPRequestHeader

type TCPRequestHeader struct {
	PreSessionKeyHeader TCPRequestHeader1PreSessionKey
	FixedLengthHeader   TCPRequestHeader2FixedLength
	Header              TCPRequestHeader3VariableLength
}

type TCPRequestHeader1PreSessionKey

type TCPRequestHeader1PreSessionKey struct {
	Salt RequestSalt
	EIH  ExtensibleIdentityHeaders
}

type TCPRequestHeader2FixedLength

type TCPRequestHeader2FixedLength struct {
	Type         byte
	Timestamp    uint64
	HeaderLength uint16
}

type TCPRequestHeader3VariableLength

type TCPRequestHeader3VariableLength struct {
	DestinationAddress DestinationAddress
	Contents           struct {
		PaddingLength uint16 `struc:"sizeof=Padding"`
		Padding       []byte
	}
}

type TCPResponseHeader

type TCPResponseHeader struct {
	PreSessionKeyHeader TCPResponseHeader1PreSessionKey
	Header              TCPResponseHeader2FixedLength
}

type TCPResponseHeader1PreSessionKey

type TCPResponseHeader1PreSessionKey struct {
	Salt RequestSalt
}

type TCPResponseHeader2FixedLength

type TCPResponseHeader2FixedLength struct {
	Type                 byte
	Timestamp            uint64
	RequestSalt          RequestSalt
	InitialPayloadLength uint16
}

type UDPClientPacketProcessor

type UDPClientPacketProcessor interface {
	EncodeUDPRequest(request *UDPRequest, out *buf.Buffer, cache UDPClientPacketProcessorCachedStateContainer) error
	DecodeUDPResp(input []byte, resp *UDPResponse, cache UDPClientPacketProcessorCachedStateContainer) error
}

UDPClientPacketProcessor Caller retain and receive all ownership of the buffer

type UDPClientPacketProcessorCachedState added in v5.12.1

type UDPClientPacketProcessorCachedState interface{}

type UDPClientPacketProcessorCachedStateContainer added in v5.12.1

type UDPClientPacketProcessorCachedStateContainer interface {
	GetCachedState(sessionID string) UDPClientPacketProcessorCachedState
	PutCachedState(sessionID string, cache UDPClientPacketProcessorCachedState)
	GetCachedServerState(serverSessionID string) UDPClientPacketProcessorCachedState
	PutCachedServerState(serverSessionID string, cache UDPClientPacketProcessorCachedState)
}

type UDPRequest

type UDPRequest struct {
	SessionID [8]byte
	PacketID  uint64
	TimeStamp uint64
	Address   DestinationAddress
	Port      int
	Payload   *buf.Buffer
}

type UDPResponse

type UDPResponse struct {
	UDPRequest
	ClientSessionID [8]byte
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL