transmit

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilePID       protocol.ID = "/transmit/file/0.0.1"
	DonePID       protocol.ID = "/transmit/done/0.0.1"
	ITEM_INTERVAL             = 25
)

Transfer Protocol ID's

Variables

View Source
var (
	ErrNoSession        = errors.New("Failed to get current session, set to nil")
	ErrFailedAuth       = errors.New("Failed to Authenticate message")
	ErrInvalidDirection = errors.New("Direction was not set")
)

Error Definitions

Functions

func CreatePayloadItems

func CreatePayloadItems(sp *v1.SessionPayload, dir types.Direction) []*v1.SessionItem

CreateItems creates list of sessionItems

func FileCount added in v0.18.2

func FileCount(p *types.Payload) int

FileCount returns the number of files in the Payload

func IsMultiple added in v0.18.2

func IsMultiple(p *types.Payload) (bool, error)

IsMultiple returns true if the transfer is a multiple transfer. Error returned if No Items present in Payload

func IsSingle added in v0.18.2

func IsSingle(p *types.Payload) (bool, error)

IsSingle returns true if the transfer is a single transfer. Error returned if No Items present in Payload

func Libp2pID added in v0.18.2

func Libp2pID(p *types.Peer) (peer.ID, error)

Libp2pID returns the PeerID based on PublicKey from Profile

func NewInSession

func NewInSession(payload *types.Payload, from *types.Peer, to *types.Peer) *v1.Session

NewInSession creates a new Session from the given payload with Incoming direction.

func NewOutSession

func NewOutSession(payload *types.Payload, to *types.Peer, from *types.Peer) *v1.Session

NewOutSession creates a new Session from the given payload with Outgoing direction.

func NewSessionPayload

func NewSessionPayload(p *types.Payload) *v1.SessionPayload

NewSessionPayload creates session payload

func ProgressItem

func ProgressItem(si *v1.SessionItem, wrt int, n config.CallbackImpl) bool

Progress pushes a progress event to the node. Returns true if the item is done.

func ReadItemFromStream

func ReadItemFromStream(si *v1.SessionItem, node config.CallbackImpl, reader msgio.ReadCloser) error

ReadFromStream reads the item from the stream

func RouteSessionStream

func RouteSessionStream(s *v1.Session, stream network.Stream, n config.CallbackImpl) (*motor.OnTransmitCompleteResponse, error)

RouteStream is used to route the given stream to the given peer.

func SessionEvent

func SessionEvent(s *v1.Session) *motor.OnTransmitCompleteResponse

Event returns the complete event for the session.

func SessionFinalIndex

func SessionFinalIndex(s *v1.Session) int

FinalIndex returns the final index of the session.

func SessionHasRead

func SessionHasRead(s *v1.Session) bool

HasRead returns true if all files have been read.

func SessionHasWrote

func SessionHasWrote(s *v1.Session) bool

HasWrote returns true if all files have been written.

func SessionIsDone

func SessionIsDone(s *v1.Session) bool

IsDone returns true if all files have been read or written.

func SessionIsIn

func SessionIsIn(s *v1.Session) bool

IsIn returns true if the session is incoming.

func SessionIsOut

func SessionIsOut(s *v1.Session) bool

IsOut returns true if the session is outgoing.

func URLCount added in v0.18.2

func URLCount(p *types.Payload) int

URLCount returns the number of URLs in the Payload

func UpdateCurrent

func UpdateCurrent(s *v1.Session, result bool) bool

UpdateCurrent updates the current index of the session.

func WriteItemToStream

func WriteItemToStream(si *v1.SessionItem, node config.CallbackImpl, writer msgio.WriteCloser) error

WriteToStream writes the item to the stream

Types

type Option

type Option func(*options)

Option is a function that can be applied to ExchangeProtocol config

type PayloadItemFunc added in v0.18.2

type PayloadItemFunc func(item *types.Payload_Item, index int, total int) error

** ─────────────────────────────────────────────────────── ** ─── Payload Management ──────────────────────────────── ** ─────────────────────────────────────────────────────── PayloadItemFunc is the Map function for PayloadItem

type TransmitProtocol

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

TransmitProtocol type

func New

func New(ctx context.Context, host host.HostImpl, cb config.CallbackImpl, options ...Option) (*TransmitProtocol, error)

New creates a new TransferProtocol

func (*TransmitProtocol) CurrentSession

func (p *TransmitProtocol) CurrentSession() (*v1.Session, error)

CurrentSession returns the current session

func (*TransmitProtocol) Incoming

func (p *TransmitProtocol) Incoming(payload *types.Payload, from *types.Peer) error

Incoming is called by the node to accept an incoming transfer

func (*TransmitProtocol) Outgoing

func (p *TransmitProtocol) Outgoing(payload *types.Payload, to *types.Peer) error

Outgoing is called by the node to initiate a transfer

func (*TransmitProtocol) Reset

Reset resets the current session

Jump to

Keyboard shortcuts

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