transfer

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

transfer.go specifies the necessary messaging needed for the transfer protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Expected []MsgType
	Got      MsgType
}

func (Error) Error

func (e Error) Error() string

type Msg

type Msg struct {
	Type    MsgType `json:"type"`
	Payload Payload `json:"payload,omitempty"`
}

Msg specifies a message in the transfer protocol.

func (Msg) Bytes

func (t Msg) Bytes() []byte

type MsgType

type MsgType int

MsgType specifies the message type for the messages in the transfer protocol.

const (
	TransferError     MsgType = iota // An error has occured in transferProtocol
	ReceiverHandshake                // Receiver exchange its IP via the rendezvous server to the sender
	SenderHandshake                  // Sender exchanges IP, port and payload size to the receiver via the rendezvous server
	ReceiverDirectCommunication
	SenderDirectAck            // Sender ACKs the request for direct communication
	ReceiverRelayCommunication // Receiver has tried to probe the sender but cannot find it on the subnet, relay communication will be used
	SenderRelayAck             // Sender ACKs the request for relay communication
	ReceiverRequestPayload     // Receiver request the payload from the sender
	SenderPayloadSent          // Sender announces that the entire file has been transfered
	ReceiverPayloadAck         // Receiver ACKs that is has received the payload
	SenderClosing              // Sender announces that it is closing the connection
	ReceiverClosingAck         // Receiver ACKs the closing of the connection
)

func (MsgType) Name

func (t MsgType) Name() string

type Payload

type Payload struct {
	IP          net.IP `json:"ip,omitempty"`
	Port        int    `json:"port,omitempty"`
	PayloadSize int64  `json:"payload_size,omitempty"`
}

type Type

type Type int
const (
	Unknown Type = iota
	Direct
	Relay
)

Jump to

Keyboard shortcuts

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