Documentation ¶
Index ¶
- Constants
- type Authentication
- func (a *Authentication) BuildAuthentication(number int64) (*shared.AuthenticationMessage, error)
- func (a *Authentication) Decrypt(encrypted []byte) ([]byte, error)
- func (a *Authentication) Encrypt(data []byte) ([]byte, error)
- func (a *Authentication) ReadAuthentication(msg *shared.AuthenticationMessage) (int64, error)
- func (a *Authentication) StoreTo(path string) error
- type PeerValidation
- type Tinzenite
- func (t *Tinzenite) Address() (string, error)
- func (t *Tinzenite) AllowPeer(address string) error
- func (t *Tinzenite) Close()
- func (t *Tinzenite) DisconnectPeer(peerName string)
- func (t *Tinzenite) Name() string
- func (t *Tinzenite) PrintStatus() string
- func (t *Tinzenite) RegisterPeerValidation(f PeerValidation)
- func (t *Tinzenite) Store() error
- func (t *Tinzenite) SyncEncrypted() error
- func (t *Tinzenite) SyncLocal() error
- func (t *Tinzenite) SyncRemote() error
Constants ¶
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 ¶
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 ¶
CreateTinzenite makes a directory a new Tinzenite directory. Will return error if already so.
func LoadTinzenite ¶
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) AllowPeer ¶
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 ¶
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) PrintStatus ¶
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 ¶
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 ¶
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 ¶
SyncLocal changes. Will send updates to connected peers but not synchronize with other peers.
func (*Tinzenite) SyncRemote ¶
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!