core: v2ray.com/core/proxy/shadowsocks Index | Files

package shadowsocks

import "v2ray.com/core/proxy/shadowsocks"

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

Package Files

client.go config.go config.pb.go errors.generated.go ota.go protocol.go server.go shadowsocks.go

Constants

const (
    Version                               = 1
    RequestOptionOneTimeAuth bitmask.Byte = 0x01
)
const (
    // AuthSize is the number of extra bytes for Shadowsocks OTA.
    AuthSize = 10
)

Variables

var Account_OneTimeAuth_name = map[int32]string{
    0:  "Auto",
    1:  "Disabled",
    2:  "Enabled",
}
var Account_OneTimeAuth_value = map[string]int32{
    "Auto":     0,
    "Disabled": 1,
    "Enabled":  2,
}
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",
}
var 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,
}

func ChunkKeyGenerator Uses

func ChunkKeyGenerator(iv []byte) func() []byte

func DecodeUDPPacket Uses

func DecodeUDPPacket(user *protocol.MemoryUser, payload *buf.Buffer) (*protocol.RequestHeader, *buf.Buffer, error)

func EncodeUDPPacket Uses

func EncodeUDPPacket(request *protocol.RequestHeader, payload []byte) (*buf.Buffer, error)

func HeaderKeyGenerator Uses

func HeaderKeyGenerator(key []byte, iv []byte) func() []byte

func ReadTCPResponse Uses

func ReadTCPResponse(user *protocol.MemoryUser, reader io.Reader) (buf.Reader, error)

func ReadTCPSession Uses

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 Uses

func WriteTCPRequest(request *protocol.RequestHeader, writer io.Writer) (buf.Writer, error)

WriteTCPRequest writes Shadowsocks request into the given writer, and returns a writer for body.

func WriteTCPResponse Uses

func WriteTCPResponse(request *protocol.RequestHeader, writer io.Writer) (buf.Writer, error)

type AEADCipher Uses

type AEADCipher struct {
    KeyBytes        int32
    IVBytes         int32
    AEADAuthCreator func(key []byte) cipher.AEAD
}

func (*AEADCipher) DecodePacket Uses

func (c *AEADCipher) DecodePacket(key []byte, b *buf.Buffer) error

func (*AEADCipher) EncodePacket Uses

func (c *AEADCipher) EncodePacket(key []byte, b *buf.Buffer) error

func (*AEADCipher) IVSize Uses

func (c *AEADCipher) IVSize() int32

func (*AEADCipher) IsAEAD Uses

func (*AEADCipher) IsAEAD() bool

func (*AEADCipher) KeySize Uses

func (c *AEADCipher) KeySize() int32

func (*AEADCipher) NewDecryptionReader Uses

func (c *AEADCipher) NewDecryptionReader(key []byte, iv []byte, reader io.Reader) (buf.Reader, error)

func (*AEADCipher) NewEncryptionWriter Uses

func (c *AEADCipher) NewEncryptionWriter(key []byte, iv []byte, writer io.Writer) (buf.Writer, error)

type Account Uses

type Account struct {
    Password             string              `protobuf:"bytes,1,opt,name=password,proto3" json:"password,omitempty"`
    CipherType           CipherType          `protobuf:"varint,2,opt,name=cipher_type,json=cipherType,proto3,enum=v2ray.core.proxy.shadowsocks.CipherType" json:"cipher_type,omitempty"`
    Ota                  Account_OneTimeAuth `protobuf:"varint,3,opt,name=ota,proto3,enum=v2ray.core.proxy.shadowsocks.Account_OneTimeAuth" json:"ota,omitempty"`
    XXX_NoUnkeyedLiteral struct{}            `json:"-"`
    XXX_unrecognized     []byte              `json:"-"`
    XXX_sizecache        int32               `json:"-"`
}

func (*Account) AsAccount Uses

func (a *Account) AsAccount() (protocol.Account, error)

AsAccount implements protocol.AsAccount.

func (*Account) Descriptor Uses

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

func (*Account) GetCipherType Uses

func (m *Account) GetCipherType() CipherType

func (*Account) GetOta Uses

func (m *Account) GetOta() Account_OneTimeAuth

func (*Account) GetPassword Uses

func (m *Account) GetPassword() string

func (*Account) ProtoMessage Uses

func (*Account) ProtoMessage()

func (*Account) Reset Uses

func (m *Account) Reset()

func (*Account) String Uses

func (m *Account) String() string

func (*Account) XXX_DiscardUnknown Uses

func (m *Account) XXX_DiscardUnknown()

func (*Account) XXX_Marshal Uses

func (m *Account) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Account) XXX_Merge Uses

func (m *Account) XXX_Merge(src proto.Message)

func (*Account) XXX_Size Uses

func (m *Account) XXX_Size() int

