From f2851418d1f09b5980659b3ed3142bc4d1bcc714 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Sat, 6 Apr 2019 08:57:08 -0700 Subject: [PATCH] report irc protocol --- QnetGateway.cpp | 17 ++++++++++++++++- ircddb/IRCClient.cpp | 8 ++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/QnetGateway.cpp b/QnetGateway.cpp index bc037ff..fb66fdd 100644 --- a/QnetGateway.cpp +++ b/QnetGateway.cpp @@ -53,6 +53,7 @@ const std::string IRCDDB_VERSION("QnetGateway-9.0"); extern void dstar_dv_init(); extern int dstar_dv_decode(const unsigned char *d, int data[3]); +extern std::atomic ircsocketfamily; static std::atomic keep_running(true); @@ -1879,7 +1880,7 @@ void CQnetGateway::Process() if (keep_running) printf("get_irc_data thread started\n"); - ii->kickWatchdog(IRCDDB_VERSION.c_str()); + ii->kickWatchdog(IRCDDB_VERSION); while (keep_running) { ProcessTimeouts(); @@ -2423,6 +2424,20 @@ bool CQnetGateway::Init(char *cfgfile) } rc = ii->getConnectionState(); } + switch (ircsocketfamily) { + case AF_INET: + printf("IRC server is using IPV4\n"); + af_family = AF_INET; + break; + case AF_INET6: + printf("IRC server is using IPV6\n"); + af_family = AF_INET6; + break; + default: + printf("IRC server is using unknown protocol!\n"); + af_family = AF_UNSPEC; + break; + } /* udp port 40000 must open first */ g2_sock = open_port(g2_external); diff --git a/ircddb/IRCClient.cpp b/ircddb/IRCClient.cpp index bb4e43d..9b36a50 100644 --- a/ircddb/IRCClient.cpp +++ b/ircddb/IRCClient.cpp @@ -3,13 +3,14 @@ #include #include #include +#include #include "IRCClient.h" #include "IRCutils.h" #include "../TCPReaderWriterClient.h" -#include -#include +std::atomic ircsocketfamily; + IRCClient::IRCClient(IRCApplication *app, const std::string &update_channel, const std::string &hostName, unsigned int port, const std::string &callsign, const std::string &password, const std::string &versionInfo) { @@ -57,6 +58,7 @@ void IRCClient::Entry() int state = 0; int timer = 0; + socklen_t optlen = sizeof(int); while (true) { @@ -83,6 +85,8 @@ void IRCClient::Entry() case 4: + + getsockopt(ircSock.GetFD(), SOL_SOCKET, SO_DOMAIN, &ircsocketfamily, &optlen); recvQ = new IRCMessageQueue(); sendQ = new IRCMessageQueue();