core

package
v0.0.0-...-c39b484 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2014 License: ISC Imports: 27 Imported by: 0

Documentation

Overview

* Copyright (c) 2014 Marco Peereboom <marco@peereboom.us> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Index

Constants

View Source
const (
	RpcIdentity        = "identity"
	RpcConfirmation    = "confirmation"
	RpcSendFileCommand = "sendfile"
)
View Source
const (
	StateInvalid = 0
	StateQueued  = 1
	StateDenied  = 2
	StateAllowed = 100
)
View Source
const (
	ProfilePicture = "ProfilePicture"
)

Variables

View Source
var (
	State = map[int]string{
		StateInvalid: "Invalid",
		StateQueued:  "Queued",
		StateDenied:  "Denied",
		StateAllowed: "Allowed",
	}
)

Functions

func GenerateCert

func GenerateCert(cert, key, id, name string, json []byte) error

Types

type Client

type Client struct {
	Session
}

func NewClient

func NewClient(address, port string) (*Client, error)

type Confirmation

type Confirmation struct {
	LookingFor   string `json:"lookingfor"`
	MaxFrameSize int    `json:"marxframesize"`
	Error        string `json:"error"`
	State        int    `json:"state"`
}

type Core

type Core struct {
	*queueb.Queueb
	*dbglog.DbgLogger
	// contains filtered or unexported fields
}

func New

func New() (*Core, error)

func (*Core) DebugUi

func (c *Core) DebugUi(format string, args ...interface{})

func (*Core) NewClientSession

func (c *Core) NewClientSession(to string) (*Client, error)

establish a new session and return the session

func (*Core) ReceiveUi

func (c *Core) ReceiveUi() (*queueb.QueuebMessage, error)

func (*Core) SendCore

func (c *Core) SendCore(m interface{}) error

func (*Core) ServerCallback

func (c *Core) ServerCallback(s *Session)

func (*Core) Start

func (c *Core) Start()

type Exit

type Exit struct{}

signal queueb loop to exit

type MetaRecord

type MetaRecord struct {
	Version uint32    `json:"version"`
	Mime    string    `json:"mime"`
	Created time.Time `json:"created"`
}

This structure is saved alongside content with some interesting information. this needs lots more stuff, like encrypt at rest, keys it was sent with etc TODO this probably deserves it's own package

type Rpc

type Rpc struct {
	Command string      `json:"command"`
	Payload interface{} `json:"payload"`
}

type RpcSendFile

type RpcSendFile struct {
	Filename string `json:"filename"`
	Mime     string `json:"mime"`
	Content  []byte `json:"content"`
}

type SendFile

type SendFile struct {
	To       string
	Filename string
	Mime     string
}

signal core to send file

type Server

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

func NewServer

func NewServer(listenAddrs []string, cert, key string,
	callback func(*Session)) (*Server, error)

type Session

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

func (*Session) BecomeReady

func (s *Session) BecomeReady() (err error)

func (*Session) ConfirmationPhase

func (s *Session) ConfirmationPhase(c *Confirmation) (err error)

func (*Session) DefaultSession

func (s *Session) DefaultSession(pid *mcrypt.PublicIdentity) (err error)

func (*Session) IdentityPhase

func (s *Session) IdentityPhase(pid *mcrypt.PublicIdentity) (err error)

func (*Session) RpcReceive

func (s *Session) RpcReceive() (interface{}, error)

func (*Session) RpcSend

func (s *Session) RpcSend(command interface{}) error

func (*Session) SendFile

func (s *Session) SendFile(sf *SendFile) error

func (*Session) SessionPhase

func (s *Session) SessionPhase() (err error)

type Shutdown

type Shutdown struct{}

signal core to initiate shutdown

type Trust

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

func NewTrust

func NewTrust(path string) (*Trust, error)

func (*Trust) Add

func (t *Trust) Add(id *mcrypt.Identity, trustee *mcrypt.PublicIdentity,
	state int, freeToUse map[string]string, overwrite bool) error

Store public identity in database

func (*Trust) Close

func (t *Trust) Close()

func (*Trust) Get

func (t *Trust) Get(id *mcrypt.Identity,
	trustee *mcrypt.PublicIdentity) (*TrustRecord, error)

Get public identity from database

func (*Trust) GetAll

func (t *Trust) GetAll(id *mcrypt.Identity) ([]*TrustRecord, error)

Get all rust records.

func (*Trust) Update

func (t *Trust) Update(id *mcrypt.Identity, tr *TrustRecord) error

type TrustRecord

type TrustRecord struct {
	PublicIdentity *mcrypt.PublicIdentity
	Inserted       time.Time         // database insertion
	LastUpdate     time.Time         // record update
	State          int               // record state
	FreeToUse      map[string]string // User definable key value pairs
}

type UiConfirmIdentity

type UiConfirmIdentity struct {
	Message string
	Name    string
	Address string
}

signal UI to render dialog to confirm identity

type UiConfirmIdentityReply

type UiConfirmIdentityReply struct {
	Name        string
	Address     string
	Identifiers []*mcrypt.Identifier
	Error       error
}

signal core that the UI has obtained an identity

type UiConfirmPublicIdentity

type UiConfirmPublicIdentity struct {
	PublicIdentity *mcrypt.PublicIdentity
}

signal UI to render dialog to confirm public identity

type UiConfirmPublicIdentityReply

type UiConfirmPublicIdentityReply struct {
	PublicIdentity *mcrypt.PublicIdentity
	Error          error
	State          int
}

signal core that the UI has done something with the public identity

type UiPopup

type UiPopup struct {
	Title   string
	Message string
}

signal UI to render a popup

type UiReady

type UiReady struct{}

signal core that the UI is up and running

type UiRenderIdentity

type UiRenderIdentity struct {
	PublicIdentity *mcrypt.PublicIdentity
}

signal UI to render identity

type UiRenderTrust

type UiRenderTrust struct {
	TrustRecords []*TrustRecord
}

signal UI to render identity

type UpdateTrustRecord

type UpdateTrustRecord struct {
	TrustRecord *TrustRecord
}

signal core to update trust record

Jump to

Keyboard shortcuts

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