node

package
v0.0.0-...-11d313d Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var G_NodeMgr = NewNodeMgr()
View Source
var G_TunnelMgr = NewTunnelMgr()
View Source
var PubKeyCache = new(NodeID2PublicKey)

Functions

func AppendTunnel

func AppendTunnel(newTarget *NodeIDNData,
	targetMsg *bufio.Reader,
	chnl chn.Channel,
	nestedAES *stream.NestedAESCFB) (io.Reader,
	<-chan *stream.NestedAESCFB)

func End

func End(nestedAES *stream.NestedAESCFB) (io.Reader,
	<-chan *stream.NestedAESCFB)

func GetKeysNIVs

func GetKeysNIVs(n []*NodeIDNData) (ivs [][]byte, keys [][]byte, er error)

function to extract from slice of NodeIDNData their ivs and keys

func GetPublicKey

func GetPublicKey(ctx context.Context,
	pid peer.ID) (p *rsa.PublicKey, er error)

func GetPublicKeyCH

func GetPublicKeyCH(ctx context.Context, pid peer.ID) <-chan PubKeyBundle

func HeaderBytes

func HeaderBytes(nextPID peer.ID, soln sln.Soln,
	channelID sln.ChannelID) (b []byte)

func InitAlerts

func InitAlerts()

func KeepOnlyConnectedNodes

func KeepOnlyConnectedNodes(ps []peer.ID) (nds []peer.ID)

func Msg

func Msg(targetMsg *bufio.Reader,
	nestedAES *stream.NestedAESCFB) (io.Reader,
	<-chan *stream.NestedAESCFB)

func NewAlertListener

func NewAlertListener() (a *alertListener)

func NewCFBDecrypter

func NewCFBDecrypter(buf *bufio.Reader,
	symKey []byte) (d cipher.Stream, er error)

func NewNodeMgr

func NewNodeMgr() (nm *nmgr)

func NewTunnelMgr

func NewTunnelMgr() (tm *tmgr)

func RelayStream

func RelayStream(remaining []byte, dst network.Stream) (i int, er error)

func SendChunk

func SendChunk(c []byte, s network.Stream) (i int, er error)

func SetStreamHandler

func SetStreamHandler()

func StartStream

func StartStream(ctx context.Context,
	pid peer.ID) (s network.Stream, er error)

func StartTunnel

func StartTunnel(ticks []*NodeIDNData,
	targetMsg *bufio.Reader) (io.Reader, <-chan *stream.NestedAESCFB)

These functions are to form the slices for tunnel, msg, etc. Management of the channel/tunnel will be taken care of elsewhere.

func StreamHandler

func StreamHandler(s network.Stream)

func TakeUpToNNodes

func TakeUpToNNodes(nodes []peer.ID, n int) (nds []peer.ID)

Types

type ErrWMutex

type ErrWMutex struct {
	sync.RWMutex
	// contains filtered or unexported fields
}
type Header struct {
	NextTickID peer.ID       `json:"n"`
	Soln       sln.Soln      `json:"s"`
	ChannelID  sln.ChannelID `json:"c"`
}

type IpfsNode

type IpfsNode core.IpfsNode

func G_Node

func G_Node() (n *IpfsNode)

func New

func New() (n *IpfsNode, er error)

func (*IpfsNode) DecryptOAEPRSA

func (n *IpfsNode) DecryptOAEPRSA(bMessage []byte) (p []byte, er error)

func (*IpfsNode) PublicKey

func (n *IpfsNode) PublicKey() (p *rsa.PublicKey, er error)

func (*IpfsNode) Set

func (i *IpfsNode) Set(n *core.IpfsNode)

func (*IpfsNode) SetPrivateKey

func (n *IpfsNode) SetPrivateKey() (er error)

type KeyPacket

type KeyPacket struct {
	NIDND *NodeIDNData
	// contains filtered or unexported fields
}

func GenerateNodeIDNData

func GenerateNodeIDNData(pid peer.ID, pk *rsa.PublicKey) (kp *KeyPacket)

type NodeData

type NodeData struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

type NodeID2PublicKey

type NodeID2PublicKey struct {
	sync.RWMutex
	M map[peer.ID]*rsa.PublicKey
}

func (*NodeID2PublicKey) CheckCapacity

func (n *NodeID2PublicKey) CheckCapacity()

func (*NodeID2PublicKey) CheckInit

func (n *NodeID2PublicKey) CheckInit()

func (*NodeID2PublicKey) Get

func (n *NodeID2PublicKey) Get(pid peer.ID) (pk *rsa.PublicKey)

func (*NodeID2PublicKey) Put

func (n *NodeID2PublicKey) Put(pid peer.ID, pk *rsa.PublicKey) (er error)

type NodeIDNData

type NodeIDNData struct {
	NodeID    peer.ID
	AESKey    []byte
	EncAESKey []byte
	// encrypted w the rsa pubkey belonging to this node
	IV []byte
}

func GenNodeIDNDatas

func GenNodeIDNDatas(pid2pk *PID2PubKey) (n []*NodeIDNData, er error)

func PrepNodesForStartTunnel

func PrepNodesForStartTunnel(nodes []peer.ID,
	target peer.ID) (ticks []*NodeIDNData,
	targetMsg *bufio.Reader,
	er error)

type NodeRegStatus

type NodeRegStatus byte
const (
	NeverRegistered NodeRegStatus = iota
	Registered
	Unregistered
)

type PID2PubKey

type PID2PubKey struct {
	sync.RWMutex
	M map[peer.ID]*rsa.PublicKey
}

func GetPublicKeys

func GetPublicKeys(ctx context.Context,
	pids []peer.ID) (pid2PubKey *PID2PubKey, er error)

func (*PID2PubKey) GetTarget

func (p *PID2PubKey) GetTarget(
	target peer.ID) (targetOnly *PID2PubKey, er error)

note: always pick target before picking "first" the purpose of this function is so that we can call GenNodeIDNDatas on targetOnly and p without target to be sure that the resulting pair of slices can be ordered so that target is last

func (*PID2PubKey) PickFirst

func (p *PID2PubKey) PickFirst() (firstOnly *PID2PubKey, er error)

note: always pick target before picking "first" A choice function picking from the map a "first" element

type PayloadType

type PayloadType byte
const (
	Relay PayloadType = iota
	Accept
)

func (PayloadType) Byte

func (p PayloadType) Byte() (b byte)

type PubKeyBundle

type PubKeyBundle struct {
	PID    peer.ID
	PubKey *rsa.PublicKey
	// contains filtered or unexported fields
}

type Tunnel

type Tunnel interface {
	Lock()
	Unlock()
	Msg(msg *bufio.Reader) (er error)
	Read(b []byte) (i int, er error)
	Close()
}

func NewTunnel

func NewTunnel(channelID string, target peer.ID) (t Tunnel, er error)

Jump to

Keyboard shortcuts

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