Documentation
¶
Overview ¶
Package shadowsocks provides compatible functionality to Shadowsocks.
Shadowsocks client and server are implemented as outbound and inbound respectively in V2Ray's term.
Shadowsocks OTA is fully supported. By default both client and server enable OTA, but it can be optionally disabled.
Supperted Ciphers: * AES-256-CFB * AES-128-CFB * Chacha20 * Chacha20-IEFT
R.I.P Shadowsocks
Index ¶
- Constants
- Variables
- func ChunkKeyGenerator(iv []byte) func() []byte
- func DecodeUDPPacket(user *protocol.MemoryUser, payload *buf.Buffer) (*protocol.RequestHeader, *buf.Buffer, error)
- func EncodeUDPPacket(request *protocol.RequestHeader, payload []byte) (*buf.Buffer, error)
- func HeaderKeyGenerator(key []byte, iv []byte) func() []byte
- func ReadTCPResponse(user *protocol.MemoryUser, reader io.Reader) (buf.Reader, error)
- func ReadTCPSession(user *protocol.MemoryUser, reader io.Reader) (*protocol.RequestHeader, buf.Reader, error)
- func WriteTCPRequest(request *protocol.RequestHeader, writer io.Writer) (buf.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) NewEncryptionWriter(key []byte, iv []byte, writer io.Writer) (buf.Writer, error)
- type Account
- func (a *Account) AsAccount() (protocol.Account, error)
- func (*Account) Descriptor() ([]byte, []int)deprecated
- func (x *Account) GetCipherType() CipherType
- func (x *Account) GetOta() Account_OneTimeAuth
- func (x *Account) GetPassword() string
- func (*Account) ProtoMessage()
- func (x *Account) ProtoReflect() protoreflect.Message
- func (x *Account) Reset()
- func (x *Account) String() string
- type Account_OneTimeAuth
- func (Account_OneTimeAuth) Descriptor() protoreflect.EnumDescriptor
- func (x Account_OneTimeAuth) Enum() *Account_OneTimeAuth
- func (Account_OneTimeAuth) EnumDescriptor() ([]byte, []int)deprecated
- func (x Account_OneTimeAuth) Number() protoreflect.EnumNumber
- func (x Account_OneTimeAuth) String() string
- func (Account_OneTimeAuth) Type() protoreflect.EnumType
- type AesCfb
- func (v *AesCfb) DecodePacket(key []byte, b *buf.Buffer) error
- func (v *AesCfb) EncodePacket(key []byte, b *buf.Buffer) error
- func (v *AesCfb) IVSize() int32
- func (*AesCfb) IsAEAD() bool
- func (v *AesCfb) KeySize() int32
- func (v *AesCfb) NewDecryptionReader(key []byte, iv []byte, reader io.Reader) (buf.Reader, error)
- func (v *AesCfb) NewEncryptionWriter(key []byte, iv []byte, writer io.Writer) (buf.Writer, error)
- type Authenticator
- type ChaCha20
- func (v *ChaCha20) DecodePacket(key []byte, b *buf.Buffer) error
- func (v *ChaCha20) EncodePacket(key []byte, b *buf.Buffer) error
- func (v *ChaCha20) IVSize() int32
- func (*ChaCha20) IsAEAD() bool
- func (v *ChaCha20) KeySize() int32
- func (v *ChaCha20) NewDecryptionReader(key []byte, iv []byte, reader io.Reader) (buf.Reader, error)
- func (v *ChaCha20) NewEncryptionWriter(key []byte, iv []byte, writer io.Writer) (buf.Writer, error)
- type ChunkReader
- type ChunkWriter
- type Cipher
- type CipherType
- type Client
- type ClientConfig
- type KeyGenerator
- 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) NewEncryptionWriter(key []byte, iv []byte, writer io.Writer) (buf.Writer, error)
- type Server
- type ServerConfig
- func (*ServerConfig) Descriptor() ([]byte, []int)deprecated
- func (x *ServerConfig) GetNetwork() []net.Network
- func (x *ServerConfig) GetUdpEnabled() booldeprecated
- func (x *ServerConfig) GetUser() *protocol.User
- func (*ServerConfig) ProtoMessage()
- func (x *ServerConfig) ProtoReflect() protoreflect.Message
- func (x *ServerConfig) Reset()
- func (x *ServerConfig) String() string
- type UDPReader
- type UDPWriter
Constants ¶
const ( Version = 1 RequestOptionOneTimeAuth bitmask.Byte = 0x01 )
const (
// AuthSize is the number of extra bytes for Shadowsocks OTA.
AuthSize = 10
)
Variables ¶
var ( CipherType_name = map[int32]string{ 0: "UNKNOWN", 1: "AES_128_CFB", 2: "AES_256_CFB", 3: "CHACHA20", 4: "CHACHA20_IETF", 5: "AES_128_GCM", 6: "AES_256_GCM", 7: "CHACHA20_POLY1305", 8: "NONE", } CipherType_value = map[string]int32{ "UNKNOWN": 0, "AES_128_CFB": 1, "AES_256_CFB": 2, "CHACHA20": 3, "CHACHA20_IETF": 4, "AES_128_GCM": 5, "AES_256_GCM": 6, "CHACHA20_POLY1305": 7, "NONE": 8, } )
Enum value maps for CipherType.
var ( Account_OneTimeAuth_name = map[int32]string{ 0: "Auto", 1: "Disabled", 2: "Enabled", } Account_OneTimeAuth_value = map[string]int32{ "Auto": 0, "Disabled": 1, "Enabled": 2, } )
Enum value maps for Account_OneTimeAuth.
var File_v2ray_com_core_proxy_shadowsocks_config_proto protoreflect.FileDescriptor
Functions ¶
func ChunkKeyGenerator ¶
func DecodeUDPPacket ¶
func DecodeUDPPacket(user *protocol.MemoryUser, payload *buf.Buffer) (*protocol.RequestHeader, *buf.Buffer, error)
func EncodeUDPPacket ¶
func HeaderKeyGenerator ¶
func ReadTCPResponse ¶
func ReadTCPSession ¶
func ReadTCPSession(user *protocol.MemoryUser, reader io.Reader) (*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 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) NewEncryptionWriter ¶
type Account ¶
type Account struct {
Password string `protobuf:"bytes,1,opt,name=password,proto3" json:"password,omitempty"`
CipherType CipherType `` /* 137-byte string literal not displayed */
Ota Account_OneTimeAuth `protobuf:"varint,3,opt,name=ota,proto3,enum=v2ray.core.proxy.shadowsocks.Account_OneTimeAuth" json:"ota,omitempty"`
// contains filtered or unexported fields
}
func (*Account) Descriptor
deprecated
func (*Account) GetCipherType ¶
func (x *Account) GetCipherType() CipherType
func (*Account) GetOta ¶
func (x *Account) GetOta() Account_OneTimeAuth
func (*Account) GetPassword ¶
func (*Account) ProtoMessage ¶
func (*Account) ProtoMessage()
func (*Account) ProtoReflect ¶
func (x *Account) ProtoReflect() protoreflect.Message
type Account_OneTimeAuth ¶
type Account_OneTimeAuth int32
const ( Account_Auto Account_OneTimeAuth = 0 Account_Disabled Account_OneTimeAuth = 1 Account_Enabled Account_OneTimeAuth = 2 )
func (Account_OneTimeAuth) Descriptor ¶
func (Account_OneTimeAuth) Descriptor() protoreflect.EnumDescriptor
func (Account_OneTimeAuth) Enum ¶
func (x Account_OneTimeAuth) Enum() *Account_OneTimeAuth
func (Account_OneTimeAuth) EnumDescriptor
deprecated
func (Account_OneTimeAuth) EnumDescriptor() ([]byte, []int)
Deprecated: Use Account_OneTimeAuth.Descriptor instead.
func (Account_OneTimeAuth) Number ¶
func (x Account_OneTimeAuth) Number() protoreflect.EnumNumber
func (Account_OneTimeAuth) String ¶
func (x Account_OneTimeAuth) String() string
func (Account_OneTimeAuth) Type ¶
func (Account_OneTimeAuth) Type() protoreflect.EnumType
type AesCfb ¶
type AesCfb struct {
KeyBytes int32
}
AesCfb represents all AES-CFB ciphers.
func (*AesCfb) NewDecryptionReader ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
func NewAuthenticator ¶
func NewAuthenticator(keygen KeyGenerator) *Authenticator
func (*Authenticator) Authenticate ¶
func (v *Authenticator) Authenticate(data []byte, dest []byte)
type ChunkReader ¶
type ChunkReader struct {
// contains filtered or unexported fields
}
func NewChunkReader ¶
func NewChunkReader(reader io.Reader, auth *Authenticator) *ChunkReader
func (*ChunkReader) ReadMultiBuffer ¶
func (v *ChunkReader) ReadMultiBuffer() (buf.MultiBuffer, error)
type ChunkWriter ¶
type ChunkWriter struct {
// contains filtered or unexported fields
}
func NewChunkWriter ¶
func NewChunkWriter(writer io.Writer, auth *Authenticator) *ChunkWriter
func (*ChunkWriter) WriteMultiBuffer ¶
func (w *ChunkWriter) WriteMultiBuffer(mb buf.MultiBuffer) error
WriteMultiBuffer implements buf.Writer.
type Cipher ¶
type Cipher interface {
KeySize() int32
IVSize() int32
NewEncryptionWriter(key []byte, iv []byte, writer io.Writer) (buf.Writer, error)
NewDecryptionReader(key []byte, iv []byte, reader io.Reader) (buf.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_UNKNOWN CipherType = 0 CipherType_AES_128_CFB CipherType = 1 CipherType_AES_256_CFB CipherType = 2 CipherType_CHACHA20 CipherType = 3 CipherType_CHACHA20_IETF CipherType = 4 CipherType_AES_128_GCM CipherType = 5 CipherType_AES_256_GCM CipherType = 6 CipherType_CHACHA20_POLY1305 CipherType = 7 CipherType_NONE CipherType = 8 )
func (CipherType) Descriptor ¶
func (CipherType) Descriptor() protoreflect.EnumDescriptor
func (CipherType) Enum ¶
func (x CipherType) Enum() *CipherType
func (CipherType) EnumDescriptor
deprecated
func (CipherType) EnumDescriptor() ([]byte, []int)
Deprecated: Use CipherType.Descriptor instead.
func (CipherType) Number ¶
func (x CipherType) Number() protoreflect.EnumNumber
func (CipherType) String ¶
func (x CipherType) String() string
func (CipherType) Type ¶
func (CipherType) Type() protoreflect.EnumType
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a inbound handler for Shadowsocks protocol
type ClientConfig ¶
type ClientConfig struct {
Server []*protocol.ServerEndpoint `protobuf:"bytes,1,rep,name=server,proto3" json:"server,omitempty"`
// contains filtered or unexported fields
}
func (*ClientConfig) Descriptor
deprecated
func (*ClientConfig) Descriptor() ([]byte, []int)
Deprecated: Use ClientConfig.ProtoReflect.Descriptor instead.
func (*ClientConfig) GetServer ¶
func (x *ClientConfig) GetServer() []*protocol.ServerEndpoint
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 KeyGenerator ¶
type KeyGenerator func() []byte
type MemoryAccount ¶
type MemoryAccount struct {
Cipher Cipher
Key []byte
OneTimeAuth Account_OneTimeAuth
}
MemoryAccount is an account type converted from Account.
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) NewEncryptionWriter ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
type ServerConfig ¶
type ServerConfig struct {
// UdpEnabled specified whether or not to enable UDP for Shadowsocks.
// Deprecated. Use 'network' field.
//
// Deprecated: Do not use.
UdpEnabled bool `protobuf:"varint,1,opt,name=udp_enabled,json=udpEnabled,proto3" json:"udp_enabled,omitempty"`
User *protocol.User `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"`
Network []net.Network `protobuf:"varint,3,rep,packed,name=network,proto3,enum=v2ray.core.common.net.Network" json:"network,omitempty"`
// contains filtered or unexported fields
}
func (*ServerConfig) Descriptor
deprecated
func (*ServerConfig) Descriptor() ([]byte, []int)
Deprecated: Use ServerConfig.ProtoReflect.Descriptor instead.
func (*ServerConfig) GetNetwork ¶
func (x *ServerConfig) GetNetwork() []net.Network
func (*ServerConfig) GetUdpEnabled
deprecated
func (x *ServerConfig) GetUdpEnabled() bool
Deprecated: Do not use.
func (*ServerConfig) GetUser ¶
func (x *ServerConfig) GetUser() *protocol.User
func (*ServerConfig) ProtoMessage ¶
func (*ServerConfig) ProtoMessage()
func (*ServerConfig) ProtoReflect ¶
func (x *ServerConfig) ProtoReflect() protoreflect.Message
func (*ServerConfig) Reset ¶
func (x *ServerConfig) Reset()
func (*ServerConfig) String ¶
func (x *ServerConfig) String() string
type UDPReader ¶
type UDPReader struct {
Reader io.Reader
User *protocol.MemoryUser
}
func (*UDPReader) ReadMultiBuffer ¶
func (v *UDPReader) ReadMultiBuffer() (buf.MultiBuffer, error)