Documentation ¶
Index ¶
- Constants
- type KeyExchangeHandler
- type Node
- func (n *Node) AddAuthenticatedPeer(peerID peer.ID)
- func (n *Node) AdvertiseIdentifier(t time.Time, chanID int16) string
- func (n *Node) HasPublicAddr() bool
- func (n *Node) IsAuthenticated(peerID peer.ID) bool
- func (n *Node) Read(s network.Stream, data p2p.HeaderMessage) error
- func (n *Node) ReadBytes(r io.Reader) ([]byte, error)
- func (n *Node) ResetOnShutdown(s network.Stream) context.CancelFunc
- func (n *Node) Send(s network.Stream, msg p2p.HeaderMessage) error
- func (n *Node) Shutdown()
- func (n *Node) WaitForEOF(s network.Stream) error
- func (n *Node) WriteBytes(w io.Writer, data []byte) (int, error)
- type PakeClientProtocol
- type PakeProtocol
- type PakeServerProtocol
- type PeerHandler
- type PushProtocol
- type PushRequestHandler
- type TransferHandler
- type TransferProtocol
Constants ¶
const ProtocolPake = "/pcp/pake/0.1.0"
pattern: /protocol-name/request-or-response-message/version
const ProtocolPushRequest = "/pcp/push/0.0.1"
pattern: /protocol-name/request-or-response-message/version
const (
ProtocolTransfer = "/pcp/transfer/0.1.0"
)
pattern: /protocol-name/request-or-response-message/version
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeyExchangeHandler ¶
type Node ¶
type Node struct { host.Host *PushProtocol *TransferProtocol *service.Service // DHT is an accessor that is needed in the DHT discoverer/advertiser. DHT *kaddht.IpfsDHT // contains filtered or unexported fields }
Node encapsulates the logic for sending and receiving messages.
func (*Node) AddAuthenticatedPeer ¶
func (*Node) AdvertiseIdentifier ¶
AdvertiseIdentifier returns the string, that we use to advertise via mDNS and the DHT. See ChannelID above for more information.
func (*Node) HasPublicAddr ¶
func (*Node) Read ¶
Read drains the given stream and parses the content. It unmarshalls it into the protobuf object. It also verifies the authenticity of the message. Read closes the stream for reading but leaves it open for writing.
func (*Node) ResetOnShutdown ¶
func (n *Node) ResetOnShutdown(s network.Stream) context.CancelFunc
func (*Node) Send ¶
Send prepares the message msg to be sent over the network stream s. Send closes the stream for writing but leaves it open for reading.
func (*Node) WaitForEOF ¶
WaitForEOF waits for an EOF signal on the stream. This indicates that the peer has received all data and won't read from this stream anymore. Alternatively there is a 10 second timeout.
type PakeClientProtocol ¶
type PakeClientProtocol struct {
*PakeProtocol
}
PakeClientProtocol .
func NewPakeClientProtocol ¶
func NewPakeClientProtocol(node *Node, pw []byte) *PakeClientProtocol
func (*PakeClientProtocol) StartKeyExchange ¶
type PakeProtocol ¶
type PakeProtocol struct {
// contains filtered or unexported fields
}
func (*PakeProtocol) ReceiveVerifyProof ¶
func (p *PakeProtocol) ReceiveVerifyProof(s network.Stream, key []byte) error
type PakeServerProtocol ¶
type PakeServerProtocol struct { *PakeProtocol // contains filtered or unexported fields }
PakeServerProtocol .
func NewPakeServerProtocol ¶
func NewPakeServerProtocol(node *Node, pw []byte) *PakeServerProtocol
func (*PakeServerProtocol) RegisterKeyExchangeHandler ¶
func (p *PakeServerProtocol) RegisterKeyExchangeHandler(keh KeyExchangeHandler)
func (*PakeServerProtocol) UnregisterKeyExchangeHandler ¶
func (p *PakeServerProtocol) UnregisterKeyExchangeHandler()
type PeerHandler ¶
type PushProtocol ¶
type PushProtocol struct {
// contains filtered or unexported fields
}
PushProtocol .
func NewPushProtocol ¶
func NewPushProtocol(node *Node) *PushProtocol
func (*PushProtocol) RegisterPushRequestHandler ¶
func (p *PushProtocol) RegisterPushRequestHandler(prh PushRequestHandler)
func (*PushProtocol) SendPushRequest ¶
func (*PushProtocol) UnregisterPushRequestHandler ¶
func (p *PushProtocol) UnregisterPushRequestHandler()
type PushRequestHandler ¶
type PushRequestHandler interface {
HandlePushRequest(*p2p.PushRequest) (bool, error)
}
type TransferHandler ¶
type TransferProtocol ¶
type TransferProtocol struct {
// contains filtered or unexported fields
}
TransferProtocol encapsulates data necessary to fulfill its protocol.
func NewTransferProtocol ¶
func NewTransferProtocol(node *Node) *TransferProtocol
New TransferProtocol initializes a new TransferProtocol object with all fields set to their default values.
func (*TransferProtocol) RegisterTransferHandler ¶
func (t *TransferProtocol) RegisterTransferHandler(th TransferHandler)
func (*TransferProtocol) Transfer ¶
func (t *TransferProtocol) Transfer(ctx context.Context, peerID peer.ID, bar io.Writer, payload io.Reader) (int64, error)
Transfer can be called to transfer the given payload to the given peer. The PushRequest is used for displaying the progress to the user. This function returns when the bytes where transmitted and we have received an acknowledgment.
func (*TransferProtocol) UnregisterTransferHandler ¶
func (t *TransferProtocol) UnregisterTransferHandler()