agent

package
v0.0.0-...-4f831cf Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OK        MsgType = 0
	Error             = 1
	AddKey            = 2
	Question          = 3
	Answer            = 4
	ListKeys          = 5
	Keys              = 6
	Decrypt           = 7
	Decrypted         = 8
)

Variables

View Source
var MsgTypeNames = map[MsgType]string{
	OK:        "ok",
	Error:     "error",
	AddKey:    "add-key",
	Question:  "question",
	Answer:    "answer",
	ListKeys:  "list-keys",
	Keys:      "keys",
	Decrypt:   "decrypt",
	Decrypted: "decrypted",
}

Functions

func SendMessage

func SendMessage(conn net.Conn, msg Msg) error

Types

type Client

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

func NewClient

func NewClient(path string) (*Client, error)

func (*Client) AddKey

func (c *Client) AddKey(key identity.Key) error

func (*Client) ListKeys

func (c *Client) ListKeys() ([]identity.PrivateKey, error)

type Connection

type Connection struct {
	C chan Msg
	// contains filtered or unexported fields
}

func (*Connection) SendDecrypted

func (c *Connection) SendDecrypted(data []byte) error

func (*Connection) SendError

func (c *Connection) SendError(msg string) error

func (*Connection) SendKeys

func (c *Connection) SendKeys(keys []KeyInfo) error

func (*Connection) SendOK

func (c *Connection) SendOK() error

type KeyInfo

type KeyInfo struct {
	Name      string
	Type      identity.KeyType
	Size      int
	ID        string
	PublicKey []byte
}

type Msg

type Msg interface {
	SetType(t MsgType)
	Type() MsgType
}

func RPC

func RPC(conn net.Conn, msg Msg) (Msg, error)

func ReceiveMessage

func ReceiveMessage(conn net.Conn) (Msg, error)

type MsgAddKey

type MsgAddKey struct {
	MsgHdr
	Data []byte
}

type MsgAnswer

type MsgAnswer struct {
	MsgHdr
	Answers []string
}

type MsgDecrypt

type MsgDecrypt struct {
	MsgHdr
	KeyID string
	Data  []byte
}

type MsgDecrypted

type MsgDecrypted struct {
	MsgHdr
	Data []byte
}

type MsgError

type MsgError struct {
	MsgHdr
	Message string
}

type MsgHdr

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

func (*MsgHdr) SetType

func (hdr *MsgHdr) SetType(t MsgType)

func (*MsgHdr) String

func (hdr *MsgHdr) String() string

func (*MsgHdr) Type

func (hdr *MsgHdr) Type() MsgType

type MsgKeys

type MsgKeys struct {
	MsgHdr
	Keys []KeyInfo
}

type MsgListKeys

type MsgListKeys struct {
	MsgHdr
}

type MsgOK

type MsgOK struct {
	MsgHdr
}

type MsgQuestion

type MsgQuestion struct {
	MsgHdr
	Questions []string
	Echos     []bool
}

type MsgType

type MsgType uint8

func (MsgType) String

func (t MsgType) String() string

type Server

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

func NewServer

func NewServer(listener net.Listener) *Server

func (*Server) Accept

func (s *Server) Accept() (*Connection, error)

Jump to

Keyboard shortcuts

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