Documentation
¶
Index ¶
- Constants
- Variables
- type HandShakeContent
- type Message
- type MessageContent
- type Packet
- type PacketContent
- func (p *PacketContent) Bytes() []byte
- func (p *PacketContent) Check() error
- func (p *PacketContent) Decode(r io.Reader) (int, error)
- func (p *PacketContent) Encode(w io.Writer) (int, error)
- func (p *PacketContent) GetCommand() common.Command
- func (p *PacketContent) Len() int
- func (p *PacketContent) Max() int
- type Protocol
- type ProtocolInfo
- func (pi *ProtocolInfo) GetDefaultPort() int
- func (pi *ProtocolInfo) GetDefaultProtocol() string
- func (pi *ProtocolInfo) GetDefaultVersion() string
- func (pi *ProtocolInfo) IsPortSupported(port int) (bool, error)
- func (pi *ProtocolInfo) IsProtocolSupported(proto string) (bool, error)
- func (pi *ProtocolInfo) IsVersionSupported(version string) (bool, error)
- func (pi *ProtocolInfo) ProtocolInfo() *ProtocolInfo
- type ProtocolPort
- type ProtocolVersion
- type RPC
- type RPCContent
- type TransportProtocol
Constants ¶
View Source
const (
MaxMessagePayloadSize = 32
)
View Source
const (
MaxPacketPayloadSize = 200
)
View Source
const (
MaxRPCPayloadSize = 50
)
Variables ¶
Functions ¶
This section is empty.
Types ¶
type HandShakeContent ¶
type HandShakeContent struct {
DIDDocument *did.Document `json:"did_document"`
Signature []byte `json:"signature"` // Signature of the DID Document
Challenge []byte `json:"challenge"` // Random challenge for replay protection
Version string `json:"version"`
}
func NewHandShakeContent ¶
func NewHandShakeContent(didDoc *did.Document, signature, challenge []byte, version string) *HandShakeContent
type Message ¶
type MessageContent ¶
type MessageContent struct {
Type common.Message // Type of message
PayloadLen uint8 // Real payload length
Payload [MaxMessagePayloadSize]byte // Actual message content or data
Hash [32]byte // Payload hash
CreatedAt int64 // Timestamp of message creation
}
func (*MessageContent) Bytes ¶
func (m *MessageContent) Bytes() []byte
func (*MessageContent) Len ¶
func (m *MessageContent) Len() int
func (*MessageContent) Max ¶
func (m *MessageContent) Max() int
func (*MessageContent) Verify ¶
func (m *MessageContent) Verify(sharedKey []byte) bool
type Packet ¶
type PacketContent ¶
type PacketContent struct {
Command common.Command
PayloadLen uint16
Payload [MaxPacketPayloadSize]byte
CheckSum uint64
}
func (*PacketContent) Bytes ¶
func (p *PacketContent) Bytes() []byte
func (*PacketContent) Check ¶
func (p *PacketContent) Check() error
func (*PacketContent) GetCommand ¶
func (p *PacketContent) GetCommand() common.Command
func (*PacketContent) Len ¶
func (p *PacketContent) Len() int
func (*PacketContent) Max ¶
func (p *PacketContent) Max() int
type Protocol ¶
type Protocol interface {
ProtocolInfo() *ProtocolInfo
IsVersionSupported(string) (bool, error)
IsPortSupported(int) (bool, error)
IsProtocolSupported(string) (bool, error)
GetDefaultVersion() string
GetDefaultPort() int
GetDefaultProtocol() string
}
func NewProtocolInfo ¶
func NewProtocolInfo(transport TransportProtocol) Protocol
NewProtocolInfo creates a new ProtocolInfo instance
type ProtocolInfo ¶
type ProtocolInfo struct {
TransportProtocol TransportProtocol
Version ProtocolVersion
Port ProtocolPort
}
ProtcolInfo defines the protocol used in the p2p network
func (*ProtocolInfo) GetDefaultPort ¶
func (pi *ProtocolInfo) GetDefaultPort() int
GetDefaultPort returns the default protocol port
func (*ProtocolInfo) GetDefaultProtocol ¶
func (pi *ProtocolInfo) GetDefaultProtocol() string
GetDefaultProtocol returns the default transport protocol
func (*ProtocolInfo) GetDefaultVersion ¶
func (pi *ProtocolInfo) GetDefaultVersion() string
GetDefaultVersion returns the default protocol version
func (*ProtocolInfo) IsPortSupported ¶
func (pi *ProtocolInfo) IsPortSupported(port int) (bool, error)
IsPortSupported checks if the given port is supported
func (*ProtocolInfo) IsProtocolSupported ¶
func (pi *ProtocolInfo) IsProtocolSupported(proto string) (bool, error)
IsProtocolSupported checks if the given protocol is supported
func (*ProtocolInfo) IsVersionSupported ¶
func (pi *ProtocolInfo) IsVersionSupported(version string) (bool, error)
IsVersionSupported checks if the given version is supported
func (*ProtocolInfo) ProtocolInfo ¶
func (pi *ProtocolInfo) ProtocolInfo() *ProtocolInfo
GetProtocolInfo returns the protocol information
type ProtocolPort ¶
type ProtocolPort int
type ProtocolVersion ¶
type ProtocolVersion string
type RPC ¶
type RPC interface {
Encode(w io.Writer) (int, error)
Decode(r io.Reader) (int, error)
Verify(pubKey ed25519.PublicKey) error
Bytes() []byte
Len() int
Max() int
}
func NewRPCContent ¶
func NewRPCContent(msg Message, d did.IdentifierDID) (RPC, error)
type RPCContent ¶
type RPCContent struct {
From [50]byte
PayloadLen uint8
Payload [MaxRPCPayloadSize]byte
Sig [64]byte
}
func (*RPCContent) Bytes ¶
func (rpc *RPCContent) Bytes() []byte
func (*RPCContent) Len ¶
func (rpc *RPCContent) Len() int
func (*RPCContent) Max ¶
func (rpc *RPCContent) Max() int
type TransportProtocol ¶
type TransportProtocol string
const ( TCPProtocol TransportProtocol = "tcp" UDPProtocol TransportProtocol = "udp" )
Click to show internal directories.
Click to hide internal directories.