diff options
author | Adam <Adam@anope.org> | 2017-06-22 17:59:58 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2017-06-22 17:59:58 -0400 |
commit | 2b6c5833bb6cd6b1e21bb66a0ebbc6a6e3e86767 (patch) | |
tree | 4f3b8b2dd11e2d80c62db732d0e803978ed440c8 /include | |
parent | 46acfd0490bee851ef82897fa6a7686f64b2544e (diff) |
Ping uplink occasionally and disconnect if no pong is received
Diffstat (limited to 'include')
-rw-r--r-- | include/modules/protocol/rfc1459.h | 8 | ||||
-rw-r--r-- | include/uplink.h | 12 |
2 files changed, 19 insertions, 1 deletions
diff --git a/include/modules/protocol/rfc1459.h b/include/modules/protocol/rfc1459.h index 54c4bada5..8780892e0 100644 --- a/include/modules/protocol/rfc1459.h +++ b/include/modules/protocol/rfc1459.h @@ -288,6 +288,14 @@ class Ping : public IRCDMessage void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; }; +class Pong : public IRCDMessage +{ + public: + Pong(Module *creator, const Anope::string &mname = "PONG") : IRCDMessage(creator, mname) { } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override; +}; + class Privmsg : public IRCDMessage { public: diff --git a/include/uplink.h b/include/uplink.h index 8cb8c8b20..be2675931 100644 --- a/include/uplink.h +++ b/include/uplink.h @@ -21,6 +21,7 @@ #include "sockets.h" #include "protocol.h" +#include "timers.h" namespace Uplink { @@ -40,13 +41,22 @@ namespace Uplink IRCMessage message(Me, command, std::forward<Args>(args)...); SendMessage(message); } + + class PingTimer : public Timer + { + public: + PingTimer(time_t); + void Tick(time_t) override; + }; } /* This is the socket to our uplink */ class UplinkSocket : public ConnectionSocket, public BufferedSocket { public: - bool error; + bool error = false; + time_t last_read = 0; + bool pinged = false; UplinkSocket(); ~UplinkSocket(); bool ProcessRead() override; |