server

package
v0.0.0-...-c0ff69a Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2015 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotAuthorized = `HTTP/1.0 401 Not Authorized
WWW-Authenticate: Basic realm="anytunnel"
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 Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func InitRestInferface

func InitRestInferface(c *ControlRegistry)

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 BinaryHandler

type BinaryHandler struct {
}

func (*BinaryHandler) ServeHTTP

func (b *BinaryHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

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) All

func (r *ControlRegistry) All() []*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 Node

type Node struct {
	Id       string
	LastPing time.Time
	Services []NodeService
}

+gen *

type NodeResource

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

func (NodeResource) Register

func (u NodeResource) Register(container *restful.Container)

type NodeService

type NodeService struct {
	Url string
	Req msg.ReqTunnel
}

type Nodes

type Nodes []*Node

Nodes is a slice of type *Node. Use it where you would use []*Node.

func (Nodes) Where

func (rcv Nodes) Where(fn func(*Node) bool) (result Nodes)

Where returns a new Nodes slice whose elements return true for func. See: http://clipperhouse.github.io/gen/#Where

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