From 23120bcde6718da1d73dccf0507b0a8722d71ed5 Mon Sep 17 00:00:00 2001 From: KimLS Date: Fri, 14 Oct 2016 21:19:14 -0700 Subject: [PATCH] Added keep alive to relay link for backwards compat with emu_tcp_connection (they disconnect you after about 45 seconds if you don't send keep alives even if the tcp connection is fine...) --- common/net/relay_link.cpp | 12 +++++++++++- common/net/relay_link.h | 2 ++ world/queryserv.cpp | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/common/net/relay_link.cpp b/common/net/relay_link.cpp index 5d841f64b..95083e3e7 100644 --- a/common/net/relay_link.cpp +++ b/common/net/relay_link.cpp @@ -5,7 +5,8 @@ #include "../servertalk.h" EQ::Net::RelayLink::RelayLink(const std::string &addr, int port, const std::string &identifier, const std::string &password) - : m_timer(std::unique_ptr(new EQ::Timer(250, true, std::bind(&EQ::Net::RelayLink::Connect, this)))) + : m_timer(std::unique_ptr(new EQ::Timer(250, true, std::bind(&EQ::Net::RelayLink::Connect, this)))), + m_keepalive(std::unique_ptr(new EQ::Timer(5000, true, std::bind(&EQ::Net::RelayLink::SendKeepAlive, this)))) { m_established = false; m_connecting = false; @@ -224,3 +225,12 @@ void EQ::Net::RelayLink::OnAuthFailed(const EQ::Net::Packet &p) m_connection->Disconnect(); } } + +void EQ::Net::RelayLink::SendKeepAlive() +{ + if (!m_connection) + return; + + EQ::Net::WritablePacket p; + SendPacket(0, p); +} diff --git a/common/net/relay_link.h b/common/net/relay_link.h index 62dc99eb7..1add3b6ff 100644 --- a/common/net/relay_link.h +++ b/common/net/relay_link.h @@ -32,8 +32,10 @@ namespace EQ void SendInternal(const EQ::Net::Packet &p); void SendPassword(); void OnAuthFailed(const EQ::Net::Packet &p); + void SendKeepAlive(); std::unique_ptr m_timer; + std::unique_ptr m_keepalive; std::string m_addr; std::string m_identifier; std::string m_password; diff --git a/world/queryserv.cpp b/world/queryserv.cpp index bf1af1e2e..9a5c3e268 100644 --- a/world/queryserv.cpp +++ b/world/queryserv.cpp @@ -69,7 +69,7 @@ bool QueryServConnection::Process() { struct in_addr in; in.s_addr = GetIP(); - Log.Out(Logs::Detail, Logs::QS_Server, "QueryServ authorization failed."); + Log.Out(Logs::General, Logs::QS_Server, "QueryServ authorization failed."); auto pack = new ServerPacket(ServerOP_ZAAuthFailed); SendPacket(pack); delete pack; @@ -82,6 +82,7 @@ bool QueryServConnection::Process() Log.Out(Logs::Detail, Logs::QS_Server,"**WARNING** You have not configured a world shared key in your config file. You should add a STRING element to your element to prevent unauthroized zone access."); authenticated = true; } + delete pack; continue; }