internal

package
v0.0.0-...-add61a3 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2019 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version    string
	CompiledAt string
	GoVersion  string
)

Automatically injected during compilation. Use make compile target.

Functions

func CreateLogger

func CreateLogger(level string, devMode bool) *zap.Logger

func EnsureDefault

func EnsureDefault(a, b string) string

func IsRouteForEnv

func IsRouteForEnv(env string, addr ilp.Address) error

func LoadFileConfig

func LoadFileConfig(filename string, cfg *Config) ([]string, error)

LoadFileConfig creates a new connector based on the configuration defined in the provided file

func NewAPI

func NewAPI(s *Service, rt *Router) *httprouter.Router

func Start

func Start(cfg *Config) (func() error, error)

Types

type Callback

type Callback interface {
	// contains filtered or unexported methods
}

type CallbackChan

type CallbackChan chan *CallbackResult

type CallbackFn

type CallbackFn func(error, ilp.Message)

type CallbackResult

type CallbackResult struct {
	Err error
	Msg ilp.Message
}

type Config

type Config struct {
	Env      string `yaml:"env"`
	LogLevel string `yaml:"log_level"`
	DevMode  bool   `yaml:"dev_mode"`
	Admin    struct {
		Enable bool   `yaml:"enable"`
		Host   string `yaml:"string"`
		Port   int    `yaml:"port"`
	} `yaml:"admin"`
	IlpAddress         ilp.Address `yaml:"ilpAddress"`
	StreamSharedSecret string      `yaml:"sharedSecret"`
	BTP                struct {
		Host string `yaml:"host"`
		Port int    `yaml:"port"`
	} `yaml:"btp"`
	Storage storage.Config `yaml:"storage"`
	Peers   []Peer         `yaml:"peers"`
}

type Opts

type Opts struct {
	Log     *zap.Logger
	Config  *Config
	Route   *Router
	Storage storage.Storer

	Transports []Transport
}

type Peer

type Peer struct {
	Transport string `yaml:"transport"`
	Host      string `yaml:"host"`
	Port      int    `yaml:"port"`
	Auth      struct {
		User  string `yaml:"user"`
		Token string `yaml:"token"`
	} `yaml:"auth"`
}

type PingRequest

type PingRequest struct {
	Address ilp.Address `json:"address"`
}

type PingResponse

type PingResponse struct {
	Error    string        `json:"error,omitempty"`
	Address  ilp.Address   `json:"address"`
	Duration time.Duration `json:"duration"`
}

type Router

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

func NewRouter

func NewRouter(log *zap.Logger, env string, sender Sender, addr ilp.Address) *Router

func (*Router) AddPeer

func (r *Router) AddPeer(connId string) error

func (*Router) FlushTable

func (r *Router) FlushTable()

func (*Router) HandleRequest

func (r *Router) HandleRequest(connId string, msg *ilp.MessagePrepare) ilp.Message

func (*Router) Info

func (r *Router) Info() map[string]interface{}

func (*Router) NextHop

func (r *Router) NextHop(destination ilp.Address) (string, error)

func (*Router) RemovePeer

func (r *Router) RemovePeer(connId string) error

func (*Router) Run

func (r *Router) Run() error

type Sender

type Sender interface {
	SendMessage(context.Context, string, *ilp.MessagePrepare, [32]byte, Callback) error
}

type Service

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

func New

func New(opts *Opts) (*Service, error)

func (*Service) ConnectToPeer

func (s *Service) ConnectToPeer(address string, data *btp.AuthData, transport string) error

ConnectToPeer tries to open a connection to the target and initialize a channel. If the transport does not exist or there was an irrecoverable network issue, it returns an error. If the transport connection is successful, the peer goes through the normal authentication flow.

func (*Service) DisconnectFromPeer

func (s *Service) DisconnectFromPeer(connId string) error

func (*Service) GenerateTxInit

func (s *Service) GenerateTxInit(tag string) (ilp.Address, string, error)

func (*Service) Info

func (s *Service) Info() map[string]interface{}

func (*Service) SendBiDirectionalPing

func (s *Service) SendBiDirectionalPing(ctx context.Context, address ilp.Address) error

func (*Service) SendMessage

func (s *Service) SendMessage(ctx context.Context, id string, msg *ilp.MessagePrepare, ff [32]byte, fn Callback) error

func (*Service) Start

func (s *Service) Start() error

func (*Service) Stop

func (s *Service) Stop() error

type Transport

type Transport interface {
	// Start starts up the transport and begins accepting connections.
	Start() (<-chan *TransportConnection, error)
	// Open opens a new connection with the remote
	Open(address string) (*TransportConnection, error)
	// Close closes the connection
	Close(id string) error
	// Send sends data over a connection
	Send(id string, data []byte) error
	// Stop starts tearing down the transports. It stops accepting new peer
	// and waits for the completion of pending ones.
	Stop(ctx context.Context) error
	// Name uniquely identifies the transport. Used mainly for logging purposes.
	Name() string
}

type TransportConnection

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

type WebsocketTransport

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

func NewWebSocketTransport

func NewWebSocketTransport(log *zap.Logger, address string) *WebsocketTransport

func (*WebsocketTransport) Close

func (b *WebsocketTransport) Close(id string) error

func (*WebsocketTransport) Name

func (b *WebsocketTransport) Name() string

func (*WebsocketTransport) Open

func (b *WebsocketTransport) Open(address string) (*TransportConnection, error)

func (*WebsocketTransport) Send

func (b *WebsocketTransport) Send(id string, data []byte) error

func (*WebsocketTransport) Start

func (b *WebsocketTransport) Start() (<-chan *TransportConnection, error)

func (*WebsocketTransport) Stop

func (b *WebsocketTransport) Stop(ctx context.Context) error

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
* Copyright (c) 2019 Uroš Hercog <uros@orcus.network> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright (c) 2019 Uroš Hercog <uros@orcus.network> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.

Jump to

Keyboard shortcuts

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