Documentation ¶
Overview ¶
Package shadowsocks provides compatible functionality to Shadowsocks.
Shadowsocks client and server are implemented as outbound and inbound respectively in Xray's term.
R.I.P Shadowsocks
Index ¶
- Constants
- Variables
- func DecodeUDPPacket(validator *Validator, payload *buf.Buffer) (*protocol.RequestHeader, *buf.Buffer, error)
- func EncodeUDPPacket(request *protocol.RequestHeader, payload []byte) (*buf.Buffer, error)
- func ReadTCPResponse(user *protocol.MemoryUser, reader io.Reader) (buf.Reader, error)
- func ReadTCPSession(validator *Validator, 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) GetIvCheck() bool
- func (x *Account) GetPassword() string
- func (*Account) ProtoMessage()
- func (x *Account) ProtoReflect() protoreflect.Message
- func (x *Account) Reset()
- func (x *Account) String() string
- type Cipher
- type CipherType
- type Client
- type ClientConfig
- type FullReader
- 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) GetUsers() []*protocol.User
- func (*ServerConfig) ProtoMessage()
- func (x *ServerConfig) ProtoReflect() protoreflect.Message
- func (x *ServerConfig) Reset()
- func (x *ServerConfig) String() string
- type UDPReader
- type UDPWriter
- type Validator
Constants ¶
const (
Version = 1
)
Variables ¶
var ( CipherType_name = map[int32]string{ 0: "UNKNOWN", 5: "AES_128_GCM", 6: "AES_256_GCM", 7: "CHACHA20_POLY1305", 8: "XCHACHA20_POLY1305", 9: "NONE", } CipherType_value = map[string]int32{ "UNKNOWN": 0, "AES_128_GCM": 5, "AES_256_GCM": 6, "CHACHA20_POLY1305": 7, "XCHACHA20_POLY1305": 8, "NONE": 9, } )
Enum value maps for CipherType.
var (
ErrIVNotUnique = newError("IV is not unique")
)
var (
ErrNotFound = newError("Not Found")
)
var File_proxy_shadowsocks_config_proto protoreflect.FileDescriptor
Functions ¶
func DecodeUDPPacket ¶
func EncodeUDPPacket ¶
func ReadTCPResponse ¶
func ReadTCPSession ¶
func ReadTCPSession(validator *Validator, 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 `` /* 131-byte string literal not displayed */ IvCheck bool `protobuf:"varint,3,opt,name=iv_check,json=ivCheck,proto3" json:"iv_check,omitempty"` // contains filtered or unexported fields }
func (*Account) Descriptor
deprecated
func (*Account) GetCipherType ¶
func (x *Account) GetCipherType() CipherType
func (*Account) GetIvCheck ¶
func (*Account) GetPassword ¶
func (*Account) ProtoMessage ¶
func (*Account) ProtoMessage()
func (*Account) ProtoReflect ¶
func (x *Account) ProtoReflect() protoreflect.Message
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_GCM CipherType = 5 CipherType_AES_256_GCM CipherType = 6 CipherType_CHACHA20_POLY1305 CipherType = 7 CipherType_XCHACHA20_POLY1305 CipherType = 8 CipherType_NONE CipherType = 9 )
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 FullReader ¶
type FullReader struct {
// contains filtered or unexported fields
}
type MemoryAccount ¶
MemoryAccount is an account type converted from Account.
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) NewEncryptionWriter ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(ctx context.Context, config *ServerConfig) (*Server, error)
NewServer create a new Shadowsocks server.
type ServerConfig ¶
type ServerConfig struct { Users []*protocol.User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"` Network []net.Network `protobuf:"varint,2,rep,packed,name=network,proto3,enum=xray.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) GetUsers ¶
func (x *ServerConfig) GetUsers() []*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)
type UDPWriter ¶
type UDPWriter struct { Writer io.Writer Request *protocol.RequestHeader }
func (*UDPWriter) WriteMultiBuffer ¶
func (w *UDPWriter) WriteMultiBuffer(mb buf.MultiBuffer) error
type Validator ¶
Validator stores valid Shadowsocks users.
func (*Validator) Add ¶
func (v *Validator) Add(u *protocol.MemoryUser) error
Add a Shadowsocks user.
func (*Validator) Get ¶
func (v *Validator) Get(bs []byte, command protocol.RequestCommand) (u *protocol.MemoryUser, aead cipher.AEAD, ret []byte, ivLen int32, err error)
Get a Shadowsocks user.