overlay

package
v0.0.0-...-da90e6b Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnwrapMessage

func UnwrapMessage(data tl.Serializable) (tl.Serializable, []byte)

func UnwrapQuery

func UnwrapQuery(data tl.Serializable) (tl.Serializable, []byte)

func WrapMessage

func WrapMessage(id []byte, data tl.Serializable) tl.Serializable

func WrapQuery

func WrapQuery(id []byte, data tl.Serializable) tl.Serializable

Types

type ADNL

type ADNL interface {
	SetCustomMessageHandler(handler func(msg *adnl.MessageCustom) error)
	SetQueryHandler(handler func(msg *adnl.MessageQuery) error)
	SetDisconnectHandler(handler func(addr string, key ed25519.PublicKey))
	SendCustomMessage(ctx context.Context, req tl.Serializable) error
	Query(ctx context.Context, req, result tl.Serializable) error
	Answer(ctx context.Context, queryID []byte, result tl.Serializable) error
	RemoteAddr() string
	GetID() []byte
	Close()
}

type ADNLOverlayWrapper

type ADNLOverlayWrapper struct {
	*ADNLWrapper
	// contains filtered or unexported fields
}

func (*ADNLOverlayWrapper) Close

func (a *ADNLOverlayWrapper) Close()

func (*ADNLOverlayWrapper) GetRandomPeers

func (a *ADNLOverlayWrapper) GetRandomPeers(ctx context.Context) ([]Node, error)

func (*ADNLOverlayWrapper) Query

func (a *ADNLOverlayWrapper) Query(ctx context.Context, req, result tl.Serializable) error

func (*ADNLOverlayWrapper) SendCustomMessage

func (a *ADNLOverlayWrapper) SendCustomMessage(ctx context.Context, req tl.Serializable) error

func (*ADNLOverlayWrapper) SetAuthorizedKeys

func (a *ADNLOverlayWrapper) SetAuthorizedKeys(keysWithMaxLen map[string]int32)

func (*ADNLOverlayWrapper) SetBroadcastHandler

func (a *ADNLOverlayWrapper) SetBroadcastHandler(handler func(msg tl.Serializable, trusted bool) error)

func (*ADNLOverlayWrapper) SetCustomMessageHandler

func (a *ADNLOverlayWrapper) SetCustomMessageHandler(handler func(msg *adnl.MessageCustom) error)

func (*ADNLOverlayWrapper) SetDisconnectHandler

func (a *ADNLOverlayWrapper) SetDisconnectHandler(handler func(addr string, key ed25519.PublicKey))

func (*ADNLOverlayWrapper) SetQueryHandler

func (a *ADNLOverlayWrapper) SetQueryHandler(handler func(msg *adnl.MessageQuery) error)

type ADNLWrapper

type ADNLWrapper struct {
	ADNL
	// contains filtered or unexported fields
}

func CreateExtendedADNL

func CreateExtendedADNL(adnl ADNL) *ADNLWrapper

func (*ADNLWrapper) CreateOverlayWithSettings

func (a *ADNLWrapper) CreateOverlayWithSettings(id []byte, maxUnauthBroadcastSize int32,
	allowBroadcastFEC bool, trustUnauthorizedBroadcast bool) *ADNLOverlayWrapper

func (*ADNLWrapper) SetCustomMessageHandler

func (a *ADNLWrapper) SetCustomMessageHandler(handler func(msg *adnl.MessageCustom) error)

func (*ADNLWrapper) SetDisconnectHandler

func (a *ADNLWrapper) SetDisconnectHandler(handler func(addr string, key ed25519.PublicKey))

func (*ADNLWrapper) SetOnUnknownOverlayQuery

func (a *ADNLWrapper) SetOnUnknownOverlayQuery(handler func(query *adnl.MessageQuery) error)

func (*ADNLWrapper) SetQueryHandler

func (a *ADNLWrapper) SetQueryHandler(handler func(msg *adnl.MessageQuery) error)

func (*ADNLWrapper) UnregisterOverlay

