naconn

package
v0.0.0-...-020e20f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package naconn provides node-oriented connection based on ETLS crypto connection.

This package requires a node ID resolver to work like a traditional DNS resolver, except that it resolves node IDs into IP addresses (and ports).

Index

Constants

View Source
const (
	// HeaderSize is the header size with ETLSHeader + NodeID + Nonce.
	HeaderSize = etls.MagicSize + hash.HashBSize + cpuminer.Uint256Size
)

Variables

This section is empty.

Functions

func Dial

func Dial(remote proto.NodeID) (conn net.Conn, err error)

Dial connects to the node with remote node id.

func DialEx

func DialEx(remote proto.NodeID, isAnonymous bool) (conn net.Conn, err error)

DialEx connects to the node with remote node id.

func GetSharedSecretWith

func GetSharedSecretWith(resolver Resolver, nodeID *proto.RawNodeID, isAnonymous bool) (symmetricKey []byte, err error)

GetSharedSecretWith gets shared symmetric key with ECDH.

func RegisterResolver

func RegisterResolver(resolver Resolver)

RegisterResolver registers the default resolver.

Types

type NAConn

type NAConn struct {
	*etls.CryptoConn
	// contains filtered or unexported fields
}

NAConn defines node aware connection based on ETLS crypto connection.

func Accept

func Accept(conn net.Conn) (*NAConn, error)

Accept takes the ownership of conn and accepts it as a NAConn.

func NewServerConn

func NewServerConn(conn net.Conn) *NAConn

NewServerConn takes a raw connection and returns a new server side NAConn.

func (*NAConn) Handshake

func (c *NAConn) Handshake() (err error)

Handshake does the initial handshaking according to the connection role.

func (*NAConn) Remote

func (c *NAConn) Remote() proto.RawNodeID

Remote returns the remote node ID of the NAConn.

type Remoter

type Remoter interface {
	Remote() proto.RawNodeID
}

Remoter defines the interface to acquire remote node ID.

type Resolver

type Resolver interface {
	Resolve(id *proto.RawNodeID) (string, error)
	ResolveEx(id *proto.RawNodeID) (*proto.Node, error)
}

Resolver defines the node ID resolver interface for node-oriented connection.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL