GBServerDatabase

package
v0.0.0-...-0e4a5a4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2015 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_STORAGE_BYTES = 1073741824 // 1 gigabyte

)

Variables

This section is empty.

Functions

func AddPathToAllOtherClients

func AddPathToAllOtherClients(UserCollection *mgo.Collection, username string, Source_RSA_Public_Key string, metadata FileMetadata, operation_int int) error

AddPathToAllOtherClients queues the files to be sent to all other clients.

func AddPathToReceive

func AddPathToReceive(UserCollection *mgo.Collection, username string, RSA_Public_Key string, metadata FileMetadata, operation_int int) error

AddPathToReceive queues a file to be sent to the client.

func ClientExists

func ClientExists(UserCollection *mgo.Collection, username string, RSA_Public_Key string) (bool, error)

ClientExists returns true if the given client has already been used by the user.

func EmailExists

func EmailExists(UserCollection *mgo.Collection, email string) bool

UsernameExists checks if the given email already exists in the collection.

func GetActivationKey

func GetActivationKey(UserCollection *mgo.Collection, username string) (activation_key string, err error)

GetActivationKey returns the activation key for the given account.

func InitClient

func InitClient(UserCollection *mgo.Collection, username string, RSA_Public_Key string) (int64, error)

func InsertClient

func InsertClient(UserCollection *mgo.Collection, username string, client Client) error

InsertClient inserts a client with the given information into the clients list of the user.

func RemovePathFromClient

func RemovePathFromClient(UserCollection *mgo.Collection, username string, RSA_Public_Key string, path string) error

AddPathToReceive removes a file from the queue.

func SignupUser

func SignupUser(UserCollection, MetadataCollection *mgo.Collection, username, email, password_hash string) error

SignupUser creates a user with the given username, email, and password hash.

func UpdateCurrentlyBeingUsed

func UpdateCurrentlyBeingUsed(UserCollection *mgo.Collection, username string, RSA_Public_Key string, currently_being_used bool) error

UpdateCurrentlyBeingUsed sets the current state of the currently_being_used variable to the value given.

func UpdateLastAccessedTime

func UpdateLastAccessedTime(UserCollection *mgo.Collection, username string, public_key string, timeout int64) error

UpdateLastAccessedTime updates the last accessed time of the client.

func UsernameExists

func UsernameExists(UserCollection *mgo.Collection, username string) bool

UsernameExists checks if the given username already exists in the collection.

func ValidatePassword

func ValidatePassword(collection *mgo.Collection, username string, password string) (bool, error)

ValidatePassword checks if a given cleartext password matches the hash stored in the server.

Types

type Client

type Client struct {
	Public_Key           string      `bson: "public_key"`
	Currently_being_used bool        `bson: "currently_being_used"`
	Last_accessed        int64       `bson: "last_accessed"`
	Files_to_receive     []FileQueue `bson: "files_to_receive"`
}

Client stores the name, IP address, and usage time of a computer.

func GetAllClients

func GetAllClients(UserCollection *mgo.Collection, username string) ([]Client, error)

GetAllClients returns a list of all clients for a user.

func GetClient

func GetClient(UserCollection *mgo.Collection, username, RSA_Public_Key string) (Client, error)

GetClient returns a specific client for a given RSA public key.

type ClientContainer

type ClientContainer struct {
	Clients []Client `bson: "client"`
}

A container used for internal functions.

type FileMetadata

type FileMetadata struct {
	Path              string `bson: "path"`
	Is_dir            bool   `bson: "is_dir"`
	Modification_time int64  `bson: "modification_time"`
	Size              int64  `bson: "size"`
}

FileMetadata stores the metadata for each file.

type FileQueue

type FileQueue struct {
	Path              string `bson: "path"`
	Is_dir            bool   `bson: "is_dir"`
	Modification_time int64  `bson: "modification_time"`
	Size              int64  `bson: "size"`
	Operation_int     int    `bson: "operation_int"`
}

FileQueue is the information the server needs to send a file to client.

type User

type User struct {
	// Auth info
	Username      string `bson: "username"`
	Password_hash string `bson: "password_hash"`
	Email         string `bson: "email"`

	// A key that symmetrically encrypts the user's encryption key.
	// Sent to user over TLS on session start, decrypts their file key.
	Activation_key string `bson: "activation_key"`

	// Usage info
	Clients               []Client `bson: "clients"`
	Current_storage_usage int64    `bson: "current_storage_usage"`
	Max_storage_possible  int64    `bson: "max_storage_possible"`
}

User (collection item) specifies the information kept for each user.

type UserFiles

type UserFiles struct {
	Username           string         `bson: "username"`
	User_file_metadata []FileMetadata `bson: "user_file_metadata"`
}

UserFiles stores all the metadata for a user's files.

Jump to

Keyboard shortcuts

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