mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-24 00:41:30 +00:00
[Telnet] Automatically prune connections
This commit is contained in:
parent
4493ebebab
commit
aa8b0570d6
@ -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,13 @@ 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) {
|
||||
EQ::Net::DynamicPacket clear;
|
||||
clear.PutUInt8(0, 0);
|
||||
m_connection->Write((const char*)clear.Data(), clear.Length());
|
||||
});
|
||||
|
||||
auto addr = m_connection->RemoteIP();
|
||||
|
||||
SendLine(fmt::format("Establishing connection from: {0}:{1}", addr, m_connection->RemotePort()));
|
||||
@ -85,12 +92,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 +234,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);
|
||||
}
|
||||
|
||||
|
||||
@ -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];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user