Documentation
¶
Index ¶
- func CipherList() []string
- func GetCipherAndPasswordFromUserinfo(user *url.Userinfo) (cipher, password string, err error)
- func IsCipher(method string) bool
- func KDF(password string, keyLen int) []byte
- func RegisterCipher(method string, fun func(password string) (ConnCipher, error))
- type BytesPool
- type ConnCipher
- type Dialer
- type ListenPacket
- type Logger
- type PacketClient
- type PacketServer
- type Server
- type SimplePacketServer
- type SimpleServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CipherList ¶
func CipherList() []string
func GetCipherAndPasswordFromUserinfo ¶ added in v0.2.1
func RegisterCipher ¶
func RegisterCipher(method string, fun func(password string) (ConnCipher, error))
Types ¶
type BytesPool ¶
BytesPool is an interface for getting and returning temporary bytes for use by io.CopyBuffer.
type ConnCipher ¶
type ConnCipher interface {
StreamConn(net.Conn) net.Conn
Decrypt(dist, src []byte) (n int, err error)
Encrypt(dist, src []byte) (n int, err error)
}
func NewCipher ¶
func NewCipher(method, password string) (c ConnCipher, err error)
NewCipher creates a cipher that can be used in Dial()
type Dialer ¶
type Dialer struct {
// ProxyNetwork network between a proxy server and a client
ProxyNetwork string
// ProxyAddress proxy server address
ProxyAddress string
// ProxyDial specifies the optional dial function for
// establishing the transport connection.
ProxyDial func(context.Context, string, string) (net.Conn, error)
// Cipher use cipher protocol
Cipher string
// Password use password authentication
Password string
// ConnCipher is connect the cipher codec
ConnCipher ConnCipher
// IsResolve resolve domain name on locally
IsResolve bool
// Resolver optionally specifies an alternate resolver to use
Resolver *net.Resolver
// Timeout is the maximum amount of time a dial will wait for
// a connect to complete. The default is no timeout
Timeout time.Duration
}
Dialer is a shadowsocks dialer.
func NewDialer ¶
NewDialer returns a new Dialer that dials through the provided proxy server's network and address.
type ListenPacket ¶ added in v0.2.0
type PacketClient ¶ added in v0.2.0
type PacketClient struct {
// ProxyNetwork network between a proxy server and a client
ProxyNetwork string
// ProxyAddress proxy server address
ProxyAddress string
// ProxyPacket specifies the optional dial function for
// establishing the transport connection.
ProxyPacket func(ctx context.Context, network, address string) (net.PacketConn, error)
// Cipher use cipher protocol
Cipher string
// Password use password authentication
Password string
// ConnCipher is connect the cipher codec
ConnCipher ConnCipher
// IsResolve resolve domain name on locally
IsResolve bool
// Resolver optionally specifies an alternate resolver to use
Resolver *net.Resolver
// BytesPool getting and returning temporary bytes
BytesPool BytesPool
}
func NewPacketClient ¶ added in v0.2.0
func NewPacketClient(addr string) (*PacketClient, error)
func (*PacketClient) ListenPacket ¶ added in v0.2.0
func (l *PacketClient) ListenPacket(ctx context.Context, network, address string) (net.PacketConn, error)
type PacketServer ¶ added in v0.2.0
type PacketServer struct {
// ProxyNetwork network between a proxy server and a client
ProxyNetwork string
// ProxyAddress proxy server address
ProxyAddress string
// Context is default context
Context context.Context
// ProxyPacket specifies the optional dial function for
// establishing the transport connection.
ProxyPacket func(ctx context.Context, network, address string) (net.PacketConn, error)
// Cipher use cipher protocol
Cipher string
// Password use password authentication
Password string
// ConnCipher is connect the cipher codec
ConnCipher ConnCipher
// IsResolve resolve domain name on locally
IsResolve bool
// Resolver optionally specifies an alternate resolver to use
Resolver *net.Resolver
// Timeout is the maximum amount of time a dial will wait for
// a connect to complete. The default is no timeout
Timeout time.Duration
// Logger error log
Logger Logger
// BytesPool getting and returning temporary bytes
BytesPool BytesPool
// contains filtered or unexported fields
}
func NewPacketServer ¶ added in v0.2.0
func NewPacketServer() *PacketServer
func (*PacketServer) ListenAndServe ¶ added in v0.2.0
func (p *PacketServer) ListenAndServe(network, addr string) error
ListenAndServe is used to create a listener and serve on it
func (*PacketServer) ServePacket ¶ added in v0.2.0
func (p *PacketServer) ServePacket(conn net.PacketConn) error
type Server ¶
type Server struct {
// ProxyDial specifies the optional proxyDial function for
// establishing the transport connection.
ProxyDial func(context.Context, string, string) (net.Conn, error)
// Logger error log
Logger Logger
// Context is default context
Context context.Context
// Cipher use cipher protocol
Cipher string
// Password use password authentication
Password string
// ConnCipher is connect the cipher codec
ConnCipher ConnCipher
// BytesPool getting and returning temporary bytes for use by io.CopyBuffer
BytesPool BytesPool
}
Server is accepting connections and handling the details of the shadowsocks protocol
func (*Server) ListenAndServe ¶
ListenAndServe is used to create a listener and serve on it
type SimplePacketServer ¶ added in v0.2.0
type SimplePacketServer struct {
PacketServer
PacketConn net.PacketConn
Network string
Address string
}
SimplePacketServer is a simplified server, which can be configured as easily as client.
func NewSimplePacketServer ¶ added in v0.2.0
func NewSimplePacketServer(addr string) (*SimplePacketServer, error)
NewSimplePacketServer creates a new NewSimplePacketServer
func (*SimplePacketServer) Close ¶ added in v0.2.0
func (s *SimplePacketServer) Close() error
Close closes the listener
func (*SimplePacketServer) ProxyURL ¶ added in v0.2.0
func (s *SimplePacketServer) ProxyURL() string
ProxyURL returns the URL of the proxy
type SimpleServer ¶ added in v0.1.1
SimpleServer is a simplified server, which can be configured as easily as client.
func NewSimpleServer ¶ added in v0.1.1
func NewSimpleServer(addr string) (*SimpleServer, error)
NewServer creates a new NewSimpleServer
func (*SimpleServer) Close ¶ added in v0.1.1
func (s *SimpleServer) Close() error
Close closes the listener
func (*SimpleServer) ProxyURL ¶ added in v0.1.1
func (s *SimpleServer) ProxyURL() string
ProxyURL returns the URL of the proxy