diff --git a/QnetGateway.cpp b/QnetGateway.cpp index fb66fdd..38654da 100644 --- a/QnetGateway.cpp +++ b/QnetGateway.cpp @@ -53,7 +53,6 @@ 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); @@ -2424,7 +2423,7 @@ bool CQnetGateway::Init(char *cfgfile) } rc = ii->getConnectionState(); } - switch (ircsocketfamily) { + switch (ii->GetFamily()) { case AF_INET: printf("IRC server is using IPV4\n"); af_family = AF_INET; @@ -2434,9 +2433,8 @@ bool CQnetGateway::Init(char *cfgfile) af_family = AF_INET6; break; default: - printf("IRC server is using unknown protocol!\n"); - af_family = AF_UNSPEC; - break; + printf("IRC server is using unknown protocol! Shutting down...\n"); + return true; } /* udp port 40000 must open first */ diff --git a/ircddb/IRCClient.cpp b/ircddb/IRCClient.cpp index 9b36a50..fe72db9 100644 --- a/ircddb/IRCClient.cpp +++ b/ircddb/IRCClient.cpp @@ -3,13 +3,9 @@ #include #include #include -#include #include "IRCClient.h" #include "IRCutils.h" -#include "../TCPReaderWriterClient.h" - -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) @@ -58,7 +54,7 @@ void IRCClient::Entry() int state = 0; int timer = 0; - socklen_t optlen = sizeof(int); + socklen_t optlen; while (true) { @@ -85,8 +81,8 @@ void IRCClient::Entry() case 4: - - getsockopt(ircSock.GetFD(), SOL_SOCKET, SO_DOMAIN, &ircsocketfamily, &optlen); + optlen = sizeof(int); + getsockopt(ircSock.GetFD(), SOL_SOCKET, SO_DOMAIN, &family, &optlen); recvQ = new IRCMessageQueue(); sendQ = new IRCMessageQueue(); @@ -174,3 +170,8 @@ void IRCClient::Entry() } return; } + +int IRCClient::GetFamily() +{ + return family; +} diff --git a/ircddb/IRCClient.h b/ircddb/IRCClient.h index e64d381..e6f58ba 100644 --- a/ircddb/IRCClient.h +++ b/ircddb/IRCClient.h @@ -1,6 +1,8 @@ #pragma once #include +#include +#include "../TCPReaderWriterClient.h" #include "IRCReceiver.h" #include "IRCMessageQueue.h" @@ -15,11 +17,14 @@ public: virtual ~IRCClient(); bool startWork(); void stopWork(); + int GetFamily(); protected: virtual void Entry(); private: + std::atomic family; + std::future client_thread; char host_name[100]; char local_addr[100]; unsigned int port; @@ -32,7 +37,6 @@ private: IRCMessageQueue *recvQ; IRCMessageQueue *sendQ; IRCProtocol *proto; - std::future client_thread; IRCApplication *app; }; diff --git a/ircddb/IRCDDB.cpp b/ircddb/IRCDDB.cpp index 6e0e736..7d3d47f 100644 --- a/ircddb/IRCDDB.cpp +++ b/ircddb/IRCDDB.cpp @@ -27,6 +27,11 @@ CIRCDDB::~CIRCDDB() delete d; } +int CIRCDDB::GetFamily() +{ + return d->client->GetFamily(); +} + // A false return implies a network error, or unable to log in bool CIRCDDB::open() diff --git a/ircddb/IRCDDB.h b/ircddb/IRCDDB.h index 3cbfddf..e06460b 100644 --- a/ircddb/IRCDDB.h +++ b/ircddb/IRCDDB.h @@ -24,6 +24,8 @@ public: CIRCDDB(const std::string &hostName, unsigned int port, const std::string &callsign, const std::string &password, const std::string &versionInfo); ~CIRCDDB(); + int GetFamily(); + // A false return implies a network error, or unable to log in bool open();