Compare commits

...

2 Commits

Author SHA1 Message Date
Akkadius 6b65dd3a00 Update console_server_connection.cpp 2024-12-14 21:50:53 -06:00
Akkadius aa8b0570d6 [Telnet] Automatically prune connections 2024-12-14 21:16:14 -06:00
2 changed files with 12 additions and 3 deletions
+10 -3
View File
@@ -4,6 +4,7 @@
#include "../eqemu_logsys.h"
#include "../servertalk.h"
#include "../rulesys.h"
#include "../event/timer.h"
#include <fmt/format.h>
EQ::Net::ConsoleServerConnection::ConsoleServerConnection(ConsoleServer *parent, std::shared_ptr<TCPConnection> connection)
@@ -21,7 +22,11 @@ EQ::Net::ConsoleServerConnection::ConsoleServerConnection(ConsoleServer *parent,
m_connection->OnDisconnect(std::bind(&ConsoleServerConnection::OnDisconnect, this, std::placeholders::_1));
m_connection->Start();
ClearBuffer();
m_keepalive = std::make_unique<EQ::Timer>(1000, true, [this](EQ::Timer *t) {
m_connection->Write("", 0);
});
auto addr = m_connection->RemoteIP();
SendLine(fmt::format("Establishing connection from: {0}:{1}", addr, m_connection->RemotePort()));
@@ -85,12 +90,12 @@ void EQ::Net::ConsoleServerConnection::QueueMessage(const std::string &msg)
}
else {
std::string cmd(m_line, m_line + m_cursor);
size_t len = m_user.length() + 2 + cmd.length();
for (size_t i = 0; i < len; ++i) {
Send("\x08");
}
if (msg.length() < cmd.length()) {
Send(msg);
size_t blank_spaces = 2 + cmd.length() - msg.length();
@@ -227,6 +232,8 @@ void EQ::Net::ConsoleServerConnection::OnRead(TCPConnection *c, const unsigned c
void EQ::Net::ConsoleServerConnection::OnDisconnect(TCPConnection *c)
{
LogInfo("Console connection disconnected");
m_parent->ConnectionDisconnected(this);
}
+2
View File
@@ -1,6 +1,7 @@
#pragma once
#include "tcp_server.h"
#include "../event/timer.h"
#include <memory>
#include <map>
@@ -58,6 +59,7 @@ namespace EQ
int m_user_id;
int m_admin;
bool m_accept_messages;
std::unique_ptr<EQ::Timer> m_keepalive;
size_t m_cursor;
char m_line[MaxConsoleLineLength];