Documentation ¶
Index ¶
- Variables
- type Metric
- type MetricProvider
- type NoMetrics
- type ServiceMetrics
- type TcpProxy
- func (tp *TcpProxy) Close() error
- func (tp *TcpProxy) LocalAddr() net.Addr
- func (tp *TcpProxy) Proxy() error
- func (tp *TcpProxy) ProxyConnClose(client net.Conn) error
- func (tp *TcpProxy) RemoteAddr() net.Addr
- func (tp *TcpProxy) SetDeadline(t time.Time) error
- func (tp *TcpProxy) SetDest(dest string) error
- func (tp *TcpProxy) SetDestAddr(addr *net.TCPAddr)
- func (tp *TcpProxy) SetReadDeadline(t time.Time) error
- func (tp *TcpProxy) SetWriteDeadline(t time.Time) error
Constants ¶
This section is empty.
Variables ¶
var ( // Will be set by one of the metrics options to wrap a handler and transport MetricsHandlerWrapper func(http.Handler) http.Handler MetricsClientTransportWrapper func(tripper http.RoundTripper) http.RoundTripper )
var Debug = true
Functions ¶
This section is empty.
Types ¶
type Metric ¶
type Metric interface {
Add(float64)
}
Metric is an interface for applications updating metrics Expvar is an interface between metric and the collection system.
type MetricProvider ¶
type MetricProvider interface { // Can only go up. Current value tracked. NewCounter(name, descr string, opts ...string) Metric // Like counter, but can go down. Mean, min, max ( and sum, count) are tracked. NewGauge(name, descr string, opts ...string) Metric // Tracks 50, 90, 99% value of all Add events. NewHistogram(name, descr string, opts ...string) Metric }
Abstract creation of metrics - zserge(minimal with UI) for local, prom or OC for servers. The opts are currently used for in-process time-series. If specified and an in-process implementation exists it'll be used. The parameter is 'total' and 'interval' - total/interval is the number of samples. External timeseries have their own polling interval and aggregation. If metrics are pushed, the first interval is used to control the rate.
var ( // Singleton factory Metrics MetricProvider = &NoMetrics{} )
type NoMetrics ¶
type NoMetrics struct { }
func (*NoMetrics) NewCounter ¶
type ServiceMetrics ¶
type ServiceMetrics struct { // Active requests, gauge. Active Metric // Total requests, counter Total Metric Errors Metric // Service latency (total). Latency Metric }
Set of metrics used by client or server of a service.
func NewServiceMetrics ¶
func NewServiceMetrics(base string, descr string) *ServiceMetrics
type TcpProxy ¶
type TcpProxy struct { ugate.Stream OnProxyClose func(proxy *TcpProxy) // Client stream reader, data from captured/local app to remote. // Set when the proxy is created, based on the captured stream. // // - For socks or accept capture, a TCPConnection // - For accept, a net.Conn // - for TCP-over-HTTP server - req.Body // - ... ClientIn io.ReadCloser // A chunk of initial data, to be sent before localIn. // Currently not used - SNI proxy and other cases where data is sent along var-len header might use it. Initial []byte // Client stream writer. // // - for socks - a TCPConnection // - for accept, a net.Conn // - for TCP-over-HTTP - a http.Writer. // // When the remoteIn is closed, the appropriate CloseWrite must be called, to send the FIN to the other side. // Note that reading from clientIn might continue. ClientOut io.Writer // remoteCtx is a context associated with the remote side connection, for example in http cases. RemoteCtx context.CancelFunc // Address of the connected endpoint, previous hop. // OriginIP/OriginPort track the real client, and PrevPath // the path. ClientAddr net.Addr // Original client from the interception -host:port, result of net.JoinHostPort // // In the origin server it's typically 127.0.0.1:XXXX. // When forwarded, it should be translated to VIP : OriginStreamID Origin string // True if the destination is local, no VPN needed // Used for VPN-accepted connections forwarded to directly // reachable hosts, disables dialing through other VPNs. DestDirectNoVPN bool DestIP net.IP // DestPort is set DestPort int }
=== L4/TCP common code ===
- Handles SOCKS, HTTP CONNECT, TUN captured - opens a connection to the remote site, proxies packets - keeps stats - buffer reuse. - handles accepted connections sent back over SSHClientConn or direct
Implements ReadCloser over the localIn stream - so it can be passed to http.Post() or used for reading.
func (*TcpProxy) Proxy ¶
Proxy will start forwarding the connection to the remote. This is a blocking call - will return when done.
func (*TcpProxy) ProxyConnClose ¶
This is the main function used with the DialProxy interface