Documentation
¶
Index ¶
- Constants
- func DecodeUDPPacket(account *MemoryAccount, payload *buf.Buffer) (*protocol.RequestHeader, *buf.Buffer, error)
- func EncodeUDPPacket(request *protocol.RequestHeader, payload []byte) (*buf.Buffer, error)
- func ReadTCPResponse(account *MemoryAccount, reader io.Reader) (buf.Reader, error)
- func ReadTCPResponseIO(account *MemoryAccount, reader io.Reader) (io.Reader, error)
- func ReadTCPSession(account *MemoryAccount, reader io.Reader, drainOnError bool) (*protocol.RequestHeader, buf.Reader, error)
- func WriteTCPRequest(request *protocol.RequestHeader, writer io.Writer) (buf.Writer, error)
- func WriteTCPRequestIO(request *protocol.RequestHeader, writer io.Writer) (io.Writer, error)
- func WriteTCPResponse(request *protocol.RequestHeader, writer io.Writer) (buf.Writer, error)
- type AEADCipher
- func (c *AEADCipher) DecodePacket(key []byte, b *buf.Buffer) error
- func (c *AEADCipher) EncodePacket(key []byte, b *buf.Buffer) error
- func (c *AEADCipher) IVSize() int32
- func (*AEADCipher) IsAEAD() bool
- func (c *AEADCipher) KeySize() int32
- func (c *AEADCipher) NewDecryptionReader(key []byte, iv []byte, reader io.Reader) (buf.Reader, error)
- func (c *AEADCipher) NewDecryptionReaderIO(key []byte, iv []byte, reader io.Reader) (io.Reader, error)
- func (c *AEADCipher) NewEncryptionWriter(key []byte, iv []byte, writer io.Writer) (buf.Writer, error)
- func (c *AEADCipher) NewEncryptionWriterIO(key []byte, iv []byte, writer io.Writer) (io.Writer, error)
- type Cipher
- type CipherType
- type Client
- func (c *Client) HandleFlow(ctx context.Context, dst net.Destination, rw buf.ReaderWriter) error
- func (c *Client) HandlePacketConn(ctx context.Context, dst net.Destination, p udp.PacketReaderWriter) error
- func (c *Client) ListenPacket(ctx context.Context, dst net.Destination) (udp.UdpConn, error)
- func (c *Client) ProxyDial(ctx context.Context, dst net.Destination, initialData buf.MultiBuffer) (i.FlowConn, error)
- type ClientSettings
- type MemoryAccount
- type NoneCipher
- func (NoneCipher) DecodePacket(key []byte, b *buf.Buffer) error
- func (NoneCipher) EncodePacket(key []byte, b *buf.Buffer) error
- func (NoneCipher) IVSize() int32
- func (NoneCipher) IsAEAD() bool
- func (NoneCipher) KeySize() int32
- func (NoneCipher) NewDecryptionReader(key []byte, iv []byte, reader io.Reader) (buf.Reader, error)
- func (NoneCipher) NewDecryptionReaderIO(key []byte, iv []byte, reader io.Reader) (io.Reader, error)
- func (NoneCipher) NewEncryptionWriter(key []byte, iv []byte, writer io.Writer) (buf.Writer, error)
- func (NoneCipher) NewEncryptionWriterIO(key []byte, iv []byte, writer io.Writer) (io.Writer, error)
- type UDPReader
- type UDPWriter
Constants ¶
View Source
const (
Version = 1
)
Variables ¶
This section is empty.
Functions ¶
func DecodeUDPPacket ¶
func DecodeUDPPacket(account *MemoryAccount, payload *buf.Buffer) (*protocol.RequestHeader, *buf.Buffer, error)
func EncodeUDPPacket ¶
func ReadTCPResponse ¶
func ReadTCPResponseIO ¶
func ReadTCPSession ¶
func ReadTCPSession(account *MemoryAccount, reader io.Reader, drainOnError bool) (*protocol.RequestHeader, buf.Reader, error)
ReadTCPSession reads a Shadowsocks TCP session from the given reader, returns its header and remaining parts.
func WriteTCPRequest ¶
WriteTCPRequest writes Shadowsocks request into the given writer, and returns a writer for body.
func WriteTCPRequestIO ¶
WriteTCPRequest writes Shadowsocks request into the given writer, and returns a writer for body.
func WriteTCPResponse ¶
Types ¶
type AEADCipher ¶
type AEADCipher struct {
KeyBytes int32
IVBytes int32
AEADAuthCreator func(key []byte) cipher.AEAD
}
func (*AEADCipher) DecodePacket ¶
func (c *AEADCipher) DecodePacket(key []byte, b *buf.Buffer) error
func (*AEADCipher) EncodePacket ¶
func (c *AEADCipher) EncodePacket(key []byte, b *buf.Buffer) error
func (*AEADCipher) IVSize ¶
func (c *AEADCipher) IVSize() int32
func (*AEADCipher) IsAEAD ¶
func (*AEADCipher) IsAEAD() bool
func (*AEADCipher) KeySize ¶
func (c *AEADCipher) KeySize() int32
func (*AEADCipher) NewDecryptionReader ¶
func (*AEADCipher) NewDecryptionReaderIO ¶
func (*AEADCipher) NewEncryptionWriter ¶
func (*AEADCipher) NewEncryptionWriterIO ¶
type Cipher ¶
type Cipher interface {
KeySize() int32
IVSize() int32
NewEncryptionWriter(key []byte, iv []byte, writer io.Writer) (buf.Writer, error)
NewEncryptionWriterIO(key []byte, iv []byte, writer io.Writer) (io.Writer, error)
NewDecryptionReader(key []byte, iv []byte, reader io.Reader) (buf.Reader, error)
NewDecryptionReaderIO(key []byte, iv []byte, reader io.Reader) (io.Reader, error)
IsAEAD() bool
EncodePacket(key []byte, b *buf.Buffer) error
DecodePacket(key []byte, b *buf.Buffer) error
}
Cipher is an interface for all Shadowsocks ciphers.
type CipherType ¶
type CipherType int32
const ( CipherType_AES_128_GCM CipherType = 0 CipherType_AES_256_GCM CipherType = 1 CipherType_CHACHA20_POLY1305 CipherType = 2 CipherType_NONE CipherType = 3 )
type Client ¶
type Client struct {
ClientSettings
}
Client is a inbound handler for Shadowsocks protocol
func NewClient ¶
func NewClient(settings *ClientSettings) *Client
NewClient create a new Shadowsocks client.
func (*Client) HandleFlow ¶
func (c *Client) HandleFlow(ctx context.Context, dst net.Destination, rw buf.ReaderWriter) error
func (*Client) HandlePacketConn ¶
func (c *Client) HandlePacketConn(ctx context.Context, dst net.Destination, p udp.PacketReaderWriter) error
func (*Client) ListenPacket ¶
type ClientSettings ¶
type ClientSettings struct {
Address net.Address
PortPicker i.PortSelector
Account *MemoryAccount
Dialer i.Dialer
}
type MemoryAccount ¶
type MemoryAccount struct {
Cipher Cipher
Key []byte
Uid string
ReplayFilter antireplay.GeneralizedReplayFilter
ReducedIVEntropy bool
}
MemoryAccount is an account type converted from Account.
func NewMemoryAccount ¶
func NewMemoryAccount(uid string, cipher CipherType, password string, reducedIVEntropy, ivCheck bool) (*MemoryAccount, error)
func (*MemoryAccount) CheckIV ¶
func (a *MemoryAccount) CheckIV(iv []byte) error
type NoneCipher ¶
type NoneCipher struct{}
func (NoneCipher) DecodePacket ¶
func (NoneCipher) DecodePacket(key []byte, b *buf.Buffer) error
func (NoneCipher) EncodePacket ¶
func (NoneCipher) EncodePacket(key []byte, b *buf.Buffer) error
func (NoneCipher) IVSize ¶
func (NoneCipher) IVSize() int32
func (NoneCipher) IsAEAD ¶
func (NoneCipher) IsAEAD() bool
func (NoneCipher) KeySize ¶
func (NoneCipher) KeySize() int32
func (NoneCipher) NewDecryptionReader ¶
func (NoneCipher) NewDecryptionReaderIO ¶
func (NoneCipher) NewEncryptionWriter ¶
func (NoneCipher) NewEncryptionWriterIO ¶
type UDPReader ¶
type UDPReader struct {
Reader io.Reader
User *MemoryAccount
}
func (*UDPReader) ReadMultiBuffer ¶
func (v *UDPReader) ReadMultiBuffer() (buf.MultiBuffer, error)
Click to show internal directories.
Click to hide internal directories.