func (*Account) XXX_Unmarshal Uses

func (m *Account) XXX_Unmarshal(b []byte) error

type Account_OneTimeAuth Uses

type Account_OneTimeAuth int32
const (
    Account_Auto     Account_OneTimeAuth = 0
    Account_Disabled Account_OneTimeAuth = 1
    Account_Enabled  Account_OneTimeAuth = 2
)

func (Account_OneTimeAuth) EnumDescriptor Uses

func (Account_OneTimeAuth) EnumDescriptor() ([]byte, []int)

func (Account_OneTimeAuth) String Uses

func (x Account_OneTimeAuth) String() string

type AesCfb Uses

type AesCfb struct {
    KeyBytes int32
}

AesCfb represents all AES-CFB ciphers.

func (*AesCfb) DecodePacket Uses

func (v *AesCfb) DecodePacket(key []byte, b *buf.Buffer) error

func (*AesCfb) EncodePacket Uses

func (v *AesCfb) EncodePacket(key []byte, b *buf.Buffer) error

func (*AesCfb) IVSize Uses

func (v *AesCfb) IVSize() int32

func (*AesCfb) IsAEAD Uses

func (*AesCfb) IsAEAD() bool

func (*AesCfb) KeySize Uses

func (v *AesCfb) KeySize() int32

func (*AesCfb) NewDecryptionReader Uses

func (v *AesCfb) NewDecryptionReader(key []byte, iv []byte, reader io.Reader) (buf.Reader, error)

func (*AesCfb) NewEncryptionWriter Uses

func (v *AesCfb) NewEncryptionWriter(key []byte, iv []byte, writer io.Writer) (buf.Writer, error)

type Authenticator Uses

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

func NewAuthenticator Uses

func NewAuthenticator(keygen KeyGenerator) *Authenticator

func (*Authenticator) Authenticate Uses

func (v *Authenticator) Authenticate(data []byte, dest []byte)

type ChaCha20 Uses

type ChaCha20 struct {
    IVBytes int32
}

func (*ChaCha20) DecodePacket Uses

func (v *ChaCha20) DecodePacket(key []byte, b *buf.Buffer) error

func (*ChaCha20) EncodePacket Uses

func (v *ChaCha20) EncodePacket(key []byte, b *buf.Buffer) error

func (*ChaCha20) IVSize Uses

func (v *ChaCha20) IVSize() int32

func (*ChaCha20) IsAEAD Uses

func (*ChaCha20) IsAEAD() bool

func (*ChaCha20) KeySize Uses

func (v *ChaCha20) KeySize() int32

func (*ChaCha20) NewDecryptionReader Uses

func (v *ChaCha20) NewDecryptionReader(key []byte, iv []byte, reader io.Reader) (buf.Reader, error)

func (*ChaCha20) NewEncryptionWriter Uses

func (v *ChaCha20) NewEncryptionWriter(key []byte, iv []byte, writer io.Writer) (buf.Writer, error)

type ChunkReader Uses

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

func NewChunkReader Uses

func NewChunkReader(reader io.Reader, auth *Authenticator) *ChunkReader

func (*ChunkReader) ReadMultiBuffer Uses

func (v *ChunkReader) ReadMultiBuffer() (buf.MultiBuffer, error)

type ChunkWriter Uses

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

func NewChunkWriter Uses

func NewChunkWriter(writer io.Writer, auth *Authenticator) *ChunkWriter

func (*ChunkWriter) WriteMultiBuffer Uses

func (w *ChunkWriter) WriteMultiBuffer(mb buf.MultiBuffer) error

WriteMultiBuffer implements buf.Writer.

type Cipher Uses

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 Uses

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) EnumDescriptor Uses

func (CipherType) EnumDescriptor() ([]byte, []int)

func (CipherType) String Uses

func (x CipherType) String() string

type Client Uses

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

Client is a inbound handler for Shadowsocks protocol

func NewClient Uses

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

NewClient create a new Shadowsocks client.

func (*Client) Process Uses

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

Process implements OutboundHandler.Process().

type ClientConfig Uses

type ClientConfig struct {
    Server               []*protocol.ServerEndpoint `protobuf:"bytes,1,rep,name=server,proto3" json:"server,omitempty"`
    XXX_NoUnkeyedLiteral struct{}                   `json:"-"`
    XXX_unrecognized     []byte                     `json:"-"`
    XXX_sizecache        int32                      `json:"-"`
}

func (*ClientConfig) Descriptor Uses

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

func (*ClientConfig) GetServer Uses

func (m *ClientConfig) GetServer() []*protocol.ServerEndpoint

func (*ClientConfig) ProtoMessage Uses

func (*ClientConfig) ProtoMessage()

func (*ClientConfig) Reset Uses

func (m *ClientConfig) Reset()

func (*ClientConfig) String Uses

func (m *ClientConfig) String() string