func (a *ADNLWrapper) UnregisterOverlay(id []byte)

func (*ADNLWrapper) WithOverlay

func (a *ADNLWrapper) WithOverlay(id []byte) *ADNLOverlayWrapper

WithOverlay - creates basic overlay with restrictive broadcast settings

type Broadcast

type Broadcast struct {
	Source      any    `tl:"struct boxed [pub.ed25519]"`
	Certificate any    `tl:"struct boxed [overlay.emptyCertificate,overlay.certificate,overlay.certificateV2]"`
	Flags       int32  `tl:"int"`
	Data        []byte `tl:"bytes"`
	Date        int32  `tl:"int"`
	Signature   []byte `tl:"bytes"`
}

type BroadcastFEC

type BroadcastFEC struct {
	Source      any    `tl:"struct boxed [pub.ed25519]"`
	Certificate any    `tl:"struct boxed [overlay.emptyCertificate,overlay.certificate,overlay.certificateV2]"`
	DataHash    []byte `tl:"int256"`
	DataSize    int32  `tl:"int"`
	Flags       int32  `tl:"int"`
	Data        []byte `tl:"bytes"`
	Seqno       int32  `tl:"int"`
	FEC         any    `tl:"struct boxed [fec.roundRobin,fec.raptorQ,fec.online]"`
	Date        int32  `tl:"int"`
	Signature   []byte `tl:"bytes"`
}

func (*BroadcastFEC) CalcID

func (t *BroadcastFEC) CalcID() ([]byte, error)

type BroadcastFECID

type BroadcastFECID struct {
	Source   []byte `tl:"int256"`
	Type     []byte `tl:"int256"`
	DataHash []byte `tl:"int256"`
	Size     int32  `tl:"int"`
	Flags    int32  `tl:"int"`
}

type BroadcastFECPartID

type BroadcastFECPartID struct {
	BroadcastHash []byte `tl:"int256"`
	DataHash      []byte `tl:"int256"`
	Seqno         int32  `tl:"int"`
}

type BroadcastFECShort

type BroadcastFECShort struct {
	Source        any    `tl:"struct boxed [pub.ed25519]"`
	Certificate   any    `tl:"struct boxed [overlay.emptyCertificate,overlay.certificate,overlay.certificateV2]"`
	BroadcastHash []byte `tl:"int256"`
	PartDataHash  []byte `tl:"int256"`
	Seqno         int32  `tl:"int"`
	Signature     []byte `tl:"bytes"`
}

type BroadcastToSign

type BroadcastToSign struct {
	Hash []byte `tl:"int256"`
	Date int32  `tl:"int"`
}

type CertCheckResult

type CertCheckResult int
const CertCheckResultForbidden CertCheckResult = 0
const CertCheckResultNeedCheck CertCheckResult = 2
const CertCheckResultTrusted CertCheckResult = 1

type Certificate

type Certificate struct {
	IssuedBy  any    `tl:"struct boxed [pub.ed25519]"`
	ExpireAt  int32  `tl:"int"`
	MaxSize   int32  `tl:"int"`
	Signature []byte `tl:"bytes"`
}

func (Certificate) Check

func (c Certificate) Check(issuedToId []byte, overlayId []byte, dataSize int32, isFEC bool) (CertCheckResult, error)

type CertificateEmpty

type CertificateEmpty struct{}

type CertificateId

type CertificateId struct {
	OverlayID []byte `tl:"int256"`
	Node      []byte `tl:"int256"`
	ExpireAt  int32  `tl:"int"`
	MaxSize   int32  `tl:"int"`
}

type CertificateIdV2

type CertificateIdV2 struct {
	OverlayID []byte `tl:"int256"`
	Node      []byte `tl:"int256"`
	ExpireAt  int32  `tl:"int"`
	MaxSize   int32  `tl:"int"`
	Flags     int32  `tl:"int"`
}

type CertificateV2

type CertificateV2 struct {
	IssuedBy  any    `tl:"struct boxed [pub.ed25519]"`
	ExpireAt  int32  `tl:"int"`
	MaxSize   int32  `tl:"int"`
	Flags     int32  `tl:"int"`
	Signature []byte `tl:"bytes"`
}

func (CertificateV2) Check

func (c CertificateV2) Check(issuedToId []byte, overlayId []byte, dataSize int32, isFEC bool) (CertCheckResult, error)

type CheckableCert

type CheckableCert interface {
	Check(issuedToId []byte, overlayId []byte, dataSize int32, isFEC bool) (CertCheckResult, error)
}

type FECCompleted

type FECCompleted struct {
	Hash []byte `tl:"int256"`
}

type FECReceived

type FECReceived struct {
	Hash []byte `tl:"int256"`
}

type GetRandomPeers

type GetRandomPeers struct {
	List NodesList `tl:"struct"`
}

type Message

type Message struct {
	Overlay []byte `tl:"int256"`
}

type Node

type Node struct {
	ID        any    `tl:"struct boxed [pub.ed25519,pub.aes]"`
	Overlay   []byte `tl:"int256"`
	Version   int32  `tl:"int"`
	Signature []byte `tl:"bytes"`
}

func NewNode

func NewNode(overlay []byte, key ed25519.PrivateKey) (*Node, error)

func (*Node) CheckSignature

func (n *Node) CheckSignature() error

func (*Node) Sign

func (n *Node) Sign(key ed25519.PrivateKey) error

type NodeToSign

type NodeToSign struct {
	ID      []byte `tl:"int256"`
	Overlay []byte `tl:"int256"`
	Version int32  `tl:"int"`
}

type NodesList

type NodesList struct {
	List []Node `tl:"vector struct"`
}

type Query

type Query struct {
	Overlay []byte `tl:"int256"`
}

type RLDP

type RLDP interface {
	GetADNL() rldp.ADNL
	Close()
	DoQuery(ctx context.Context, maxAnswerSize int64, query, result tl.Serializable) error
	SetOnQuery(handler func(transferId []byte, query *rldp.Query) error)
	SetOnDisconnect(handler func())
	SendAnswer(ctx context.Context, maxAnswerSize int64, queryId, transferId []byte, answer tl.Serializable) error
}

type RLDPOverlayWrapper

type RLDPOverlayWrapper struct {
	*RLDPWrapper
	// contains filtered or unexported fields
}

func (*RLDPOverlayWrapper) Close

func (r *RLDPOverlayWrapper) Close()

func (*RLDPOverlayWrapper) DoQuery

func (r *RLDPOverlayWrapper) DoQuery(ctx context.Context, maxAnswerSize int64, req, result tl.Serializable) error

func (*RLDPOverlayWrapper) SetOnDisconnect

func (r *RLDPOverlayWrapper) SetOnDisconnect(handler func())

func (*RLDPOverlayWrapper) SetOnQuery

func (r *RLDPOverlayWrapper) SetOnQuery(handler func(transferId []byte, query *rldp.Query) error)

type RLDPWrapper

type RLDPWrapper struct {
	RLDP
	// contains filtered or unexported fields
}

func CreateExtendedRLDP

func CreateExtendedRLDP(rldp RLDP) *RLDPWrapper

func (*RLDPWrapper) CreateOverlay

func (r *RLDPWrapper) CreateOverlay(id []byte) *RLDPOverlayWrapper

func (*RLDPWrapper) SetOnDisconnect

func (r *RLDPWrapper) SetOnDisconnect(handler func())

func (*RLDPWrapper) SetOnQuery

func (r *RLDPWrapper) SetOnQuery(handler func(transferId []byte, query *rldp.Query) error)

func (*RLDPWrapper) SetOnUnknownOverlayQuery

func (r *RLDPWrapper) SetOnUnknownOverlayQuery(handler func(transferId []byte, query *rldp.Query) error)

func (*RLDPWrapper) UnregisterOverlay

func (r *RLDPWrapper) UnregisterOverlay(id []byte)

Jump to

Keyboard shortcuts

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