decnet

package module
v0.0.0-...-f27ba7b Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: GPL-3.0 Imports: 20 Imported by: 0

README

DECNET

Decentralize network works on TCP

This package works as a protocol that finds other nodes and make comunicate to other nodes with same porotocol without any server.

Documentation

Index

Constants

View Source
const (
	TouchAction  = "Touch"
	RejectAction = "Rejected"
)
View Source
const (
	TouchAction  = "Touch"
	RejectAction = "Rejected"
)

Variables

View Source
var File_packet_proto protoreflect.FileDescriptor

Functions

func Encrypt

func Encrypt(publicKey *rsa.PublicKey, plainText []byte) ([]byte, error)

Types

type Connection

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

func New

func New(opt Options, key *Key) (*Connection, error)

func (*Connection) AddHandler

func (c *Connection) AddHandler(action string, handler HandlerFunc)

func (*Connection) AddReplayHandler

func (c *Connection) AddReplayHandler(action string, handler HandlerFunc)

func (*Connection) Send

func (c *Connection) Send(listener string, body io.Reader, action string) error

func (*Connection) Start

func (c *Connection) Start()

type Context

type Context struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Context) Body

func (ctx *Context) Body() io.Reader

func (*Context) Replay

func (ctx *Context) Replay(message string) error

type HandlerFunc

type HandlerFunc func(c *Context) error

type Key

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

func GenerateKey

func GenerateKey() (*Key, error)

func (*Key) Decrypt

func (k *Key) Decrypt(encryptedMessage []byte) ([]byte, error)

func (Key) PrivateKeyToPemString

func (k Key) PrivateKeyToPemString() string

func (Key) PublicKeyToPemString

func (k Key) PublicKeyToPemString() string

type Options

type Options struct {
	Port        int
	StartPoints []string
	DBPath      string
}

type Packet

type Packet struct {
	Action    string   `protobuf:"bytes,1,opt,name=Action,proto3" json:"Action,omitempty"`
	Listener  int32    `protobuf:"varint,2,opt,name=Listener,proto3" json:"Listener,omitempty"`
	Headers   []string `protobuf:"bytes,5,rep,name=Headers,proto3" json:"Headers,omitempty"`
	Sender    string   `protobuf:"bytes,6,opt,name=sender,proto3" json:"sender,omitempty"`
	Completed bool     `protobuf:"varint,7,opt,name=completed,proto3" json:"completed,omitempty"`
	Body      []byte   `protobuf:"bytes,8,opt,name=Body,proto3" json:"Body,omitempty"`
	Created   int64    `protobuf:"varint,9,opt,name=created,proto3" json:"created,omitempty"`
	// contains filtered or unexported fields
}

func (*Packet) Descriptor deprecated

func (*Packet) Descriptor() ([]byte, []int)

Deprecated: Use Packet.ProtoReflect.Descriptor instead.

func (*Packet) GetAction

func (x *Packet) GetAction() string

func (*Packet) GetBody

func (x *Packet) GetBody() []byte

func (*Packet) GetCompleted

func (x *Packet) GetCompleted() bool

func (*Packet) GetCreated

func (x *Packet) GetCreated() int64

func (*Packet) GetHeaders

func (x *Packet) GetHeaders() []string

func (*Packet) GetListener

func (x *Packet) GetListener() int32

func (*Packet) GetSender

func (x *Packet) GetSender() string

func (*Packet) ProtoMessage

func (*Packet) ProtoMessage()

func (*Packet) ProtoReflect

func (x *Packet) ProtoReflect() protoreflect.Message

func (*Packet) Reset

func (x *Packet) Reset()

func (*Packet) String

func (x *Packet) String() string

Jump to

Keyboard shortcuts

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