func (*ClientConfig) XXX_DiscardUnknown Uses

func (m *ClientConfig) XXX_DiscardUnknown()

func (*ClientConfig) XXX_Marshal Uses

func (m *ClientConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ClientConfig) XXX_Merge Uses

func (m *ClientConfig) XXX_Merge(src proto.Message)

func (*ClientConfig) XXX_Size Uses

func (m *ClientConfig) XXX_Size() int

func (*ClientConfig) XXX_Unmarshal Uses

func (m *ClientConfig) XXX_Unmarshal(b []byte) error

type KeyGenerator Uses

type KeyGenerator func() []byte

type MemoryAccount Uses

type MemoryAccount struct {
    Cipher      Cipher
    Key         []byte
    OneTimeAuth Account_OneTimeAuth
}

MemoryAccount is an account type converted from Account.

func (*MemoryAccount) Equals Uses

func (a *MemoryAccount) Equals(another protocol.Account) bool

Equals implements protocol.Account.Equals().

type NoneCipher Uses

type NoneCipher struct{}

func (NoneCipher) DecodePacket Uses

func (NoneCipher) DecodePacket(key []byte, b *buf.Buffer) error

func (NoneCipher) EncodePacket Uses

func (NoneCipher) EncodePacket(key []byte, b *buf.Buffer) error

func (NoneCipher) IVSize Uses

func (NoneCipher) IVSize() int32

func (NoneCipher) IsAEAD Uses

func (NoneCipher) IsAEAD() bool

func (NoneCipher) KeySize Uses

func (NoneCipher) KeySize() int32

func (NoneCipher) NewDecryptionReader Uses

func (NoneCipher) NewDecryptionReader(key []byte, iv []byte, reader io.Reader) (buf.Reader, error)

func (NoneCipher) NewEncryptionWriter Uses

func (NoneCipher) NewEncryptionWriter(key []byte, iv []byte, writer io.Writer) (buf.Writer, error)

type Server Uses

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

func NewServer Uses

func NewServer(ctx context.Context, config *ServerConfig) (*Server, error)

NewServer create a new Shadowsocks server.

func (*Server) Network Uses

func (s *Server) Network() []net.Network

func (*Server) Process Uses

func (s *Server) Process(ctx context.Context, network net.Network, conn internet.Connection, dispatcher routing.Dispatcher) error

type ServerConfig Uses

type ServerConfig struct {
    // UdpEnabled specified whether or not to enable UDP for Shadowsocks.
    // Deprecated. Use 'network' field.
    UdpEnabled           bool           `protobuf:"varint,1,opt,name=udp_enabled,json=udpEnabled,proto3" json:"udp_enabled,omitempty"` // Deprecated: Do not use.
    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"`
    XXX_NoUnkeyedLiteral struct{}       `json:"-"`
    XXX_unrecognized     []byte         `json:"-"`
    XXX_sizecache        int32          `json:"-"`
}

func (*ServerConfig) Descriptor Uses

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

func (*ServerConfig) GetNetwork Uses

func (m *ServerConfig) GetNetwork() []net.Network

func (*ServerConfig) GetUdpEnabled Uses

func (m *ServerConfig) GetUdpEnabled() bool

Deprecated: Do not use.

func (*ServerConfig) GetUser Uses

func (m *ServerConfig) GetUser() *protocol.User

func (*ServerConfig) ProtoMessage Uses

func (*ServerConfig) ProtoMessage()

func (*ServerConfig) Reset Uses

func (m *ServerConfig) Reset()

func (*ServerConfig) String Uses

func (m *ServerConfig) String() string

func (*ServerConfig) XXX_DiscardUnknown Uses

func (m *ServerConfig) XXX_DiscardUnknown()

func (*ServerConfig) XXX_Marshal Uses

func (m *ServerConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ServerConfig) XXX_Merge Uses

func (m *ServerConfig) XXX_Merge(src proto.Message)

func (*ServerConfig) XXX_Size Uses

func (m *ServerConfig) XXX_Size() int

func (*ServerConfig) XXX_Unmarshal Uses

func (m *ServerConfig) XXX_Unmarshal(b []byte) error

type UDPReader Uses

type UDPReader struct {
    Reader io.Reader
    User   *protocol.MemoryUser
}

func (*UDPReader) ReadMultiBuffer Uses

func (v *UDPReader) ReadMultiBuffer() (buf.MultiBuffer, error)

type UDPWriter Uses

type UDPWriter struct {
    Writer  io.Writer
    Request *protocol.RequestHeader
}

func (*UDPWriter) Write Uses

func (w *UDPWriter) Write(payload []byte) (int, error)

Write implements io.Writer.

Package shadowsocks imports 37 packages (graph) and is imported by 6 packages. Updated 2019-02-28. Refresh now. Tools for package owners.