Documentation
¶
Index ¶
Constants ¶
const MaxCapacity = 20_000
MaxCapacity is the largest allowed size of ReplayCache.
Capacities in excess of 20,000 are not recommended, due to the false positive rate of up to 2 * capacity / 2^32 = 1 / 100,000. If larger capacities are desired, the key type should be changed to uint64.
Variables ¶
This section is empty.
Functions ¶
func MakeTestPayload ¶ added in v1.0.3
MakeTestPayload returns a slice of `size` arbitrary bytes.
func MakeTestSecrets ¶ added in v1.1.1
MakeTestSecrets returns a slice of `n` test passwords. Not secure!
Types ¶
type ChunkReader ¶ added in v1.1.5
type ChunkReader interface {
// ReadChunk reads the next chunk and returns its payload. The caller must
// complete its use of the returned buffer before the next call.
// The buffer is nil iff there is an error. io.EOF indicates a close.
ReadChunk() ([]byte, error)
}
ChunkReader is similar to io.Reader, except that it controls its own buffer granularity.
type CipherEntry ¶ added in v1.0.3
type CipherEntry struct {
ID string
Cipher shadowaead.Cipher
// contains filtered or unexported fields
}
CipherEntry holds a Cipher with an identifier. The public fields are constant, but lastAddress is mutable under cipherList.mu.
type CipherList ¶ added in v1.0.3
type CipherList interface {
SnapshotForClientIP(clientIP net.IP) []*list.Element
MarkUsedByClientIP(e *list.Element, clientIP net.IP)
// Update replaces the current contents of the CipherList with `contents`,
// which is a List of *CipherEntry. Update takes ownership of `contents`,
// which must not be read or written after this call.
Update(contents *list.List)
}
CipherList is a thread-safe collection of CipherEntry elements that allows for snapshotting and moving to front.
func MakeTestCiphers ¶ added in v1.0.3
func MakeTestCiphers(secrets []string) (CipherList, error)
MakeTestCiphers creates a CipherList containing one fresh AEAD cipher for each secret in `secrets`.
func NewCipherList ¶ added in v1.0.3
func NewCipherList() CipherList
NewCipherList creates an empty CipherList
type Client ¶ added in v1.0.6
type Client interface {
// DialTCP connects to `raddr` over TCP though a Shadowsocks proxy.
// `laddr` is a local bind address, a local address is automatically chosen if nil.
// `raddr` has the form `host:port`, where `host` can be a domain name or IP address.
DialTCP(laddr *net.TCPAddr, raddr string) (onet.DuplexConn, error)
// ListenUDP relays UDP packets though a Shadowsocks proxy.
// `laddr` is a local bind address, a local address is automatically chosen if nil.
ListenUDP(laddr *net.UDPAddr) (net.PacketConn, error)
}
Client is a client for Shadowsocks TCP and UDP connections.
type Reader ¶ added in v1.1.0
Reader is an io.Reader that also implements io.WriterTo to allow for piping the data without extra allocations and copies.
func NewShadowsocksReader ¶
func NewShadowsocksReader(reader io.Reader, ssCipher shadowaead.Cipher) Reader
NewShadowsocksReader creates a Reader that decrypts the given Reader using the shadowsocks protocol with the given shadowsocks cipher.
type ReplayCache ¶ added in v1.0.8
type ReplayCache struct {
// contains filtered or unexported fields
}
ReplayCache allows us to check whether a handshake salt was used within the last `capacity` handshakes. It requires approximately 20*capacity bytes of memory (as measured by BenchmarkReplayCache_Creation).
The nil and zero values represent a cache with capacity 0, i.e. no cache.
func NewReplayCache ¶ added in v1.0.8
func NewReplayCache(capacity int) ReplayCache
NewReplayCache returns a fresh ReplayCache that promises to remember at least the most recent `capacity` handshakes.
type TCPService ¶
type TCPService interface {
Start()
Stop() error
}
TCPService is a Shadowsocks TCP service that can be started and stopped.
func NewTCPService ¶
func NewTCPService(listener *net.TCPListener, ciphers CipherList, replayCache *ReplayCache, m metrics.ShadowsocksMetrics, timeout time.Duration) TCPService
NewTCPService creates a TCPService
type UDPService ¶
type UDPService interface {
Start()
Stop() error
}
UDPService is a UDP shadowsocks service that can be started and stopped.
func NewUDPService ¶
func NewUDPService(clientConn net.PacketConn, natTimeout time.Duration, cipherList CipherList, m metrics.ShadowsocksMetrics) UDPService
NewUDPService creates a UDPService
type Writer ¶ added in v1.1.0
type Writer interface {
io.Writer
io.ReaderFrom
}
Writer is an io.Writer that also implements io.ReaderFrom to allow for piping the data without extra allocations and copies.
func NewShadowsocksWriter ¶
func NewShadowsocksWriter(writer io.Writer, ssCipher shadowaead.Cipher) Writer
NewShadowsocksWriter creates a Writer that encrypts the given Writer using the shadowsocks protocol with the given shadowsocks cipher.