core

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

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

Go to latest
Published: Oct 29, 2015 License: MIT Imports: 23 Imported by: 2

README

Core

Core library of the Tinzenite software suite.

Documentation

Index

Constants

View Source
const (
	LOCAL  = ".LOCAL"
	REMOTE = ".REMOTE"
	MODEL  = ".MODEL"
)

Naming of conflicting files.

TODO: this should be improved because it can quickly cause multi merge problems... Consider using name of peers and version numbers.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authentication

type Authentication struct {
	User    string    // hash of username
	Dirname string    // official name of directory
	DirID   string    // random id of directory
	Secure  []byte    // box encrypted private and public keys with password
	Nonce   *[24]byte // nonce for Secure
	// contains filtered or unexported fields
}

Authentication file.

func (*Authentication) BuildAuthentication

func (a *Authentication) BuildAuthentication(number int64) (*shared.AuthenticationMessage, error)

BuildAuthentication takes the given number and returns the valid AuthenticationMessage to send to the other side.

func (*Authentication) Decrypt

func (a *Authentication) Decrypt(encrypted []byte) ([]byte, error)

Decrypt returns the unencrypted data, given that the keys are valid.

func (*Authentication) Encrypt

func (a *Authentication) Encrypt(data []byte) ([]byte, error)

Encrypt returns the data in encrypted form, given that the keys are valid.

func (*Authentication) ReadAuthentication

func (a *Authentication) ReadAuthentication(msg *shared.AuthenticationMessage) (int64, error)

ReadAuthentication takes an AuthenticationMessage and decrypts it to return the contained number.

func (*Authentication) StoreTo

func (a *Authentication) StoreTo(path string) error

StoreTo the given path the authentication file to disk as json.

type PeerValidation

type PeerValidation func(address string, requestsTrust bool)

PeerValidation will be called if a peer tries to connect to this peer. The return value will state whether the user accepts the connection.

type Tinzenite

type Tinzenite struct {
	Path string
	// contains filtered or unexported fields
}

Tinzenite is the struct on which all important operations should be called.

func CreateTinzenite

func CreateTinzenite(dirname, dirpath, peername, username, password string) (*Tinzenite, error)

CreateTinzenite makes a directory a new Tinzenite directory. Will return error if already so.

func LoadTinzenite

func LoadTinzenite(dirpath, password string) (*Tinzenite, error)

LoadTinzenite will try to load the given directory path as a Tinzenite directory. If not one it won't work: use CreateTinzenite to create a new peer.

func (*Tinzenite) Address

func (t *Tinzenite) Address() (string, error)

Address of this Tinzenite peer that can be used to connect to.

func (*Tinzenite) AllowPeer

func (t *Tinzenite) AllowPeer(address string) error

AllowPeer should be called if a connection request is to be accepted after the user has verified it. NOTE: friend requests should be replied to ASAP, since they are NOT persistantly stored!

func (*Tinzenite) Close

func (t *Tinzenite) Close()

Close cleanly stores everything and shuts Tinzenite down.

func (*Tinzenite) DisconnectPeer

func (t *Tinzenite) DisconnectPeer(peerName string)

DisconnectPeer does exactly that. NOTE: this is a passive action and doesn't do anything except remove the peer from the network. The peer is not further notified.

TODO: maybe not use name but Identification? TODO: when will other peers remove it? They need to remove the contact info from the channel... FIXME

func (*Tinzenite) Name

func (t *Tinzenite) Name() string

Name of this Tinzenite peer.

func (*Tinzenite) PrintStatus

func (t *Tinzenite) PrintStatus() string

PrintStatus returns a formatted string of the peer status.

func (*Tinzenite) RegisterPeerValidation

func (t *Tinzenite) RegisterPeerValidation(f PeerValidation)

RegisterPeerValidation registers a callback.

func (*Tinzenite) Store

func (t *Tinzenite) Store() error

Store the tinzenite directory structure to disk. Will resolve all important objects and store them so that it can later be reloaded. NOTE: Will not update the full model, so be sure to have called Update() to guarantee an up to date save.

func (*Tinzenite) SyncEncrypted

func (t *Tinzenite) SyncEncrypted() error

SyncEncrypted tries to lock available encrypted peers. If successful will update them to the current state while updating any outstanding issues.

TODO FIXME maybe this should be included in sync remote. Although there is something to be said that it is the job of the client to handle this intelligently...

func (*Tinzenite) SyncLocal

func (t *Tinzenite) SyncLocal() error

SyncLocal changes. Will send updates to connected peers but not synchronize with other peers.

func (*Tinzenite) SyncRemote

func (t *Tinzenite) SyncRemote() error

SyncRemote updates first locally and then sync remotely if other peers are connected. NOTE: Both sync methods can block for a potentially long time, especially when first run!

Jump to

Keyboard shortcuts

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