edge

package
v0.13.61 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2020 License: Apache-2.0 Imports: 19 Imported by: 38

Documentation

Index

Constants

View Source
const (
	ContentTypeConnect           = 60783
	ContentTypeStateConnected    = 60784
	ContentTypeStateClosed       = 60785
	ContentTypeData              = 60786
	ContentTypeDial              = 60787
	ContentTypeDialSuccess       = 60788
	ContentTypeDialFailed        = 60789
	ContentTypeBind              = 60790
	ContentTypeUnbind            = 60791
	ContentTypeStateSessionEnded = 60792
	ContentTypeProbe             = 60793
	ContentTypeUpdateBind        = 60794

	ConnIdHeader                   = 1000
	SeqHeader                      = 1001
	SessionTokenHeader             = 1002
	PublicKeyHeader                = 1003
	CostHeader                     = 1004
	PrecedenceHeader               = 1005
	TerminatorIdentityHeader       = 1006
	TerminatorIdentitySecretHeader = 1007
	CallerIdHeader                 = 1008
	CryptoMethodHeader             = 1009

	PrecedenceDefault  Precedence = 0
	PrecedenceRequired            = 1
	PrecedenceFailed              = 2

	// Put this in the reflected range so replies will share the same UUID
	UUIDHeader = 128

	// Crypto Methods
	CryptoMethodLibsodium CryptoMethod = 0 // default: crypto_kx_*, crypto_secretstream_*
	CryptoMethodSSL                    = 1 // OpenSSL(possibly with FIPS): ECDH, AES256-GCM
)

Variables

View Source
var ContentTypeNames = map[int32]string{
	ContentTypeConnect:        "EdgeConnectType",
	ContentTypeStateConnected: "EdgeStateConnectedType",
	ContentTypeStateClosed:    "EdgeStateClosedType",
	ContentTypeData:           "EdgeDataType",
	ContentTypeDial:           "EdgeDialType",
	ContentTypeDialSuccess:    "EdgeDialSuccessType",
	ContentTypeDialFailed:     "EdgeDialFailedType",
	ContentTypeBind:           "EdgeBindType",
	ContentTypeUnbind:         "EdgeUnbindType",
	ContentTypeProbe:          "EdgeProbeType",
}
View Source
var ContentTypeValue = map[string]int32{
	"EdgeConnectType":        ContentTypeConnect,
	"EdgeStateConnectedType": ContentTypeStateConnected,
	"EdgeStateClosedType":    ContentTypeStateClosed,
	"EdgeDataType":           ContentTypeData,
	"EdgeDialType":           ContentTypeDial,
	"EdgeDialSuccessType":    ContentTypeDialSuccess,
	"EdgeDialFailedType":     ContentTypeDialFailed,
	"EdgeBindType":           ContentTypeBind,
	"EdgeUnbindType":         ContentTypeUnbind,
}

Functions

func GetLoggerFields

func GetLoggerFields(msg *channel2.Message) logrus.Fields

func NewBindMsg

func NewBindMsg(connId uint32, token string, pubKey []byte, options *ListenOptions) *channel2.Message

func NewConnectMsg

func NewConnectMsg(connId uint32, token string, pubKey []byte, options *DialOptions) *channel2.Message

func NewDataMsg

func NewDataMsg(connId uint32, seq uint32, data []byte) *channel2.Message

func NewDialFailedMsg

func NewDialFailedMsg(connId uint32, message string) *channel2.Message

func NewDialMsg

func NewDialMsg(connId uint32, token string, callerId string) *channel2.Message

func NewDialSuccessMsg

func NewDialSuccessMsg(connId uint32, newConnId uint32) *channel2.Message

func NewProbeMsg

func NewProbeMsg() *channel2.Message

func NewStateClosedMsg

func NewStateClosedMsg(connId uint32, message string) *channel2.Message

func NewStateConnectedMsg

func NewStateConnectedMsg(connId uint32) *channel2.Message

func NewStateSessionEndedMsg

func NewStateSessionEndedMsg(reason string) *channel2.Message

func NewUnbindMsg

func NewUnbindMsg(connId uint32, token string) *channel2.Message

func NewUpdateBindMsg

