Some file server related things

This commit is contained in:
WolverinDEV
2020-07-30 11:40:03 +02:00
parent 7a974677fb
commit 3f700e79d3
14 changed files with 77 additions and 46 deletions
-1
View File
@@ -65,7 +65,6 @@ void VoiceClient::tick(const std::chrono::system_clock::time_point &time) {
this->connection->ping_handler().tick(time);
this->connection->packet_statistics().tick();
} else if(this->state == ConnectionState::INIT_LOW || this->state == ConnectionState::INIT_HIGH) {
/* FIXME: Handshake timeout */
auto last_command = this->connection->crypt_setup_handler().last_handled_command();
if(last_command.time_since_epoch().count() != 0) {
if(time - last_command > seconds(5)) {
+1 -4
View File
@@ -55,7 +55,7 @@ namespace ts {
friend class server::udp::CryptSetupHandler;
using ServerCommandExecutor = ts::server::server::udp::ServerCommandExecutor;
public:
VoiceClient(const std::shared_ptr<VoiceServer>& server,const sockaddr_storage*);
VoiceClient(const std::shared_ptr<VoiceServer>& server, const sockaddr_storage*);
~VoiceClient() override;
bool close_connection(const std::chrono::system_clock::time_point &timeout) override;
@@ -95,9 +95,6 @@ namespace ts {
protected:
virtual command_result handleCommand(Command &command) override;
private:
int socket = 0;
io::pktinfo_storage address_info;
void finalDisconnect();
bool final_disconnected = false;
@@ -1,11 +1,12 @@
#include <algorithm>
#include <log/LogUtils.h>
#include "../../server/VoiceServer.h"
#include <misc/memtracker.h>
#include <protocol/Packet.h>
#include <ThreadPool/Timer.h>
#include "VoiceClientConnection.h"
#include "VoiceClient.h"
#include "../../server/VoiceServer.h"
#include "./VoiceClientConnection.h"
#include "./VoiceClient.h"
//#define LOG_AUTO_ACK_AUTORESPONSE
@@ -74,12 +75,6 @@ void VoiceClientConnection::triggerWrite() {
this->current_client->voice_server->triggerWrite(dynamic_pointer_cast<VoiceClient>(this->current_client->_this.lock()));
}
#ifdef CLIENT_LOG_PREFIX
#undef CLIENT_LOG_PREFIX
#endif
#define CLIENT_LOG_PREFIX "[" << this->client->getPeerIp() << ":" << this->client->getPeerPort() << " | " << this->client->getDisplayName() << "]"
//Message handle methods
void VoiceClientConnection::handle_incoming_datagram(const pipes::buffer_view& buffer) {
ClientPacketParser packet_parser{buffer};
if(!packet_parser.valid())
@@ -216,6 +211,11 @@ void VoiceClientConnection::reset() {
this->packet_encoder_.reset();
}
void VoiceClientConnection::reset_remote_address() {
memset(&this->remote_address_, 0, sizeof(this->remote_address_));
memset(&this->remote_address_info_, 0, sizeof(this->remote_address_info_));
}
void VoiceClientConnection::send_packet(protocol::PacketType type, protocol::PacketFlag::PacketFlags flag, const void *payload, size_t payload_size) {
this->packet_encoder_.send_packet(type, flag, payload, payload_size);
}
@@ -300,5 +300,6 @@ void VoiceClientConnection::callback_ping_send_recovery(void *ptr_this) {
}
void VoiceClientConnection::callback_ping_timeout(void *ptr_this) {
(void) ptr_this;
/* doing nothing a packet resend failed will cause the client to disconnect */
}
@@ -65,10 +65,15 @@ namespace ts {
bool wait_empty_write_and_prepare_queue(std::chrono::time_point<std::chrono::system_clock> until = std::chrono::time_point<std::chrono::system_clock>());
void reset();
void reset_remote_address();
[[nodiscard]] std::string log_prefix();
[[nodiscard]] inline auto virtual_server_id() const { return this->virtual_server_id_; }
[[nodiscard]] inline const auto& remote_address() const { return this->remote_address_; }
[[nodiscard]] inline const auto& socket_id() const { return this->socket_id_; }
[[nodiscard]] inline auto& packet_statistics() { return this->packet_statistics_; }
[[nodiscard]] inline auto& packet_decoder() { return this->packet_decoder_; }
[[nodiscard]] inline auto& packet_encoder() { return this->packet_encoder_; }
@@ -84,6 +89,10 @@ namespace ts {
ServerId virtual_server_id_;
server::VoiceClient* current_client;
int socket_id_{0};
sockaddr_storage remote_address_{};
io::pktinfo_storage remote_address_info_{};
CryptHandler crypt_handler; /* access to CryptHandler is thread save */
server::client::PacketStatistics packet_statistics_{};