revert
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -227,6 +227,11 @@ public:
|
||||
stop_type &stop_requested) const
|
||||
-> bool override;
|
||||
|
||||
[[nodiscard]] auto make_request(const curl::requests::http_post &post_file,
|
||||
long &response_code,
|
||||
stop_type &stop_requested) const
|
||||
-> bool override;
|
||||
|
||||
[[nodiscard]] auto make_request(const curl::requests::http_put_file &put_file,
|
||||
long &response_code,
|
||||
stop_type &stop_requested) const
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "comm/curl/requests/http_delete.hpp"
|
||||
#include "comm/curl/requests/http_get.hpp"
|
||||
#include "comm/curl/requests/http_head.hpp"
|
||||
#include "comm/curl/requests/http_post.hpp"
|
||||
#include "comm/curl/requests/http_put_file.hpp"
|
||||
#include "types/repertory.hpp"
|
||||
|
||||
@@ -49,6 +50,11 @@ public:
|
||||
stop_type &stop_requested) const
|
||||
-> bool = 0;
|
||||
|
||||
[[nodiscard]] virtual auto make_request(const curl::requests::http_post &post,
|
||||
long &response_code,
|
||||
stop_type &stop_requested) const
|
||||
-> bool = 0;
|
||||
|
||||
[[nodiscard]] virtual auto
|
||||
make_request(const curl::requests::http_put_file &put_file,
|
||||
long &response_code, stop_type &stop_requested) const
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -30,8 +30,7 @@ namespace repertory {
|
||||
class packet_client final {
|
||||
private:
|
||||
struct client final {
|
||||
explicit client(boost::asio::io_context &ctx) : nonce(""), socket(ctx) {}
|
||||
|
||||
explicit client(boost::asio::io_context &ctx) : socket(ctx) {}
|
||||
std::string nonce;
|
||||
tcp::socket socket;
|
||||
};
|
||||
@@ -43,34 +42,40 @@ public:
|
||||
|
||||
~packet_client();
|
||||
|
||||
packet_client(const packet_client &) = delete;
|
||||
packet_client(packet_client &&) = delete;
|
||||
auto operator=(const packet_client &) -> packet_client & = delete;
|
||||
auto operator=(packet_client &&) -> packet_client & = delete;
|
||||
|
||||
private:
|
||||
boost::asio::io_context io_context_;
|
||||
const std::string host_name_or_ip_;
|
||||
const std::uint8_t max_connections_;
|
||||
const std::uint16_t port_;
|
||||
const std::uint16_t receive_timeout_;
|
||||
const std::uint16_t send_timeout_;
|
||||
const std::string encryption_token_;
|
||||
std::string host_name_or_ip_;
|
||||
std::uint8_t max_connections_;
|
||||
std::uint16_t port_;
|
||||
std::uint16_t receive_timeout_;
|
||||
std::uint16_t send_timeout_;
|
||||
std::string encryption_token_;
|
||||
std::string unique_id_;
|
||||
|
||||
bool allow_connections_ = true;
|
||||
private:
|
||||
bool allow_connections_{true};
|
||||
boost::asio::ip::basic_resolver<boost::asio::ip::tcp>::results_type
|
||||
resolve_results_;
|
||||
std::mutex clients_mutex_;
|
||||
std::vector<std::shared_ptr<client>> clients_;
|
||||
|
||||
private:
|
||||
void close(client &c) const;
|
||||
static void close(client &cli);
|
||||
|
||||
void close_all();
|
||||
|
||||
void connect(client &c);
|
||||
void connect(client &cli);
|
||||
|
||||
[[nodiscard]] auto get_client() -> std::shared_ptr<client>;
|
||||
|
||||
void put_client(std::shared_ptr<client> &c);
|
||||
void put_client(std::shared_ptr<client> &cli);
|
||||
|
||||
[[nodiscard]] auto read_packet(client &c, packet &response)
|
||||
[[nodiscard]] auto read_packet(client &cli, packet &response)
|
||||
-> packet::error_type;
|
||||
|
||||
void resolve();
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -45,6 +45,12 @@ public:
|
||||
|
||||
~packet_server();
|
||||
|
||||
public:
|
||||
packet_server(const packet_server &) = delete;
|
||||
packet_server(packet_server &&) = delete;
|
||||
auto operator=(const packet_server &) -> packet_server & = delete;
|
||||
auto operator=(packet_server &&) -> packet_server & = delete;
|
||||
|
||||
private:
|
||||
struct connection {
|
||||
connection(boost::asio::io_service &io_service, tcp::acceptor &acceptor_)
|
||||
@@ -56,11 +62,11 @@ private:
|
||||
std::string client_id;
|
||||
std::string nonce;
|
||||
|
||||
void generate_nonce() { nonce = utils::generate_random_string(256u); }
|
||||
void generate_nonce() { nonce = utils::generate_random_string(256U); }
|
||||
};
|
||||
|
||||
private:
|
||||
const std::string encryption_token_;
|
||||
std::string encryption_token_;
|
||||
closed_callback closed_;
|
||||
message_handler_callback message_handler_;
|
||||
boost::asio::io_context io_context_;
|
||||
@@ -70,21 +76,22 @@ private:
|
||||
std::unordered_map<std::string, std::uint32_t> connection_lookup_;
|
||||
|
||||
private:
|
||||
void add_client(connection &c, const std::string &client_id);
|
||||
void add_client(connection &conn, const std::string &client_id);
|
||||
|
||||
void initialize(const uint16_t &port, uint8_t pool_size);
|
||||
|
||||
void listen_for_connection(tcp::acceptor &acceptor);
|
||||
|
||||
void on_accept(std::shared_ptr<connection> c, boost::system::error_code ec);
|
||||
void on_accept(std::shared_ptr<connection> conn,
|
||||
boost::system::error_code err);
|
||||
|
||||
void read_header(std::shared_ptr<connection> c);
|
||||
void read_header(std::shared_ptr<connection> conn);
|
||||
|
||||
void read_packet(std::shared_ptr<connection> c, std::uint32_t data_size);
|
||||
void read_packet(std::shared_ptr<connection> conn, std::uint32_t data_size);
|
||||
|
||||
void remove_client(connection &c);
|
||||
void remove_client(connection &conn);
|
||||
|
||||
void send_response(std::shared_ptr<connection> c,
|
||||
void send_response(std::shared_ptr<connection> conn,
|
||||
const packet::error_type &result, packet &response);
|
||||
};
|
||||
} // namespace repertory
|
||||
|
Reference in New Issue
Block a user