node

package
v0.0.0-...-0226d21 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DeMedVersion = "alpha_0.1"

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionState

type ConnectionState byte
const (
	Closed      ConnectionState = 0b000
	Established ConnectionState = 0b001
	Ready       ConnectionState = 0b010
)

type Info

type Info struct {
	RemotePeer *net.TCPAddr
	Peer       *net.TCPAddr
	Socket     net.Conn

	LastSeen        time.Time
	ConnectionState ConnectionState

	RemotePubKey rsa.PublicKey
	// contains filtered or unexported fields
}

func (*Info) CloseConnection

func (this *Info) CloseConnection()

func (*Info) SendFullMedicineRequest

func (this *Info) SendFullMedicineRequest()

func (*Info) SendGoodbye

func (this *Info) SendGoodbye()

func (*Info) SendHello

func (this *Info) SendHello(message *protobuf.Hello)

func (*Info) SendMedicineOffer

func (this *Info) SendMedicineOffer(message *protobuf.MedicineOffer)

func (*Info) SendMessageBroadcast

func (this *Info) SendMessageBroadcast(message *protobuf.MessageBroadcast)

func (*Info) SendMessageFrame

func (this *Info) SendMessageFrame(payloadBytes []byte, payloadType PayloadType)

func (*Info) SendMessageFramePacked

func (this *Info) SendMessageFramePacked(frame protobuf.MessageFrame)

func (*Info) SendPeerRequest

func (this *Info) SendPeerRequest()

func (*Info) SendPeerResponse

func (this *Info) SendPeerResponse(message protobuf.PeerResponse)

func (*Info) SendRequestResource

func (this *Info) SendRequestResource(message *protobuf.RequestBroadcast)

type MessageDescriptor

type MessageDescriptor struct {
	// contains filtered or unexported fields
}

type Node

type Node struct {
	Clients list.List

	PeerBlackList      list.List
	PeerBlackListMutex sync.Mutex

	CurrentMedicineOffersMutex  sync.Mutex
	CurrentMedicineOffers       map[string]protobuf.MedicineOffer_Medicine
	CurrentMedicineOffersRelays map[string]int

	IncomingMessageQueue  chan *MessageDescriptor
	BroadcastMessageQueue chan *protobuf.MessageFrame
	// contains filtered or unexported fields
}
var CurrentNode *Node

func (*Node) BroadcastSender

func (this *Node) BroadcastSender()

func (*Node) Connect

func (this *Node) Connect(ip net.IP, port uint32)

func (*Node) HandleConnection

func (this *Node) HandleConnection(info *Info)

func (*Node) HandleMessages

func (this *Node) HandleMessages()

func (*Node) Init

func (this *Node) Init(localCertFile, localKeyFile, caCertFile, serverName string, port, connectionLimit, bufferedMessages, maxOfferRelays uint32, discoveryInterval time.Duration)

func (*Node) Listen

func (this *Node) Listen()

func (*Node) PeerDiscovery

func (this *Node) PeerDiscovery()

func (*Node) TidyMedicineOffersRoutine

func (this *Node) TidyMedicineOffersRoutine()

type PayloadType

type PayloadType uint32
const (
	Hello               PayloadType = 0
	Goodbye             PayloadType = 1
	MessageBroadcast    PayloadType = 2
	RequestResource     PayloadType = 3
	PeerRequest         PayloadType = 4
	PeerResponse        PayloadType = 5
	MedicineOffer       PayloadType = 6
	FullMedicineRequest PayloadType = 7
)

type PeerPunish

type PeerPunish struct {
	Peer net.TCPAddr
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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