func NewUpdateBindMsg(connId uint32, token string, cost *uint16, precedence *Precedence) *channel2.Message

Types

type Addr

type Addr struct {
	MsgCh MsgChannel
}

func (*Addr) Network

func (e *Addr) Network() string

func (*Addr) String

func (e *Addr) String() string

type ApiIdentity

type ApiIdentity struct {
	Id   string `json:"id"`
	Name string `json:"name"`
}

type ApiResponseMetadata

type ApiResponseMetadata struct {
	FilterableFields []string `json:"filterableFields"`
	Pagination       *struct {
		Offset     int `json:"offset"`
		Limit      int `json:"limit"`
		TotalCount int `json:"totalCount"`
	} `json:"pagination"`
}

func ApiResponseDecode

func ApiResponseDecode(data interface{}, resp io.Reader) (*ApiResponseMetadata, error)

type ApiSession

type ApiSession struct {
	Id       string       `json:"id"`
	Token    string       `json:"token"`
	Identity *ApiIdentity `json:"identity"`
	Expires  time.Time    `json:"expiresAt"`
}

type AsyncFunctionReceiveAdapter

type AsyncFunctionReceiveAdapter struct {
	Type    int32
	Handler func(*channel2.Message, channel2.Channel)
}

func (*AsyncFunctionReceiveAdapter) ContentType

func (adapter *AsyncFunctionReceiveAdapter) ContentType() int32

func (*AsyncFunctionReceiveAdapter) HandleReceive

func (adapter *AsyncFunctionReceiveAdapter) HandleReceive(m *channel2.Message, ch channel2.Channel)

type Conn

type Conn interface {
	net.Conn
	Identifiable
	NewConn(service *Service) Conn
	Connect(session *Session, options *DialOptions) (ServiceConn, error)
	Listen(session *Session, service *Service, options *ListenOptions) (Listener, error)
	IsClosed() bool
}

type ConnOptions

type ConnOptions interface {
	GetConnectTimeout() time.Duration
}

type CryptoMethod added in v0.13.55

type CryptoMethod byte

type DialOptions added in v0.13.47

type DialOptions struct {
	ConnectTimeout time.Duration
	Identity       string
	CallerId       string
}

func (DialOptions) GetConnectTimeout added in v0.13.47

func (d DialOptions) GetConnectTimeout() time.Duration

type DialResult

type DialResult struct {
	ConnId    uint32
	NewConnId uint32
	Success   bool
	Message   string
}

func UnmarshalDialResult

func UnmarshalDialResult(msg *channel2.Message) (*DialResult, error)

type EdgeRouter

type EdgeRouter struct {
	Name     string `json:"name"`
	Hostname string `json:"hostname"`
	Urls     map[string]string
}

type FunctionReceiveAdapter

type FunctionReceiveAdapter struct {
	Type    int32
	Handler func(*channel2.Message, channel2.Channel)
}

func (*FunctionReceiveAdapter) ContentType

func (adapter *FunctionReceiveAdapter) ContentType() int32

func (*FunctionReceiveAdapter) HandleReceive

func (adapter *FunctionReceiveAdapter) HandleReceive(m *channel2.Message, ch channel2.Channel)

type Identifiable

type Identifiable interface {
	Id() uint32
}

type ListenOptions

type ListenOptions struct {
	Cost                  uint16
	Precedence            Precedence
	ConnectTimeout        time.Duration
	MaxConnections        int
	Identity              string
	IdentitySecret        string
	BindUsingEdgeIdentity bool
}

func (*ListenOptions) GetConnectTimeout

func (options *ListenOptions) GetConnectTimeout() time.Duration

func (*ListenOptions) String

func (options *ListenOptions) String() string

type Listener

type Listener interface {
	net.Listener
	IsClosed() bool
	UpdateCost(cost uint16) error
	UpdatePrecedence(precedence Precedence) error
	UpdateCostAndPrecedence(cost uint16, precedence Precedence) error
}

type MsgChannel

type MsgChannel struct {
	channel2.Channel
	// contains filtered or unexported fields
}

func NewEdgeMsgChannel

func NewEdgeMsgChannel(ch channel2.Channel, connId uint32) *MsgChannel

func (*MsgChannel) Id

func (ec *MsgChannel) Id() uint32

func (*MsgChannel) SendState

func (ec *MsgChannel) SendState(msg *channel2.Message) error

func (*MsgChannel) SetWriteDeadline

func (ec *MsgChannel) SetWriteDeadline(t time.Time) error

func (*MsgChannel) TraceMsg

func (ec *MsgChannel) TraceMsg(source string, msg *channel2.Message)

func (*MsgChannel) Write

func (ec *MsgChannel) Write(data []byte) (n int, err error)

func (*MsgChannel) WriteTraced

func (ec *MsgChannel) WriteTraced(data []byte, msgUUID []byte) (int, error)

type MsgEvent

type MsgEvent struct {
	ConnId  uint32
	Seq     uint32
	MsgUUID []byte
	Msg     *channel2.Message
}

func UnmarshalMsgEvent

func UnmarshalMsgEvent(msg *channel2.Message) (*MsgEvent, error)

func (*MsgEvent) GetLoggerFields

func (event *MsgEvent) GetLoggerFields() logrus.Fields

func (*MsgEvent) GetSequence

func (event *MsgEvent) GetSequence() uint32

func (*MsgEvent) Handle

func (event *MsgEvent) Handle(mux *MsgMux)

type MsgMux

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

func NewMsgMux

func NewMsgMux() *MsgMux

func (*MsgMux) AddMsgSink

func (mux *MsgMux) AddMsgSink(sink MsgSink) error

func (*MsgMux) Close

func (mux *MsgMux) Close()

func (*MsgMux) ContentType

func (mux *MsgMux) ContentType() int32

func (*MsgMux) Event

func (mux *MsgMux) Event(event MuxEvent)

func (*MsgMux) ExecuteClose

func (mux *MsgMux) ExecuteClose()

func (*MsgMux) HandleClose

func (mux *MsgMux) HandleClose(_ channel2.Channel)

func (*MsgMux) HandleReceive

func (mux *MsgMux) HandleReceive(msg *channel2.Message, _ channel2.Channel)

func (*MsgMux) IsClosed

func (mux *MsgMux) IsClosed() bool

func (*MsgMux) RemoveMsgSink

func (mux *MsgMux) RemoveMsgSink(sink MsgSink)

func (*MsgMux) RemoveMsgSinkById

func (mux *MsgMux) RemoveMsgSinkById(sinkId uint32)

type MsgSink

type MsgSink interface {
	HandleMuxClose() error
	Id() uint32
	Accept(event *MsgEvent)
}

type MuxEvent

type MuxEvent interface {
	Handle(mux *MsgMux)
}

type Precedence

type Precedence byte

type RouterConn

type RouterConn interface {
	io.Closer
	IsClosed() bool
	Key() string
	NewConn(service *Service) Conn
	GetRouterName() string
}

type Sequenced

type Sequenced interface {
	GetSequence() uint32
}

type Service

type Service struct {
	Id          string                            `json:"id"`
	Name        string                            `json:"name"`
	Permissions []string                          `json:"permissions"`
	Encryption  bool                              `json:"encryptionRequired"`
	Configs     map[string]map[string]interface{} `json:"config"`
	Tags        map[string]string                 `json:"tags"`
}

func (*Service) GetConfigOfType

func (service *Service) GetConfigOfType(configType string, target interface{}) (bool, error)

type ServiceConn added in v0.12.0

type ServiceConn interface {
	net.Conn
	IsClosed() bool
}

type Session

type Session struct {
	Id          string       `json:"id"`
	Service     ApiIdentity  `json:"service"`
	Token       string       `json:"token"`
	Type        SessionType  `json:"type"`
	EdgeRouters []EdgeRouter `json:"edgeRouters"`
}

type SessionListener added in v0.13.2

type SessionListener interface {
	Listener
	GetCurrentSession() *Session
	SetConnectionChangeHandler(func(conn []Listener))
	SetErrorEventHandler(func(error))
	GetErrorEventHandler() func(error)
}

type SessionType added in v0.13.0

type SessionType string
const (
	SessionDial SessionType = "Dial"
	SessionBind SessionType = "Bind"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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