server

package
v0.0.0-...-a8e7fa4 Latest Latest
Warning

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

Go to latest
Published: May 31, 2016 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotAuthorized = `HTTP/1.0 401 Not Authorized
WWW-Authenticate: Basic realm="ngrok"
Content-Length: 23

Authorization required
`

	NotFound = `HTTP/1.0 404 Not Found
Content-Length: %d

Tunnel %s not found
`

	BadRequest = `HTTP/1.0 400 Bad Request
Content-Length: 12

Bad Request
`
)

Variables

This section is empty.

Functions

func LoadTLSConfig

func LoadTLSConfig(crtPath string, keyPath string) (tlsConfig *tls.Config, err error)

func Main

func Main()

func NewControl

func NewControl(ctlConn conn.Conn, authMsg *msg.Auth)

func NewProxy

func NewProxy(pxyConn conn.Conn, regPxy *msg.RegProxy)

Types

type Control

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

func (*Control) GetProxy

func (c *Control) GetProxy() (proxyConn conn.Conn, err error)

Remove a proxy connection from the pool and return it If not proxy connections are in the pool, request one and wait until it is available Returns an error if we couldn't get a proxy because it took too long or the tunnel is closing

func (*Control) RegisterProxy

func (c *Control) RegisterProxy(conn conn.Conn)

func (*Control) Replaced

func (c *Control) Replaced(replacement *Control)

Called when this control is replaced by another control this can happen if the network drops out and the client reconnects before the old tunnel has lost its heartbeat

type ControlRegistry

type ControlRegistry struct {
	log.Logger
	sync.RWMutex
	// contains filtered or unexported fields
}

ControlRegistry maps a client ID to Control structures

func NewControlRegistry

func NewControlRegistry() *ControlRegistry

func (*ControlRegistry) Add

func (r *ControlRegistry) Add(clientId string, ctl *Control) (oldCtl *Control)

func (*ControlRegistry) Del

func (r *ControlRegistry) Del(clientId string) error

func (*ControlRegistry) Get

func (r *ControlRegistry) Get(clientId string) *Control

type KeenIoMetric

type KeenIoMetric struct {
	Collection string
	Event      interface{}
}

type KeenIoMetrics

type KeenIoMetrics struct {
	log.Logger
	ApiKey       string
	ProjectToken string
	HttpClient   http.Client
	Metrics      chan *KeenIoMetric
}

func NewKeenIoMetrics

func NewKeenIoMetrics(batchInterval time.Duration) *KeenIoMetrics

func (*KeenIoMetrics) AuthedRequest

func (k *KeenIoMetrics) AuthedRequest(method, path string, body *bytes.Reader) (resp *http.Response, err error)

func (*KeenIoMetrics) CloseConnection

func (k *KeenIoMetrics) CloseConnection(t *Tunnel, c conn.Conn, start time.Time, in, out int64)

func (*KeenIoMetrics) CloseTunnel

func (k *KeenIoMetrics) CloseTunnel(t *Tunnel)

func (*KeenIoMetrics) OpenConnection

func (k *KeenIoMetrics) OpenConnection(t *Tunnel, c conn.Conn)

func (*KeenIoMetrics) OpenTunnel

func (k *KeenIoMetrics) OpenTunnel(t *Tunnel)

type KeenStruct

type KeenStruct struct {
	Timestamp string `json:"timestamp"`
}

type LocalMetrics

type LocalMetrics struct {
	log.Logger
	// contains filtered or unexported fields
}

func NewLocalMetrics

func NewLocalMetrics(reportInterval time.Duration) *LocalMetrics

func (*LocalMetrics) CloseConnection

func (m *LocalMetrics) CloseConnection(t *Tunnel, c conn.Conn, start time.Time, bytesIn, bytesOut int64)

func (*LocalMetrics) CloseTunnel

func (m *LocalMetrics) CloseTunnel(t *Tunnel)

func (*LocalMetrics) OpenConnection

func (m *LocalMetrics) OpenConnection(t *Tunnel, c conn.Conn)

func (*LocalMetrics) OpenTunnel

func (m *LocalMetrics) OpenTunnel(t *Tunnel)

func (*LocalMetrics) Report

func (m *LocalMetrics) Report()

type Metrics

type Metrics interface {
	log.Logger
	OpenConnection(*Tunnel, conn.Conn)
	CloseConnection(*Tunnel, conn.Conn, time.Time, int64, int64)
	OpenTunnel(*Tunnel)
	CloseTunnel(*Tunnel)
}

type Options

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

type Tunnel

type Tunnel struct {

	// logger
	log.Logger
	// contains filtered or unexported fields
}

*

  • Tunnel: A control connection, metadata and proxy connections which
  • route public traffic to a firewalled endpoint.

func NewTunnel

func NewTunnel(m *msg.ReqTunnel, ctl *Control) (t *Tunnel, err error)

Create a new tunnel from a registration message received on a control channel

func (*Tunnel) HandlePublicConnection

func (t *Tunnel) HandlePublicConnection(publicConn conn.Conn)

func (*Tunnel) Id

func (t *Tunnel) Id() string

func (*Tunnel) Shutdown

func (t *Tunnel) Shutdown()

type TunnelRegistry

type TunnelRegistry struct {
	log.Logger
	sync.RWMutex
	// contains filtered or unexported fields
}

TunnelRegistry maps a tunnel URL to Tunnel structures

func NewTunnelRegistry

func NewTunnelRegistry(cacheSize uint64, cacheFile string) *TunnelRegistry

func (*TunnelRegistry) Del

func (r *TunnelRegistry) Del(url string)

func (*TunnelRegistry) Get

func (r *TunnelRegistry) Get(url string) *Tunnel

func (*TunnelRegistry) GetCachedRegistration

func (r *TunnelRegistry) GetCachedRegistration(t *Tunnel) (url string)

func (*TunnelRegistry) Register

func (r *TunnelRegistry) Register(url string, t *Tunnel) error

Register a tunnel with a specific url, returns an error if a tunnel is already registered at that url

func (*TunnelRegistry) RegisterAndCache

func (r *TunnelRegistry) RegisterAndCache(url string, t *Tunnel) (err error)

func (*TunnelRegistry) RegisterRepeat

func (r *TunnelRegistry) RegisterRepeat(urlFn func() string, t *Tunnel) (string, error)

Register a tunnel with the following process: Consult the affinity cache to try to assign a previously used tunnel url if possible Generate new urls repeatedly with the urlFn and register until one is available.

func (*TunnelRegistry) SaveCacheThread

func (r *TunnelRegistry) SaveCacheThread(path string, interval time.Duration)

Spawns a goroutine the periodically saves the cache to a file.

Jump to

Keyboard shortcuts

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