Documentation ¶
Index ¶
- Constants
- Variables
- type AuthentJSON
- type AuthentPacket
- func (p *AuthentPacket) GetJSONVersion() (*AuthentJSON, error)
- func (p *AuthentPacket) MarshalBinary() ([]byte, error)
- func (p *AuthentPacket) Read(reader io.Reader, hSize uint32, bSize uint32, fSize uint32) error
- func (*AuthentPacket) Type() byte
- func (p *AuthentPacket) UnmarshalBinary(src []byte) error
- type BlockRequestPacket
- type ConnectionErrorPacket
- type DataPacket
- func (p *DataPacket) MarshalBinary() ([]byte, error)
- func (p *DataPacket) Read(reader io.Reader, hSize uint32, bSize uint32, fSize uint32) error
- func (*DataPacket) Type() byte
- func (p *DataPacket) UnmarshalBinary(src []byte) error
- func (p *DataPacket) WritePacket(writer io.Writer, blockSize uint32) ([]byte, error)
- type EndRequestPacket
- type EndTransferPacket
- type ErrorPacket
- type InformationPacket
- type JSONRequest
- type JSONRequestPacket
- type KeepAlivePacket
- type NetworkPacket
- type NoopPacket
- type R66Packet
- type ReqBody
- type ReqHeader
- type RequestPacket
- type ShutdownPacket
- type TestPacket
- type ValidPacket
Constants ¶
const NoID = 2147483648
NoID is the identifier for a packet without a session.
Variables ¶
var ANSWER = byte(1)
ANSWER is a tag for a response packet
var AuthentCode = byte(1)
AuthentCode is the code identifying an AuthentPacket
var BLOCK = byte(0)
BLOCK tags the BlockRequestPacket as a blocking packet for further request
var BandwidthCode = byte(19)
BandwidthCode identifies a ValidPacket requesting a request or an update of the bandwidth limitation
var BlockRequestCode = byte(24)
BlockRequestCode is the code identifying an BlockRequestPacket
var CancelCode = byte(10)
CancelCode identifies a ValidPacket requesting the cancelation of a transfer
var ConfExportCode = byte(11)
ConfExportCode identifies a ValidPacket requesting an export of configuration
var ConfImportCode = byte(12)
ConfImportCode identifies a ValidPacket requesting an import of configuration
var ConnectionErrorCode = byte(6)
ConnectionErrorCode is the code identifying an ConnectionErrorPacket
var DataCode = byte(3)
DataCode is the code identifying an DataPacket
var EndRequestCode = byte(20)
EndRequestCode is the code identifying an EndRequestPacket
var EndTransferCode = byte(14)
EndTransferCode is the code identifying an EndTransferPacket
var ErrorCode = byte(5)
ErrorCode is the code identifying an ErrorPacket
var InformationCode = byte(18)
InformationCode is the code identifying an InformationPacket
var JSONRequestCode = byte(25)
JSONRequestCode is the code identifying an JSONRequestPacket
var KeepAliveCode = byte(21)
KeepAliveCode is the code identifying an KeepAlivePacket
var LogCode = byte(16)
LogCode identifies a ValidPacket requesting an export of the logs
var LogPurgeCode = byte(17)
LogPurgeCode identifies a ValidPacket requesting a purge of the logs
var NoopCode = byte(23)
NoopCode is the code identifying an NoopPacket
var QUESTION = byte(0)
QUESTION is a marker for a packet which require an answer
var RequestCode = byte(7)
RequestCode is the code identifying an RequestPacket
var RequestUserCode = byte(15)
RequestUserCode identifies a ValidPakcet as a response to a request
var ShutdownCode = byte(8)
ShutdownCode is the code identifying an ShutdownPacket
var StopCode = byte(9)
StopCode identifies a ValidPacket requesting the halt of a transfer
var TestCode = byte(13)
TestCode is the code identifying an TestPacket
var UNBLOCK = byte(1)
UNBLOCK tags the BlockRequestPacket as an unblocking packet for further request
var ValidCode = byte(4)
ValidCode is the code identifying an ValidPacket
Functions ¶
This section is empty.
Types ¶
type AuthentJSON ¶
type AuthentJSON struct { // The hostid of the partner (redundant with packet.Login) HostID string `json:"HostID"` // The version of the protocol used (formated as major.minor.path) Version string `json:"Version"` // Will the partner provide the size of the file when it sends a file FileSize bool `json:"FileSize"` // Will the partner provide a hash of the file sent at the end of the transfer FinalHash bool `json:"FinalHash"` // Which hash algorithm the partner will use to hash the file (authorized values are: MD5, SHA-1, SHA-256, SHA-384, SHA-512, ALDER32) DigestAlgo string `json:"DigestAlgo"` // Is the partner accessed through a proxy Proxified bool `json:"Proxified"` // Which separator the partner use for separating value (not used) Separator string `json:"separator"` }
AuthentJSON represents the partner configuration expected in the VersionField of an AuthentPacket
type AuthentPacket ¶
type AuthentPacket struct { // The login used by the partner Login string // The password used by the partner Password []byte // The identifier of the partner session LocalID uint32 // Is the packet a QUESTION (0) client -> server or an ANSWER (1) server -> client Way byte // The configuration of the partner (see AuthentJSON for more details) Version string }
AuthentPacket is the structure handling the R66 authent packet which provides both login and password to authenticate to the partner as well its configuration
func (*AuthentPacket) GetJSONVersion ¶
func (p *AuthentPacket) GetJSONVersion() (*AuthentJSON, error)
GetJSONVersion unmarshall the VersionField of the provided AuthentPacket and return it as a AuthentJSON pointer TODO Add Tests
func (*AuthentPacket) MarshalBinary ¶
func (p *AuthentPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary form of the packet to send on the network.
func (*AuthentPacket) UnmarshalBinary ¶
func (p *AuthentPacket) UnmarshalBinary(src []byte) error
UnmarshalBinary reads the provided byte array as an AuthentPacket. It returns an error if the byte array doesn't contain an AuthentPacket or if there is not enough data in the array.
type BlockRequestPacket ¶
type BlockRequestPacket struct { // The admin password to be authorised to perform the operation. Password []byte // The tag to block (0) or unblock (1) future transfer requests. Block byte }
BlockRequestPacket is the structure handling the R66 block request packet which requests the partner to refuse (or reaccept) future transfer requests.
func (*BlockRequestPacket) MarshalBinary ¶
func (p *BlockRequestPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary form of the packet to send on the network.
func (*BlockRequestPacket) Type ¶
func (*BlockRequestPacket) Type() byte
Type returns the code of the packet
func (*BlockRequestPacket) UnmarshalBinary ¶
func (p *BlockRequestPacket) UnmarshalBinary(src []byte) error
UnmarshalBinary reads the provided byte array as a BlockRequest. It returns an error if the byte array doesn't contain a BlockRequest or if there is not enough data in the array.
type ConnectionErrorPacket ¶
ConnectionErrorPacket is the structure handling the R66 connection error packet which indicate an error while establish the r66 connection.
func (*ConnectionErrorPacket) MarshalBinary ¶
func (p *ConnectionErrorPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary form of the packet to send on the network.
func (*ConnectionErrorPacket) Read ¶
func (p *ConnectionErrorPacket) Read(reader io.Reader, hSize uint32, bSize uint32, fSize uint32) error
Deprecated
func (*ConnectionErrorPacket) Type ¶
func (*ConnectionErrorPacket) Type() byte
Type returns the code of the packet
func (*ConnectionErrorPacket) UnmarshalBinary ¶
func (p *ConnectionErrorPacket) UnmarshalBinary(src []byte) error
UnmarshalBinary reads the provided byte array as a ConnectionErrorPacket. It returns an error if the byte array doesn't contain a ConnectionErrorPacket or if there is not enough data in the array.
type DataPacket ¶
type DataPacket struct { // Rank is the numer of the block transmited. Rank uint32 // Hash contains the data block transmited. Data []byte // Hash contains the hash of the block if the transfer is a hashed transfer. Hash []byte // Deprecated Unlock func() // contains filtered or unexported fields }
DataPacket is the structure handling the R66 data packet which carries the content of the file transfered and eventualy the hash of the content of the packet.
func (*DataPacket) MarshalBinary ¶
func (p *DataPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary form of the packet to send on the network.
func (*DataPacket) UnmarshalBinary ¶
func (p *DataPacket) UnmarshalBinary(src []byte) error
UnmarshalBinary reads the provided byte array as a DataPacket. It returns an error if the byte array doesn't contain a DataPacket or if there is not enough data in the array.
As the DataPacket can be quite large it is advised to directly read the DataPacket in the file rather than use this function.
func (*DataPacket) WritePacket ¶
WritePacket writes the content of the packet in the provided writer according to the provided blocksize. It returns the hash of the content or an error if a problem occurs. Deprecated
type EndRequestPacket ¶
EndRequestPacket is the structure handling the R66 end request packet which indicate the end of all the transfer's operations.
func (*EndRequestPacket) MarshalBinary ¶
func (p *EndRequestPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary form of the packet to send on the network.
func (*EndRequestPacket) Type ¶
func (*EndRequestPacket) Type() byte
Type returns the code of the packet
func (*EndRequestPacket) UnmarshalBinary ¶
func (p *EndRequestPacket) UnmarshalBinary(src []byte) error
UnmarshalBinary reads the provided byte array as an EndRequestPacket. It returns an error if the byte array doesn't contain an EndRequestPacket or if there is not enough data in the array.
type EndTransferPacket ¶
EndTransferPacket is the structure handling the R66 end transfer packet which indicate the end the data transfer.
func (*EndTransferPacket) MarshalBinary ¶
func (p *EndTransferPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary form of the packet to send on the network.
func (*EndTransferPacket) Type ¶
func (*EndTransferPacket) Type() byte
Type returns the code of the packet
func (*EndTransferPacket) UnmarshalBinary ¶
func (p *EndTransferPacket) UnmarshalBinary(src []byte) error
UnmarshalBinary reads the provided byte array as an EndTransferPacket. It returns an error if the byte array doesn't contain an EndTransferPacket or if there is not enough data in the array.
type ErrorPacket ¶
ErrorPacket is the structure handling the R66 error packet which provides information on an error which occured during a transfer.
func (*ErrorPacket) MarshalBinary ¶
func (p *ErrorPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary form of the packet to send on the network.
func (*ErrorPacket) UnmarshalBinary ¶
func (p *ErrorPacket) UnmarshalBinary(src []byte) error
UnmarshalBinary reads the provided byte array as an ErrorPacket. It returns an error if the byte array doesn't contain an ErrorPacket or if there is not enough data in the array.
type InformationPacket ¶
InformationPacket is the structure handling the R66 information packet which request informations of the files available through a given rules, or of an existing transfer.
func (*InformationPacket) MarshalBinary ¶
func (p *InformationPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary form of the packet to send on the network.
func (*InformationPacket) Type ¶
func (*InformationPacket) Type() byte
Type returns the code of the packet
func (*InformationPacket) UnmarshalBinary ¶
func (p *InformationPacket) UnmarshalBinary(src []byte) error
UnmarshalBinary reads the provided byte array as an InformationPacket. It returns an error if the byte array doesn't contain an InformationPacket or if there is not enough data in the array.
type JSONRequest ¶
type JSONRequest struct { Class string `json:"@class"` Comment string `json:"comment"` RequestPacket byte `json:"requestUserPacket"` Filename string `json:"filename"` FileSize int `json:"filesize"` FileInfo string `json:"fileInfo"` }
JSONRequest is the structure wrapping the informations of a request passed through a JSONRequestPacket
type JSONRequestPacket ¶
type JSONRequestPacket struct { Request *JSONRequest Result string Code byte }
JSONRequestPacket is the structure handling the R66 JSON request packet which allows specific requests to be used such as the modification of the file information before the transfer.
func (*JSONRequestPacket) MarshalBinary ¶
func (p *JSONRequestPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary form of the packet to send on the network.
func (*JSONRequestPacket) Type ¶
func (*JSONRequestPacket) Type() byte
Type returns the code of the packet
func (*JSONRequestPacket) UnmarshalBinary ¶
func (p *JSONRequestPacket) UnmarshalBinary(src []byte) error
UnmarshalBinary reads the provided byte array as an JSONRequestPacket. It returns an error if the byte array doesn't contain an JSONRequestPacket, if there is not enough data in the array or if the JSON contained in the packet is malformated.
type KeepAlivePacket ¶
type KeepAlivePacket struct {
Way byte
}
KeepAlivePacket is the structure handling the R66 keep alive packet which prevent the connection to be dropped by the remote partner.
func (*KeepAlivePacket) MarshalBinary ¶
func (p *KeepAlivePacket) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary form of the packet to send on the network.
func (*KeepAlivePacket) Type ¶
func (*KeepAlivePacket) Type() byte
Type returns the code of the packet
func (*KeepAlivePacket) UnmarshalBinary ¶
func (p *KeepAlivePacket) UnmarshalBinary(src []byte) error
UnmarshalBinary reads the provided byte array as a KeepAlive. It returns an error if the byte array doesn't contain a KeepAlive or if there is not enough data in the array.
type NetworkPacket ¶
type NetworkPacket struct { Size uint32 // RemoteID is the identifier of the remote session. RemoteID uint32 // LocalID is the identifier of the local session. LocalID uint32 // Type is the identifier of the packet content. // FIXME 1.0.0 rename into Code Type byte // Content is the payload of the NetworkPacket. Content R66Packet }
NetworkPacket is the structure handling the multiplexing part of the R66 packet.
func (*NetworkPacket) MarshalBinary ¶
func (p *NetworkPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary form of the packet to send on the network.
func (*NetworkPacket) ReadPacket ¶
func (p *NetworkPacket) ReadPacket(reader io.Reader) (err error)
ReadPacket fills the NetworkPacket from the provided reader. Deprecated
func (*NetworkPacket) UnmarshalBinary ¶
func (p *NetworkPacket) UnmarshalBinary(src []byte) error
UnmarshalBinary reads the provided byte array as a NetworkPacket. It returns an error if there is not enough data in the array.
This function only unmarshal the network specific part of the packet and not the payload.
type NoopPacket ¶
type NoopPacket struct { }
NoopPacket is the structure reponsible for handling a R66 noop Packet which do nothing.
func (*NoopPacket) MarshalBinary ¶
func (p *NoopPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary form of the packet to send on the network.
func (*NoopPacket) UnmarshalBinary ¶
func (p *NoopPacket) UnmarshalBinary(src []byte) error
UnmarshalBinary reads the provided byte array as a NoopPacket. It returns an error if the byte array doesn't contain a NoopPacket or if there is not enough data in the array.
type R66Packet ¶
type R66Packet interface { encoding.BinaryMarshaler encoding.BinaryUnmarshaler // FIXME 1.0.0 Rename into Code // Type returns the code of the packet Type() byte // Read reads the packet according to the provided header, body and footer size // Deprecated will use encoding.BinaryUnmarshaler instead Read(io.Reader, uint32, uint32, uint32) error }
R66Packet is an interface which all R66 packet must implements
type ReqBody ¶
type ReqBody struct { Filename string `json:"filename"` BlockSize uint32 `json:"block"` Rank uint32 `json:"rank"` ID int64 `json:"id"` Code rune `json:"code"` Filesize int64 `json:"length"` Limit uint32 `json:"limit"` }
ReqBody is the structure holding the Body of a R66 Request Packet
type RequestPacket ¶
RequestPacket is the structure reponsible for handling a R66 Request Packet which request a new transfer to be started or an existing.
func (*RequestPacket) MarshalBinary ¶
func (p *RequestPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary form of the packet to send on the network.
func (*RequestPacket) UnmarshalBinary ¶
func (p *RequestPacket) UnmarshalBinary(src []byte) error
UnmarshalBinary reads the provided byte array as a Request. It returns an error if the byte array doesn't contain a Request or if there is not enough data in the array.
type ShutdownPacket ¶
ShutdownPacket is the structure reponsible for handling a R66 Shutdown Packet
func (*ShutdownPacket) MarshalBinary ¶
func (p *ShutdownPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary form of the packet to send on the network.
func (*ShutdownPacket) Type ¶
func (*ShutdownPacket) Type() byte
Type returns the code of the packet
func (*ShutdownPacket) UnmarshalBinary ¶
func (p *ShutdownPacket) UnmarshalBinary(src []byte) error
UnmarshalBinary reads the provided byte array as a ShutdownPacket. It returns an error if the byte array doesn't contain a ShutdownPacket or if there is not enough data in the array.
type TestPacket ¶
TestPacket is the structure reponsible for handling a R66 Test Packet
func (*TestPacket) MarshalBinary ¶
func (p *TestPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary form of the packet to send on the network.
func (*TestPacket) UnmarshalBinary ¶
func (p *TestPacket) UnmarshalBinary(src []byte) error
UnmarshalBinary reads the provided byte array as a TestPacket. It returns an error if the byte array doesn't contain a TestPacket or if there is not enough data in the array.
type ValidPacket ¶
ValidPacket is the structure reponsible for handling a R66 Valid Packet
func (*ValidPacket) MarshalBinary ¶
func (p *ValidPacket) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary form of the packet to send on the network.
func (*ValidPacket) UnmarshalBinary ¶
func (p *ValidPacket) UnmarshalBinary(src []byte) error
UnmarshalBinary reads the provided byte array as a ValidPacket. It returns an error if the byte array doesn't contain a ValidPacket or if there is not enough data in the array.
Source Files ¶
- authent_packet.go
- block_request_packet.go
- connection_error_packet.go
- data_packet.go
- end_request_packet.go
- end_transfer_packet.go
- error_packet.go
- information_packet.go
- json_command_packet.go
- keep_alive_packet.go
- network_packet.go
- noop_packet.go
- r66_packet.go
- request_packet.go
- shutdown_packet.go
- test_packet.go
- utils.go
- valid_packet.go