-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.h
More file actions
60 lines (46 loc) · 1.58 KB
/
Copy pathServer.h
File metadata and controls
60 lines (46 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// Created by stefano on 30/08/20.
//
#ifndef SERVERBACKUP_SERVER_H
#define SERVERBACKUP_SERVER_H
#include <boost/asio/ssl.hpp>
#include <boost/asio.hpp>
#include <boost/enable_shared_from_this.hpp>
#include "User.h"
#include "Session.h"
#include "SyncedFileServer.h"
#include <shared_mutex>
using boost::asio::ip::tcp;
class Server{
private:
tcp::acceptor acceptor_;
boost::asio::ssl::context context_;
const std::string file_users = "users_list.conf";
const std::string cert_password;
std::vector<char> forbiddenChars = {' ', '/', '\\', '.', '"', '[', ']', ':', ',', ';', '|', '=', '\n'};
std::shared_mutex mutex_map;
std::mutex mutex_users;
// struttura dati condivisa
std::unordered_map<std::string, User> users;
// struttura dati condivisa
std::unordered_map<std::string, std::shared_ptr<std::unordered_map<std::string, std::shared_ptr<SyncedFileServer>>>> synced_files;
void loadUsers();
void saveUsername(const User& user);
bool auth(User& user);
std::string get_password() ;
void create_empty_map(const std::string& username);
void loadMap(const std::string& username);
void loadMaps();
void do_handshake(const std::shared_ptr<Session>& session);
void do_auth(const std::shared_ptr<Session>& session);
public:
Server(boost::asio::io_context& io_context,
unsigned short port,
const std::string& crt,
const std::string& key,
std::string cert_password,
const std::string& dhTmp
);
void do_accept();
};
#endif //SERVERBACKUP_SERVER_H