Some file server related things
This commit is contained in:
@@ -694,8 +694,8 @@ bool ConnectedClient::handle_text_command(
|
||||
if(!vc) return false;
|
||||
|
||||
send_message(_this.lock(), "I lost your IP address. I'm so dump :)");
|
||||
vc->connection->reset_remote_address();
|
||||
memset(&vc->remote_address, 0, sizeof(vc->remote_address));
|
||||
memset(&vc->address_info, 0, sizeof(vc->address_info));
|
||||
send_message(_this.lock(), "Hey, we got the address back");
|
||||
return true;
|
||||
} else if(TARG(0, "fb")) {
|
||||
|
||||
@@ -2127,11 +2127,11 @@ command_result ConnectedClient::handleCommandLogView(ts::Command& cmd) {
|
||||
this->sendCommand(result);
|
||||
#else
|
||||
constexpr static std::array<std::string_view, 5> log_output{
|
||||
"The command 'logview' is not supported anymore.",
|
||||
"In order to lookup the server actions use 'logquery'.",
|
||||
"",
|
||||
"located at your TeaSpeak installation folder. All logs could be found there.",
|
||||
"If you need to lookup the TeaSpeak - Server logs, please visit the 'logs/' folder,",
|
||||
"located at your TeaSpeak installation folder. All logs could be found there."
|
||||
"",
|
||||
"In order to lookup the server actions use 'logquery'.",
|
||||
"The command 'logview' is not supported anymore."
|
||||
};
|
||||
|
||||
command_builder result{this->getExternalType() == ClientType::CLIENT_TEAMSPEAK ? "notifyserverlog" : ""};
|
||||
@@ -2141,13 +2141,13 @@ command_result ConnectedClient::handleCommandLogView(ts::Command& cmd) {
|
||||
size_t index{0};
|
||||
if(lagacy) {
|
||||
for(const auto& message : log_output) {
|
||||
std::string line{"2020-06-27 00:00.0000|CRITICAL|Server Instance | |"};
|
||||
std::string line{"2020-06-27 00:00.000" + std::to_string(index) + "|CRITICAL|Server Instance | |"};
|
||||
line += message;
|
||||
result.put_unchecked(index++, "l", line);
|
||||
}
|
||||
} else {
|
||||
for(const auto& message : log_output) {
|
||||
std::string line{"[2020-06-27 00:00:00][ERROR] "};
|
||||
std::string line{"[2020-06-27 00:00:0" + std::to_string(index) + "][ERROR] "};
|
||||
line += message;
|
||||
result.put_unchecked(index++, "l", line);
|
||||
}
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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_{};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user