- SQLITE3:
sudo apt-get install libsqlite3-dev
- CRYPTOPP:
sudo apt-get install libcrypto++-dev libcrypto++-doc libcrypto++-utils
/client_folder
/DB
/executable_dir
/client_directory
PDS_Project_Client (executable)
/Log
log.txt
/server_folder
/DB
/users
/executable_dir
/server_directory
PDS_Project_Server (executable)
/Log
log.txt
- DB: contains all db files (e.g. user1.db, user2.db, ...)
- executable_dir: contains the executable file and client_directory/server_directory that contains users data
- Log: contains the log file
- PDS_Project_Server:
PORT
(e.g. 5111) - PDS_Project_Client:
PORT username password FETCH/RESTORE
(e.g. 5111 user1 pass FETCH)The program can be executed in two different modes:
- FETCH: replicates all user actions on client directory in server directory
- RESTORE: delete all local files and restore all data contained in the server directory
Two db types:
- username.db
- directory (path, name)
- file (path, name, hash)
- users.db
- users (username, password, salt)
The field password of users is not the real password but the salted digest computed with the library cryptopp
-
FETCH MODE:
CLIENT SERVER CONNECT username password mode -> <- CONNECT-OK CONNECT-OK -> if (!correct password) <- wrong username or password return else <- DIGEST server_db_digest endif if (client_db_digest == server_db_digest) Database up to date -> <- server_db_ok else GET-DB -> <- sendFile(server_db) ... compare the two databases ... for each different directory: DIR path action -> <- DONE for each different file: FILE path action -> if (action == 'erased') <- DONE else <- READY endif if (action != 'erased') FILE path length_file -> <- OK sendFile(path) -> <- DONE endif endif ... starting folder monitoring ...
-
RESTORE MODE: like FETCH MODE but the file/directory transfering is in the opposite direction.
This library contains primitives to send and receive messages and files between two hosts.
These two classes are used to represent a simplified view of the filesystem with some more addons (e.g. file digest).
These two classes are used to perform a TCP connection between two hosts. There is a customizable timeout for each message.
This library is used to compute the digest of a file or a string.
This library contains the Logger class that is used to write on the log file.
This library is used to monitor a specific directory in the client space and react to each modification.
This library is used to perform queries on databases using SQLITE3.
This library contains definitions of different types of exception:
- general_exception
- socket_exception
- filesystem_exception (derived from general_exception)
- database_exception (derived from general_exception)
At the beginning the client process performs a fork():
- father: display on console the child status received from the pipe (e.g. 'connection succeed', e.g. 'wrong username or password'). It is used to make the child a zombie process
- child: executes the main program and sends its status via pipe
At the beginning the server process performs a fork():
- father: dies (it is used to make the child a zombie process)
- child: executes the main program
- main thread: executes the main program and creates the below threads
- FileWatcher thread: setup and starts the FileWatcher
- monitor thread: monitors the status of the FileWatcher and opens or closes server connection
- main thread: listens on socket port and creates the below threads
- user thread: a thread is instantiated for each user that connects to the server (until the number of connected users reach a threshold). This thread executes the main program.