etcd: Index | Files

package proxy

import ""

Package proxy implements proxy servers for network fault testing.


Package Files

doc.go server.go

type Server Uses

type Server interface {
    // From returns proxy source address in "scheme://host:port" format.
    From() string
    // To returns proxy destination address in "scheme://host:port" format.
    To() string

    // Ready returns when proxy is ready to serve.
    Ready() <-chan struct{}
    // Done returns when proxy has been closed.
    Done() <-chan struct{}
    // Error sends errors while serving proxy.
    Error() <-chan error
    // Close closes listener and transport.
    Close() error

    // PauseAccept stops accepting new connections.
    // UnpauseAccept removes pause operation on accepting new connections.

    // DelayAccept adds latency ± random variable to accepting
    // new incoming connections.
    DelayAccept(latency, rv time.Duration)
    // UndelayAccept removes sending latencies.
    // LatencyAccept returns current latency on accepting
    // new incoming connections.
    LatencyAccept() time.Duration

    // DelayTx adds latency ± random variable for "outgoing" traffic
    // in "sending" layer.
    DelayTx(latency, rv time.Duration)
    // UndelayTx removes sending latencies.
    // LatencyTx returns current send latency.
    LatencyTx() time.Duration

    // DelayRx adds latency ± random variable for "incoming" traffic
    // in "receiving" layer.
    DelayRx(latency, rv time.Duration)
    // UndelayRx removes "receiving" latencies.
    // LatencyRx returns current receive latency.
    LatencyRx() time.Duration

    // ModifyTx alters/corrupts/drops "outgoing" packets from the listener
    // with the given edit function.
    ModifyTx(f func(data []byte) []byte)
    // UnmodifyTx removes modify operation on "forwarding".

    // ModifyRx alters/corrupts/drops "incoming" packets to client
    // with the given edit function.
    ModifyRx(f func(data []byte) []byte)
    // UnmodifyRx removes modify operation on "receiving".

    // BlackholeTx drops all "outgoing" packets before "forwarding".
    // "BlackholeTx" operation is a wrapper around "ModifyTx" with
    // a function that returns empty bytes.
    // UnblackholeTx removes blackhole operation on "sending".

    // BlackholeRx drops all "incoming" packets to client.
    // "BlackholeRx" operation is a wrapper around "ModifyRx" with
    // a function that returns empty bytes.
    // UnblackholeRx removes blackhole operation on "receiving".

    // PauseTx stops "forwarding" packets; "outgoing" traffic blocks.
    // UnpauseTx removes "forwarding" pause operation.

    // PauseRx stops "receiving" packets; "incoming" traffic blocks.
    // UnpauseRx removes "receiving" pause operation.

    // ResetListener closes and restarts listener.
    ResetListener() error

Server defines proxy server layer that simulates common network faults: latency spikes and packet drop or corruption. The proxy overhead is very small overhead (<500μs per request). Please run tests to compute actual overhead.

func NewServer Uses

func NewServer(cfg ServerConfig) Server

NewServer returns a proxy implementation with no iptables/tc dependencies. The proxy layer overhead is <1ms.

type ServerConfig Uses

type ServerConfig struct {
    Logger        *zap.Logger
    From          url.URL
    To            url.URL
    TLSInfo       transport.TLSInfo
    DialTimeout   time.Duration
    BufferSize    int
    RetryInterval time.Duration

ServerConfig defines proxy server configuration.

Package proxy imports 13 packages (graph) and is imported by 1 packages. Updated 2020-06-01. Refresh now. Tools for package owners.