Documentation
¶
Index ¶
- Constants
- Variables
- type Ack
- type Address
- type Buffer
- type Cancel
- type Channel
- type ChannelHeader
- type Choke
- type ChunkSizeProtocolOption
- type ChunksPerSignatureProtocolOption
- type ContentIntegrityProtectionMethodProtocolOption
- func (v *ContentIntegrityProtectionMethodProtocolOption) ByteLen() int
- func (v *ContentIntegrityProtectionMethodProtocolOption) Marshal(b []byte) int
- func (v *ContentIntegrityProtectionMethodProtocolOption) Type() ProtocolOptionType
- func (v *ContentIntegrityProtectionMethodProtocolOption) Unmarshal(b []byte) (int, error)
- type Data
- type Decoder
- type DelaySample
- type Empty
- type Encoder
- type End
- type EpochProtocolOption
- type Handshake
- type Have
- type Integrity
- type LiveSignatureAlgorithmProtocolOption
- type LiveWindowProtocolOption
- type MerkleHashTreeFunctionProtocolOption
- type Message
- type MessageHandler
- type MessageType
- type MinimumVersionProtocolOption
- type Nonce
- type Ping
- type Pong
- type ProtocolOption
- type ProtocolOptionType
- type ProtocolOptions
- type Reader
- type Request
- type Restart
- type SignedIntegrity
- type Stream
- type StreamAddress
- type StreamCancel
- type StreamClose
- type StreamCountProtocolOption
- type StreamOpen
- type StreamRequest
- type SwarmIdentifierProtocolOption
- type Timestamp
- type Unchoke
- type VersionProtocolOption
- type Writer
- func (w *Writer) Available() int
- func (w *Writer) Dirty() bool
- func (w *Writer) Flush() error
- func (w *Writer) Len() int
- func (w *Writer) Reset()
- func (w *Writer) Write(m Message) (int, error)
- func (w *Writer) WriteAck(m Ack) (int, error)
- func (w *Writer) WriteCancel(m Cancel) (int, error)
- func (w *Writer) WriteChoke(m Choke) (int, error)
- func (w *Writer) WriteData(m Data) (int, error)
- func (w *Writer) WriteHandshake(m Handshake) (int, error)
- func (w *Writer) WriteHave(m Have) (int, error)
- func (w *Writer) WriteIntegrity(m Integrity) (int, error)
- func (w *Writer) WritePing(m Ping) (int, error)
- func (w *Writer) WritePong(m Pong) (int, error)
- func (w *Writer) WriteRequest(m Request) (int, error)
- func (w *Writer) WriteRestart(m Restart) (int, error)
- func (w *Writer) WriteSignedIntegrity(m SignedIntegrity) (int, error)
- func (w *Writer) WriteStreamCancel(m StreamCancel) (int, error)
- func (w *Writer) WriteStreamClose(m StreamClose) (int, error)
- func (w *Writer) WriteStreamOpen(m StreamOpen) (int, error)
- func (w *Writer) WriteStreamRequest(m StreamRequest) (int, error)
- func (w *Writer) WriteUnchoke(m Unchoke) (int, error)
Constants ¶
const MessageTypeLen = 1
Variables ¶
var ( ErrUnsupportedMessageType = errors.New("unsupported message type") ErrUnsupportedProtocolOption = errors.New("unsupported protocol option") )
errors ...
Functions ¶
This section is empty.
Types ¶
type ChannelHeader ¶
ChannelHeader ...
type ChunkSizeProtocolOption ¶
type ChunkSizeProtocolOption struct {
Value uint32
}
ChunkSizeProtocolOption ...
func (*ChunkSizeProtocolOption) ByteLen ¶
func (v *ChunkSizeProtocolOption) ByteLen() int
ByteLen ...
func (*ChunkSizeProtocolOption) Marshal ¶
func (v *ChunkSizeProtocolOption) Marshal(b []byte) int
Marshal ...
func (*ChunkSizeProtocolOption) Type ¶
func (v *ChunkSizeProtocolOption) Type() ProtocolOptionType
Type ...
type ChunksPerSignatureProtocolOption ¶
type ChunksPerSignatureProtocolOption struct {
Value uint32
}
ChunksPerSignatureProtocolOption ...
func (*ChunksPerSignatureProtocolOption) ByteLen ¶
func (v *ChunksPerSignatureProtocolOption) ByteLen() int
ByteLen ...
func (*ChunksPerSignatureProtocolOption) Marshal ¶
func (v *ChunksPerSignatureProtocolOption) Marshal(b []byte) int
Marshal ...
func (*ChunksPerSignatureProtocolOption) Type ¶
func (v *ChunksPerSignatureProtocolOption) Type() ProtocolOptionType
Type ...
type ContentIntegrityProtectionMethodProtocolOption ¶
type ContentIntegrityProtectionMethodProtocolOption struct {
Value uint8
}
ContentIntegrityProtectionMethodProtocolOption ...
func (*ContentIntegrityProtectionMethodProtocolOption) ByteLen ¶
func (v *ContentIntegrityProtectionMethodProtocolOption) ByteLen() int
ByteLen ...
func (*ContentIntegrityProtectionMethodProtocolOption) Marshal ¶
func (v *ContentIntegrityProtectionMethodProtocolOption) Marshal(b []byte) int
Marshal ...
func (*ContentIntegrityProtectionMethodProtocolOption) Type ¶
func (v *ContentIntegrityProtectionMethodProtocolOption) Type() ProtocolOptionType
Type ...
type Data ¶
type Data struct {
Address Address
Timestamp Timestamp
Data Buffer
// contains filtered or unexported fields
}
Data ...
type DelaySample ¶
DelaySample ...
type EpochProtocolOption ¶
type EpochProtocolOption struct {
Timestamp Timestamp
Signature Buffer
// contains filtered or unexported fields
}
EpochProtocolOption ...
func NewEpochProtocolOption ¶
func NewEpochProtocolOption(t timeutil.Time, sig []byte) *EpochProtocolOption
NewEpochProtocolOption ...
func (*EpochProtocolOption) Marshal ¶
func (v *EpochProtocolOption) Marshal(b []byte) (size int)
Marshal ...
type Handshake ¶
type Handshake struct {
ChannelID uint32
Options ProtocolOptions
// contains filtered or unexported fields
}
Handshake ...
type LiveSignatureAlgorithmProtocolOption ¶
type LiveSignatureAlgorithmProtocolOption struct {
Value uint8
}
LiveSignatureAlgorithmProtocolOption ...
func (*LiveSignatureAlgorithmProtocolOption) ByteLen ¶
func (v *LiveSignatureAlgorithmProtocolOption) ByteLen() int
ByteLen ...
func (*LiveSignatureAlgorithmProtocolOption) Marshal ¶
func (v *LiveSignatureAlgorithmProtocolOption) Marshal(b []byte) int
Marshal ...
func (*LiveSignatureAlgorithmProtocolOption) Type ¶
func (v *LiveSignatureAlgorithmProtocolOption) Type() ProtocolOptionType
Type ...
type LiveWindowProtocolOption ¶
type LiveWindowProtocolOption struct {
Value uint32
}
LiveWindowProtocolOption ...
func (*LiveWindowProtocolOption) ByteLen ¶
func (v *LiveWindowProtocolOption) ByteLen() int
ByteLen ...
func (*LiveWindowProtocolOption) Marshal ¶
func (v *LiveWindowProtocolOption) Marshal(b []byte) int
Marshal ...
func (*LiveWindowProtocolOption) Type ¶
func (v *LiveWindowProtocolOption) Type() ProtocolOptionType
Type ...
type MerkleHashTreeFunctionProtocolOption ¶
type MerkleHashTreeFunctionProtocolOption struct {
Value uint8
}
MerkleHashTreeFunctionProtocolOption ...
func (*MerkleHashTreeFunctionProtocolOption) ByteLen ¶
func (v *MerkleHashTreeFunctionProtocolOption) ByteLen() int
ByteLen ...
func (*MerkleHashTreeFunctionProtocolOption) Marshal ¶
func (v *MerkleHashTreeFunctionProtocolOption) Marshal(b []byte) int
Marshal ...
func (*MerkleHashTreeFunctionProtocolOption) Type ¶
func (v *MerkleHashTreeFunctionProtocolOption) Type() ProtocolOptionType
Type ...
type Message ¶
type Message interface {
Decoder
Encoder
Type() MessageType
ByteLen() int
}
Message ...
type MessageHandler ¶
type MessageHandler interface {
HandleHandshake(v Handshake) error
HandleRestart(v Restart) error
HandleData(v Data) error
HandleAck(v Ack) error
HandleHave(v Have) error
HandleIntegrity(v Integrity) error
HandleSignedIntegrity(v SignedIntegrity) error
HandleRequest(v Request) error
HandleCancel(v Cancel) error
HandleChoke(v Choke) error
HandleUnchoke(v Unchoke) error
HandlePing(v Ping) error
HandlePong(v Pong) error
HandleStreamRequest(v StreamRequest) error
HandleStreamCancel(v StreamCancel) error
HandleStreamOpen(v StreamOpen) error
HandleStreamClose(v StreamClose) error
}
MessageHandler ...
type MessageType ¶
type MessageType uint8
MessageType ...
const ( HandshakeMessage MessageType RestartMessage DataMessage AckMessage HaveMessage IntegrityMessage SignedIntegrityMessage RequestMessage CancelMessage ChokeMessage UnchokeMessage PingMessage PongMessage StreamRequestMessage StreamCancelMessage StreamOpenMessage StreamCloseMessage EndMessage MessageType = 255 )
message types
type MinimumVersionProtocolOption ¶
type MinimumVersionProtocolOption struct {
Value uint8
}
MinimumVersionProtocolOption ...
func (*MinimumVersionProtocolOption) ByteLen ¶
func (v *MinimumVersionProtocolOption) ByteLen() int
ByteLen ...
func (*MinimumVersionProtocolOption) Marshal ¶
func (v *MinimumVersionProtocolOption) Marshal(b []byte) int
Marshal ...
func (*MinimumVersionProtocolOption) Type ¶
func (v *MinimumVersionProtocolOption) Type() ProtocolOptionType
Type ...
type ProtocolOption ¶
type ProtocolOption interface {
Decoder
Encoder
Type() ProtocolOptionType
ByteLen() int
}
ProtocolOption ...
type ProtocolOptionType ¶
type ProtocolOptionType uint8
ProtocolOptionType ...
const ( VersionOption ProtocolOptionType = iota MinimumVersionOption SwarmIdentifierOption ContentIntegrityProtectionMethodOption MerkleHashTreeFunctionOption LiveSignatureAlgorithmOption ChunkAddressingMethodOption LiveWindowOption SupportedMessagesOption ChunkSizeOption ChunksPerSignatureOption StreamCountOption EpochOption EndOption ProtocolOptionType = 255 )
protocol options
type ProtocolOptions ¶
type ProtocolOptions []ProtocolOption
ProtocolOptions ...
func (ProtocolOptions) Find ¶
func (o ProtocolOptions) Find(t ProtocolOptionType) (ProtocolOption, bool)
Find ...
func (ProtocolOptions) MustFind ¶
func (o ProtocolOptions) MustFind(t ProtocolOptionType) ProtocolOption
MustFind ...
type Reader ¶
type Reader struct {
ChunkSize int
IntegrityHashSize int
IntegritySignatureSize int
Handler MessageHandler
}
Reader ...
type SignedIntegrity ¶
type SignedIntegrity struct {
Address Address
Timestamp Timestamp
Signature Buffer
// contains filtered or unexported fields
}
SignedIntegrity ...
func (*SignedIntegrity) Marshal ¶
func (v *SignedIntegrity) Marshal(b []byte) (size int)
Marshal ...
type StreamAddress ¶
StreamAddress ...
type StreamCountProtocolOption ¶
type StreamCountProtocolOption struct {
Value uint16
}
StreamCountProtocolOption ...
func (*StreamCountProtocolOption) ByteLen ¶
func (v *StreamCountProtocolOption) ByteLen() int
ByteLen ...
func (*StreamCountProtocolOption) Marshal ¶
func (v *StreamCountProtocolOption) Marshal(b []byte) int
Marshal ...
func (*StreamCountProtocolOption) Type ¶
func (v *StreamCountProtocolOption) Type() ProtocolOptionType
Type ...
type SwarmIdentifierProtocolOption ¶
type SwarmIdentifierProtocolOption []byte
SwarmIdentifierProtocolOption ...
func NewSwarmIdentifierProtocolOption ¶
func NewSwarmIdentifierProtocolOption(id []byte) *SwarmIdentifierProtocolOption
NewSwarmIdentifierProtocolOption ...
func (*SwarmIdentifierProtocolOption) ByteLen ¶
func (v *SwarmIdentifierProtocolOption) ByteLen() int
ByteLen ...
func (*SwarmIdentifierProtocolOption) Marshal ¶
func (v *SwarmIdentifierProtocolOption) Marshal(b []byte) (size int)
Marshal ...
func (*SwarmIdentifierProtocolOption) Type ¶
func (v *SwarmIdentifierProtocolOption) Type() ProtocolOptionType
Type ...
type VersionProtocolOption ¶
type VersionProtocolOption struct {
Value uint8
}
VersionProtocolOption ...
func (*VersionProtocolOption) Marshal ¶
func (v *VersionProtocolOption) Marshal(b []byte) int
Marshal ...
func (*VersionProtocolOption) Type ¶
func (v *VersionProtocolOption) Type() ProtocolOptionType
Type ...
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer ...
func (*Writer) WriteHandshake ¶
WriteHandshake ...
func (*Writer) WriteIntegrity ¶
WriteIntegrity ...
func (*Writer) WriteRequest ¶
WriteRequest ...
func (*Writer) WriteRestart ¶
WriteRestart ...
func (*Writer) WriteSignedIntegrity ¶
func (w *Writer) WriteSignedIntegrity(m SignedIntegrity) (int, error)
WriteSignedIntegrity ...
func (*Writer) WriteStreamCancel ¶
func (w *Writer) WriteStreamCancel(m StreamCancel) (int, error)
WriteStreamCancel ...
func (*Writer) WriteStreamClose ¶
func (w *Writer) WriteStreamClose(m StreamClose) (int, error)
WriteStreamClose ...
func (*Writer) WriteStreamOpen ¶
func (w *Writer) WriteStreamOpen(m StreamOpen) (int, error)
WriteStreamOpen ...
func (*Writer) WriteStreamRequest ¶
func (w *Writer) WriteStreamRequest(m StreamRequest) (int, error)
WriteStreamRequest ...