Documentation ¶
Index ¶
- Constants
- Variables
- type Cap
- type Capabilities
- type Config
- type DiscReason
- type Header
- type Info
- type Message
- type Rlpx
- type Secrets
- type Session
- func (s *Session) Close() error
- func (s *Session) CloseChan() <-chan struct{}
- func (s *Session) Disconnect(reason DiscReason) error
- func (s *Session) GetInfo() network.Info
- func (s *Session) Handshake() error
- func (s *Session) IsClosed() bool
- func (s *Session) LocalAddr() net.Addr
- func (s *Session) OpenStream(offset uint, length uint, spec network.ProtocolSpec) *Stream
- func (s *Session) Read(b []byte) (int, error)
- func (s *Session) ReadMsg() (uint64, []byte, error)
- func (s *Session) RemoteAddr() net.Addr
- func (s *Session) RemoteIDString() string
- func (s *Session) RemoteInfo() *Info
- func (s *Session) SetDeadline(t time.Time) error
- func (s *Session) SetReadDeadline(t time.Time) error
- func (s *Session) SetSnappy()
- func (s *Session) SetWriteDeadline(t time.Time) error
- func (s *Session) Streams() []network.Stream
- func (s *Session) Write(b []byte) (int, error)
- func (s *Session) WriteRawMsg(code uint64, buf []byte) error
- type Stream
- func (s *Stream) Close() error
- func (s *Stream) LocalAddr() net.Addr
- func (s *Stream) Protocol() network.ProtocolSpec
- func (s *Stream) Read(b []byte) (n int, err error)
- func (s *Stream) RemoteAddr() net.Addr
- func (s *Stream) SetDeadline(t time.Time) error
- func (s *Stream) SetReadDeadline(t time.Time) error
- func (s *Stream) SetWriteDeadline(t time.Time) error
- func (s *Stream) Write(b []byte) (int, error)
Constants ¶
const ( BaseProtocolVersion = 5 BaseProtocolLength = uint64(16) )
const (
// HeaderSize is the size of the RLPx header
HeaderSize = sizeOfType + sizeOfLength
)
Variables ¶
var (
ErrStreamClosed = fmt.Errorf("session closed")
)
Functions ¶
This section is empty.
Types ¶
type Capabilities ¶
type Capabilities []*Cap
Capabilities are all the capabilities of the other peer
func (Capabilities) Len ¶
func (c Capabilities) Len() int
func (Capabilities) Less ¶
func (c Capabilities) Less(i, j int) bool
func (Capabilities) Swap ¶
func (c Capabilities) Swap(i, j int)
type Config ¶
type Config struct { Prv *ecdsa.PrivateKey Pub *ecdsa.PublicKey Info *Info }
A Config structure is used to configure an Rlpx session.
type DiscReason ¶
type DiscReason uint
const ( DiscRequested DiscReason = iota DiscNetworkError DiscProtocolError DiscUselessPeer DiscTooManyPeers DiscAlreadyConnected DiscIncompatibleVersion DiscInvalidIdentity DiscQuitting DiscUnexpectedIdentity DiscSelf DiscReadTimeout DiscSubprotocolError = 0x10 DiscUnknown = 0x100 )
func (DiscReason) Error ¶
func (d DiscReason) Error() string
func (DiscReason) String ¶
func (d DiscReason) String() string
type Header ¶
type Header []byte
Header represents an RLPx header
type Info ¶
type Info struct { Version uint64 Name string Caps Capabilities ListenPort uint64 ID enode.ID `rlp:"tail"` }
Info is the info of the node
func (*Info) MarshalRLP ¶
func (*Info) UnmarshalRLP ¶
type Message ¶
type Message struct { Code uint64 Size uint32 // size of the paylod Payload io.Reader ReceivedAt time.Time Err error }
Message is the p2p message
type Rlpx ¶
type Rlpx struct { Logger hclog.Logger // contains filtered or unexported fields }
Rlpx is the RLPx transport protocol
func (*Rlpx) DialTimeout ¶
DialTimeout implements the transport interface
type Secrets ¶
type Secrets struct { RemoteID *ecdsa.PublicKey AES, MAC []byte EgressMAC, IngressMAC hash.Hash Token []byte }
Secrets represents the Session Secrets which are negotiated during the encryption handshake.
type Session ¶
type Session struct { Info *Info RemoteID *ecdsa.PublicKey LocalID *ecdsa.PublicKey // contains filtered or unexported fields }
Session is the Session between peers (implements net.Conn)
func Client ¶
func Client(rlpx *Rlpx, conn net.Conn, prv *ecdsa.PrivateKey, pub *ecdsa.PublicKey, info *Info) *Session
Client returns a new Rlpx client side Session
func (*Session) CloseChan ¶
func (s *Session) CloseChan() <-chan struct{}
CloseChan returns a read-only channel which is closed as soon as the session is closed.
func (*Session) Disconnect ¶
func (s *Session) Disconnect(reason DiscReason) error
Disconnect sends a disconnect message to the peer and closes the session
func (*Session) OpenStream ¶
func (*Session) RemoteAddr ¶
RemoteAddr implements the net.Conn interface
func (*Session) RemoteIDString ¶
func (*Session) RemoteInfo ¶
func (*Session) SetDeadline ¶
SetDeadline implements the net.Conn interface
func (*Session) SetReadDeadline ¶
SetReadDeadline implements the net.Conn interface
func (*Session) SetWriteDeadline ¶
SetWriteDeadline implements the net.Conn interface
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream represents a logic stream within a RLPx session
func (*Stream) Protocol ¶
func (s *Stream) Protocol() network.ProtocolSpec
func (*Stream) RemoteAddr ¶
RemoteAddr implements the net.Conn interface
func (*Stream) SetDeadline ¶
SetDeadline implements the net.Conn interface
func (*Stream) SetReadDeadline ¶
SetReadDeadline implements the net.Conn interface
func (*Stream) SetWriteDeadline ¶
SetWriteDeadline implements the net.Conn interface