dialchain

package
v6.2.2+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeDialerJobs

func MakeDialerJobs(
	b *Builder,
	typ, scheme string,
	endpoints []Endpoint,
	mode monitors.IPSettings,
	fn func(dialer transport.Dialer, addr string) (common.MapStr, error),
) ([]monitors.Job, error)

MakeDialerJobs creates a set of monitoring jobs. The jobs behavior depends on the builder, endpoint and mode configurations, normally set by user configuration. The task to execute the actual 'ping' receives the dialer and the address pair (<hostname>:<port>), required to be used, to ping the correctly resolved endpoint.

Types

type Builder

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

Builder maintains a DialerChain for building dialers and dialer based monitoring jobs. The builder ensures a constant address is being used, for any host configured. This ensures the upper network layers (e.g. TLS) correctly see and process the original hostname.

func NewBuilder

func NewBuilder(settings BuilderSettings) (*Builder, error)

NewBuilder creates a new Builder for constructing dialers.

func (*Builder) AddLayer

func (b *Builder) AddLayer(l Layer)

AddLayer adds another custom network layer to the dialer chain.

func (*Builder) Build

func (b *Builder) Build(addr string, event common.MapStr) (transport.Dialer, error)

Build create a new dialer, that will always use the constant address, no matter which address is used to connect using the dialer. The dialer chain will add per layer information to the given event.

func (*Builder) Run

func (b *Builder) Run(
	addr string,
	fn func(transport.Dialer) (common.MapStr, error),
) (common.MapStr, error)

Run executes the given function with a new dialer instance.

type BuilderSettings

type BuilderSettings struct {
	Timeout time.Duration
	Socks5  transport.ProxyConfig
	TLS     *transport.TLSConfig
}

BuilderSettings configures the layers of the dialer chain to be constructed by a Builder.

type DialerChain

type DialerChain struct {
	Net    NetDialer
	Layers []Layer
}

DialerChain composes builders for multiple network layers, used to build the final transport.Dialer object based on the network layers. Each layer can hold individual configurations. Use 'Clone' to copy and replace/wrap layers at will. Once all Layers have been prepared, use Build to build a transport.Dialer that can used with any go library network packages relying on standard library based dialers.

For Additional Layering capabilities, DialerChain implements the NetDialer interface.

func (*DialerChain) AddLayer

func (c *DialerChain) AddLayer(l Layer)

AddLayer adds another layer to the dialer chain. The layer being added is the new topmost network layer using the other already present layers on dial.

func (*DialerChain) Build

func (c *DialerChain) Build(event common.MapStr) (d transport.Dialer, err error)

Build create a new transport.Dialer for use with other networking libraries.

func (*DialerChain) Clone

func (c *DialerChain) Clone() *DialerChain

Clone create a shallow copy of c.

func (*DialerChain) TestBuild

func (c *DialerChain) TestBuild() error

TestBuild tries to build the DialerChain and reports any error reported by one of the layers.

type Endpoint

type Endpoint struct {
	Host  string
	Ports []uint16
}

Endpoint configures a host with all port numbers to be monitored by a dialer based job.

type Layer

Layer is a configured network layer, wrapping any lower-level network layers.

func ConstAddrLayer

func ConstAddrLayer(address string) Layer

ConstAddrLayer introduces a network layer always passing a constant address to the underlying layer.

func IDLayer

func IDLayer() Layer

IDLayer creates an empty placeholder layer.

func MakeConstAddrLayer

func MakeConstAddrLayer(addr string, origLayer Layer) Layer

MakeConstAddrLayer always passes the same address to the original Layer. This is useful if a lookup did return multiple IPs for the same hostname, but the IP use to connect shall be fixed.

func SOCKS5Layer

func SOCKS5Layer(config *transport.ProxyConfig) Layer

SOCKS5Layer configures a SOCKS5 proxy layer in a DialerChain.

The layer will update the active event with:

{
  "socks5": {
      "rtt": { "connect": { "us": ... }}
  }
}

func TLSLayer

func TLSLayer(cfg *transport.TLSConfig, to time.Duration) Layer

TLSLayer configures the TLS layer in a DialerChain.

The layer will update the active event with:

{
  "tls": {
      "rtt": { "handshake": { "us": ... }}
  }
}

type NetDialer

type NetDialer func(common.MapStr) (transport.Dialer, error)

NetDialer provides the most low-level network layer for setting up a network connection. NetDialer objects do not support wrapping any lower network layers.

func MakeConstAddrDialer

func MakeConstAddrDialer(addr string, origNet NetDialer) NetDialer

MakeConstAddrDialer always passes the same address to the original NetDialer. This is useful if a lookup did return multiple IPs for the same hostname, but the IP use to connect shall be fixed.

func TCPDialer

func TCPDialer(to time.Duration) NetDialer

TCPDialer creates a new NetDialer with constant event fields and default connection timeout. The fields parameter holds additional constants to be added to the final event structure.

The dialer will update the active events with:

{
  "tcp": {
    "port": ...,
    "rtt": { "connect": { "us": ... }}
  }
}

func UDPDialer

func UDPDialer(to time.Duration) NetDialer

UDPDialer creates a new NetDialer with constant event fields and default connection timeout. The fields parameter holds additional constants to be added to the final event structure.

The dialer will update the active events with:

{
  "udp": {
    "port": ...,
    "rtt": { "connect": { "us": ... }}
  }
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL