overlay

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 13 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnwrapMessage added in v1.7.1

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

func UnwrapQuery added in v1.7.1

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

func WrapMessage added in v1.7.1

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

func WrapQuery added in v1.7.1

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

Types

type ADNL added in v1.6.0

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))
	GetDisconnectHandler() 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 added in v1.6.0

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

func (*ADNLOverlayWrapper) Close added in v1.6.0

func (a *ADNLOverlayWrapper) Close()

func (*ADNLOverlayWrapper) GetRandomPeers added in v1.6.0

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

func (*ADNLOverlayWrapper) Query added in v1.6.0

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

func (*ADNLOverlayWrapper) SendCustomMessage added in v1.6.0

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

func (*ADNLOverlayWrapper) SetAuthorizedKeys added in v1.6.0

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

func (*ADNLOverlayWrapper) SetBroadcastHandler added in v1.6.0

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

func (*ADNLOverlayWrapper) SetCustomMessageHandler added in v1.6.0

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

func (*ADNLOverlayWrapper) SetDisconnectHandler added in v1.6.0

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

func (*ADNLOverlayWrapper) SetQueryHandler added in v1.6.0

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

type ADNLWrapper added in v1.6.0

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

func CreateExtendedADNL added in v1.6.0

func CreateExtendedADNL(adnl ADNL) *ADNLWrapper

func (*ADNLWrapper) CreateOverlayWithSettings added in v1.6.0

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

func (*ADNLWrapper) GetDisconnectHandler added in v1.9.3

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

func (*ADNLWrapper) SetCustomMessageHandler added in v1.6.0

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

func (*ADNLWrapper) SetDisconnectHandler added in v1.6.0

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

func (*ADNLWrapper) SetOnUnknownOverlayQuery added in v1.7.1

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

func (*ADNLWrapper) SetQueryHandler added in v1.6.0

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

func (*ADNLWrapper) UnregisterOverlay added in v1.6.0

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

func (*ADNLWrapper) WithOverlay added in v1.6.0

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

WithOverlay - creates basic overlay with restrictive broadcast settings

type Broadcast added in v1.6.0

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 added in v1.6.0

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 added in v1.6.0

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

type BroadcastFECID added in v1.6.0

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 added in v1.6.0

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

type BroadcastFECShort added in v1.6.0

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 added in v1.6.0

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

type CertCheckResult added in v1.6.0

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

type Certificate added in v1.6.0

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 added in v1.6.0

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

type CertificateEmpty added in v1.6.0

type CertificateEmpty struct{}

type CertificateId added in v1.6.0

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

type CertificateIdV2 added in v1.6.0

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 added in v1.6.0

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 added in v1.6.0

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

type CheckableCert added in v1.6.0

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

type FECCompleted added in v1.6.0

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

type FECReceived added in v1.6.0

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

type GetRandomPeers

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

type Message added in v1.6.0

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 added in v1.7.1

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

func (*Node) CheckSignature added in v1.6.0

func (n *Node) CheckSignature() error

func (*Node) Sign added in v1.6.0

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

type NodeToSign added in v1.6.0

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 added in v1.6.0

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 added in v1.6.0

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

func (*RLDPOverlayWrapper) Close added in v1.6.0

func (r *RLDPOverlayWrapper) Close()

func (*RLDPOverlayWrapper) DoQuery added in v1.6.0

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

func (*RLDPOverlayWrapper) SetOnDisconnect added in v1.6.0

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

func (*RLDPOverlayWrapper) SetOnQuery added in v1.6.0

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

type RLDPWrapper added in v1.6.0

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

func CreateExtendedRLDP added in v1.6.0

func CreateExtendedRLDP(rldp RLDP) *RLDPWrapper

func (*RLDPWrapper) CreateOverlay added in v1.6.0

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

func (*RLDPWrapper) SetOnDisconnect added in v1.6.0

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

func (*RLDPWrapper) SetOnQuery added in v1.6.0

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

func (*RLDPWrapper) SetOnUnknownOverlayQuery added in v1.7.1

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

func (*RLDPWrapper) UnregisterOverlay added in v1.6.0

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

Jump to

Keyboard shortcuts

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