diff --git a/CacheManager.cpp b/CacheManager.cpp index 95c4d2d..9e844c9 100644 --- a/CacheManager.cpp +++ b/CacheManager.cpp @@ -182,6 +182,7 @@ void CCacheManager::clearGate() mux.lock(); GateIPV4.clear(); GateIPV6.clear(); + NameNick.clear(); mux.unlock(); } diff --git a/QnetGateway.cpp b/QnetGateway.cpp index b5c6157..924a281 100644 --- a/QnetGateway.cpp +++ b/QnetGateway.cpp @@ -54,7 +54,7 @@ #define CFG_DIR "/usr/local/etc" #endif -const std::string GW_VERSION("QnetGateway-9.4.1"); +const std::string GW_VERSION("QnetGateway-200320"); static std::atomic keep_running(true); @@ -447,35 +447,6 @@ void CQnetGateway::GetIRCDataThread(const int i) while (((type = ii[i]->getMessageType()) != IDRT_NONE) && keep_running) { switch (type) { - case IDRT_USER: { - std::string user, rptr, gate, addr, utime; - ii[i]->receiveUser(user, rptr, gate, addr, utime); - if (LOG_IRC) - printf("U%d u[%s] r[%s] g[%s] a[%s] t[%s]\n", i, user.c_str(), rptr.c_str(), gate.c_str(), addr.c_str(), utime.c_str()); - cache.updateUser(user, rptr, gate, addr, utime); - } - break; - - case IDRT_REPEATER: { - std::string rptr, gate, addr, ip; - DSTAR_PROTOCOL proto; - ii[i]->receiveRepeater(rptr, gate, addr, proto); - if (LOG_IRC) - printf("R%d r[%s] g[%s] a[%s]\n", i, rptr.c_str(), gate.c_str(), addr.c_str()); - cache.updateRptr(rptr, gate, addr); - } - break; - - case IDRT_GATEWAY: { - std::string gate, addr; - DSTAR_PROTOCOL proto; - ii[i]->receiveGateway(gate, addr, proto); - if (LOG_IRC) - printf("G%d g[%s] a[%s]\n", i, gate.c_str(),addr.c_str()); - cache.updateGate(gate, addr); - } - break; - case IDRT_PING: { std::string rptr, gate, addr; ii[i]->receivePing(rptr); @@ -530,6 +501,7 @@ int CQnetGateway::get_yrcall_rptr_from_cache(const std::string &call, std::strin fprintf(stderr, "ERROR: Invalid module %c\n", rptr.at(7)); return 2; } + if (addr.empty()) { printf("Couldn't find IP address for %s\n", ('R' == RoU) ? "repeater" : "user"); return 1; @@ -564,9 +536,7 @@ int CQnetGateway::get_yrcall_rptr(const std::string &call, std::string &rptr, st if (!ii[i]->findUser(call)) printf("findUser(%s): Network error\n", call.c_str()); } else if (RoU == 'R') { - printf("Repeater [%s] not in local cache, try again\n", call.c_str()); - if (!ii[i]->findRepeater(call)) - printf("findRepeater(%s): Network error\n", call.c_str()); + printf("Repeater [%s] not found\n", call.c_str()); } return 0; } diff --git a/ircddb/IRCDDB.cpp b/ircddb/IRCDDB.cpp index c273017..1e3123a 100644 --- a/ircddb/IRCDDB.cpp +++ b/ircddb/IRCDDB.cpp @@ -210,29 +210,6 @@ bool CIRCDDB::sendHeardWithTXStats(const std::string &myCall, const std::string return app->sendHeard( myCall, myCallExt, yourCall, rpt1, rpt2, flag1, flag2, flag3, " ", "", stats); } -// Send query for a gateway/reflector, a false return implies a network error -bool CIRCDDB::findGateway(const std::string &gatewayCallsign) -{ - if (gatewayCallsign.size() != 8) { - printf("CIRCDDB::findGateway: len != 8\n"); - return false; - } - std::string gcs = gatewayCallsign; - ToUpper(gcs); - return app->findGateway(gcs); -} - -bool CIRCDDB::findRepeater(const std::string &repeaterCallsign) -{ - if (repeaterCallsign.size() != 8) { - printf("CIRCDDB::findRepeater: len != 8\n"); - return false; - } - std::string rcs = repeaterCallsign; - ToUpper(rcs); - return app->findRepeater(rcs); -} - // Send query for a user, a false return implies a network error bool CIRCDDB::findUser(const std::string &userCallsign) { @@ -253,124 +230,6 @@ IRCDDB_RESPONSE_TYPE CIRCDDB::getMessageType() return app->getReplyMessageType(); } -// Get a gateway message, as a result of IDRT_REPEATER returned from getMessageType() -// A false return implies a network error -bool CIRCDDB::receiveRepeater(std::string &repeaterCallsign, std::string &gatewayCallsign, std::string &address, DSTAR_PROTOCOL &/*protocol*/) -{ - IRCDDB_RESPONSE_TYPE rt = app->getReplyMessageType(); - - if (rt != IDRT_REPEATER) { - printf("CIRCDDB::receiveRepeater: unexpected response type\n"); - return false; - } - - IRCMessage *m = app->getReplyMessage(); - - if (m == NULL) { - printf("CIRCDDB::receiveRepeater: no message\n"); - return false; - } - - if (m->getCommand().compare("IDRT_REPEATER")) { - printf("CIRCDDB::receiveRepeater: wrong message type\n"); - return false; - } - - if (m->getParamCount() != 3) { - printf("CIRCDDB::receiveRepeater: unexpected number of message parameters\n"); - return false; - } - - repeaterCallsign = m->getParam(0); - gatewayCallsign = m->getParam(1); - address = m->getParam(2); - - delete m; - - return true; -} - -// Get a gateway message, as a result of IDRT_GATEWAY returned from getMessageType() -// A false return implies a network error -bool CIRCDDB::receiveGateway(std::string &gatewayCallsign, std::string &address, DSTAR_PROTOCOL& /*protocol*/) -{ - IRCDDB_RESPONSE_TYPE rt = app->getReplyMessageType(); - - if (rt != IDRT_GATEWAY) { - printf("CIRCDDB::receiveGateway: unexpected response type\n"); - return false; - } - - IRCMessage *m = app->getReplyMessage(); - - if (m == NULL) { - printf("CIRCDDB::receiveGateway: no message\n"); - return false; - } - - if (m->getCommand().compare("IDRT_GATEWAY")) { - printf("CIRCDDB::receiveGateway: wrong message type\n"); - return false; - } - - if (m->getParamCount() != 2) { - printf("CIRCDDB::receiveGateway: unexpected number of message parameters\n"); - return false; - } - - gatewayCallsign = m->getParam(0); - address = m->getParam(1); - - delete m; - - return true; -} - -// Get a user message, as a result of IDRT_USER returned from getMessageType() -// A false return implies a network error -bool CIRCDDB::receiveUser(std::string &userCallsign, std::string &repeaterCallsign, std::string &gatewayCallsign, std::string &address) -{ - std::string dummy; - return receiveUser(userCallsign, repeaterCallsign, gatewayCallsign, address, dummy); -} - -bool CIRCDDB::receiveUser(std::string &userCallsign, std::string &repeaterCallsign, std::string &gatewayCallsign, std::string &address, std::string &timeStamp) -{ - IRCDDB_RESPONSE_TYPE rt = app->getReplyMessageType(); - - if (rt != IDRT_USER) { - printf("CIRCDDB::receiveUser: unexpected response type\n"); - return false; - } - - IRCMessage *m = app->getReplyMessage(); - - if (m == NULL) { - printf("CIRCDDB::receiveUser: no message\n"); - return false; - } - - if (m->getCommand().compare("IDRT_USER")) { - printf("CIRCDDB::receiveUser: wrong message type\n"); - return false; - } - - if (m->getParamCount() != 5) { - printf("CIRCDDB::receiveUser: unexpected number of message parameters\n"); - return false; - } - - userCallsign = m->getParam(0); - repeaterCallsign = m->getParam(1); - gatewayCallsign = m->getParam(2); - address = m->getParam(3); - timeStamp = m->getParam(4); - - delete m; - - return true; -} - bool CIRCDDB::receivePing(std::string &repeaterCallsign) { IRCDDB_RESPONSE_TYPE rt = app->getReplyMessageType(); diff --git a/ircddb/IRCDDB.h b/ircddb/IRCDDB.h index e200c82..950ac27 100644 --- a/ircddb/IRCDDB.h +++ b/ircddb/IRCDDB.h @@ -6,9 +6,6 @@ enum IRCDDB_RESPONSE_TYPE { IDRT_NONE, - IDRT_USER, - IDRT_GATEWAY, - IDRT_REPEATER, IDRT_PING }; @@ -93,12 +90,6 @@ public: // The following three functions don't block waiting for a reply, they just send the data - // Send query for a gateway/reflector, a false return implies a network error - bool findGateway(const std::string &gatewayCallsign); - - // Send query for a repeater module, a false return implies a network error - bool findRepeater(const std::string &repeaterCallsign); - // Send query for a user, a false return implies a network error bool findUser(const std::string &userCallsign); @@ -109,18 +100,6 @@ public: // Get a gateway message, as a result of IDRT_REPEATER returned from getMessageType() // A false return implies a network error - bool receiveRepeater(std::string &repeaterCallsign, std::string &gatewayCallsign, std::string &address, DSTAR_PROTOCOL& protocol); - - // Get a gateway message, as a result of IDRT_GATEWAY returned from getMessageType() - // A false return implies a network error - bool receiveGateway(std::string &gatewayCallsign, std::string &address, DSTAR_PROTOCOL &protocol); - - // Get a user message, as a result of IDRT_USER returned from getMessageType() - // A false return implies a network error - bool receiveUser(std::string &userCallsign, std::string &repeaterCallsign, std::string &gatewayCallsign, std::string &address); - - bool receiveUser(std::string &userCallsign, std::string &repeaterCallsign, std::string &gatewayCallsign, std::string &address, std::string &timeStamp); - bool receivePing(std::string &repeaterCallsign); void sendPing(const std::string &to, const std::string &from); diff --git a/ircddb/IRCDDBApp.cpp b/ircddb/IRCDDBApp.cpp index 17bf864..4c2d4e1 100644 --- a/ircddb/IRCDDBApp.cpp +++ b/ircddb/IRCDDBApp.cpp @@ -7,12 +7,9 @@ #include "IRCDDBApp.h" #include "IRCutils.h" -unsigned int IRCDDBAppGateObject::counter = 0; - -time_t IRCDDBAppRptrObject::maxTime((time_t)950000000); // February 2000 - -IRCDDBApp::IRCDDBApp(const std::string &u_chan, CCacheManager *cache) +IRCDDBApp::IRCDDBApp(const std::string &u_chan, CCacheManager *cache) : numberOfTables(2) { + maxTime = 950000000; // Feb 2000 wdTimer = -1; sendQ = NULL; initReady = false; @@ -153,13 +150,7 @@ IRCDDB_RESPONSE_TYPE IRCDDBApp::getReplyMessageType() std::string msgType = m->getCommand(); - if (msgType == std::string("IDRT_USER")) { - return IDRT_USER; - } else if (msgType == std::string("IDRT_REPEATER")) { - return IDRT_REPEATER; - } else if (msgType == std::string("IDRT_GATEWAY")) { - return IDRT_GATEWAY; - } else if (msgType == std::string("IDRT_PING")) { + if (msgType == std::string("IDRT_PING")) { return IDRT_PING; } @@ -191,154 +182,62 @@ void IRCDDBApp::stopWork() worker_thread.get(); } -void IRCDDBApp::userJoin(const std::string &nick, const std::string &name, const std::string &host) +void IRCDDBApp::userJoin(const std::string &nick, const std::string &name, const std::string &addr) { - std::string lnick = nick; - ToLower(lnick); - - IRCDDBAppGateObject u(lnick, name, host); - - userMapMutex.lock(); - user[lnick] = u; - userMapMutex.unlock(); - - //printf("add %d: (%s) (%s)\n", user.size(), nick.c_str(), host.c_str()); - - if (initReady) { - unsigned hyphenPos = nick.find('-'); - - if ((hyphenPos >= 4) && (hyphenPos <= 6)) { - std::string gatewayCallsign = nick.substr(0, hyphenPos); - ToUpper(gatewayCallsign); - gatewayCallsign.resize(7, '_'); - gatewayCallsign.push_back('G'); - - IRCMessage *m2 = new IRCMessage("IDRT_GATEWAY"); - m2->addParam(gatewayCallsign); - m2->addParam(host); - replyQ.putMessage(m2); - } + if ('-' == nick.at(1)) { + if ('s' == nick.at(0)) + setBestServer(nick); + return; } - //printf("user %d\n", u.usn); + std::string gate(name); + ToUpper(gate); + gate.resize(7, ' '); + gate.push_back('G'); + cache->updateName(name, nick); + cache->updateGate(gate, addr); } void IRCDDBApp::userLeave(const std::string &nick) { - std::string lnick = nick; - ToLower(lnick); - - userMapMutex.lock(); - user.erase(lnick); - userMapMutex.unlock(); - - // printf("rm %d: %s\n" user.size(), nick.c_str()); - - if (currentServer.length() > 0) { - if (user.count(myNick) != 1) { - printf("IRCDDBApp::userLeave: could not find own nick\n"); - return; - } - - IRCDDBAppGateObject me = user[myNick]; - - if (me.op == false) { - // if I am not op, then look for new server - - if (currentServer == lnick) { - // currentServer = null; - state = 2; // choose new server - timer = 200; - initReady = false; - } - } + if (0 == nick.compare(0, 2, "s-")) { + currentServer.clear(); + state = 2; + timer = 200; + initReady = false; + return; + } + std::string name(nick); + name.pop_back(); + if ('-' == name.back()) { + name.pop_back(); + cache->eraseName(name); + ToUpper(name); + name.resize(7, ' '); + name.push_back('G'); + cache->eraseGate(name); } } void IRCDDBApp::userListReset() { - userMapMutex.lock(); - user.clear(); - userMapMutex.unlock(); + cache->clearGate(); // clears the NameNick as well } void IRCDDBApp::setCurrentNick(const std::string &nick) { - myNick = nick; + myNick.assign(nick); printf("IRCDDBApp::setCurrentNick %s\n", nick.c_str()); } void IRCDDBApp::setBestServer(const std::string &ircUser) { - bestServer = ircUser; + bestServer.assign(ircUser); printf("IRCDDBApp::setBestServer %s\n", ircUser.c_str()); } -void IRCDDBApp::setTopic(const std::string &topic) -{ - channelTopic = topic; -} - bool IRCDDBApp::findServerUser() { - userMapMutex.lock(); - - bool found = false; - - std::map::iterator it; - - for (it=user.begin(); it!=user.end(); ++it) { - IRCDDBAppGateObject u = it->second; - if (0==u.nick.compare(0, 2, "s-") && u.op && myNick.compare(u.nick) && 0==u.nick.compare(bestServer)) { - currentServer = u.nick; - found = true; - break; - } - } - - if (found) { - userMapMutex.unlock(); - return true; - } - - if (bestServer.length() == 8) { - for(it=user.begin(); it!=user.end(); ++it) { - IRCDDBAppGateObject u = it->second; - if (0==u.nick.compare(0, 7, bestServer) && u.op && myNick.compare(u.nick) ) { - currentServer = u.nick; - found = true; - break; - } - } - } - - if (found) { - userMapMutex.unlock(); - return true; - } - - for(it = user.begin(); it != user.end(); ++it) { - IRCDDBAppGateObject u = it->second; - if (0==u.nick.compare(0, 2, "s-") && u.op && myNick.compare(u.nick)) { - currentServer = u.nick; - found = true; - break; - } - } - - userMapMutex.unlock(); - return found; -} - -void IRCDDBApp::userChanOp(const std::string &nick, bool op) -{ - std::string lnick = nick; - ToLower(lnick); - - userMapMutex.lock(); - if (user.count(lnick) == 1) { - user[lnick].op = op; - } - userMapMutex.unlock(); + return (!bestServer.empty() && !currentServer.empty()); } // to is the gateway to which we are sending the message, (the gateway last used by URCall) @@ -363,89 +262,7 @@ void IRCDDBApp::sendPing(const std::string &to, const std::string &from) } } -static const int numberOfTables = 2; - -std::string IRCDDBApp::getIPAddress(std::string &zonerp_cs) -{ - userMapMutex.lock(); - std::string gw = zonerp_cs; - - ReplaceChar(gw, '_', ' '); - while (isspace(gw[gw.length()-1])) - gw.pop_back(); - ToLower(gw); - - unsigned int max_usn = 0; - std::string ipAddr; - - for (int j=1; j <= 4; j++) { - std::string ircUser = gw + std::string("-") + std::to_string(j); - - if (user.count(ircUser) == 1) { - IRCDDBAppGateObject o = user[ircUser]; - - if (o.usn >= max_usn) { - max_usn = o.usn; - ipAddr = o.host; - } - } - // printf("getIP %d (%s) (%s)\n", i, ircUser.c_str(), ipAddr.c_str()); - - } - userMapMutex.unlock(); - return ipAddr; -} - -bool IRCDDBApp::findGateway(const std::string &gwCall) -{ - std::string s = gwCall.substr(0,6); - IRCMessage *m2 = new IRCMessage("IDRT_GATEWAY"); - m2->addParam(gwCall); - m2->addParam(getIPAddress(s)); - replyQ.putMessage(m2); - - return true; -} - -bool IRCDDBApp::findRepeater(const std::string &rptrCall) -{ - std::string arearp_cs = rptrCall; - ReplaceChar(arearp_cs, ' ', '_'); - - std::string zonerp_cs; - - rptrMapMutex.lock(); - - std::string s("NONE"); - - if (rptrMap.count(arearp_cs) == 1) { - IRCDDBAppRptrObject o = rptrMap[arearp_cs]; - zonerp_cs = o.zonerp_cs; - ReplaceChar(zonerp_cs, '_', ' '); - zonerp_cs[7] = 'G'; - s = o.zonerp_cs; - } - rptrMapMutex.unlock(); - - IRCMessage *m2 = new IRCMessage("IDRT_REPEATER"); - m2->addParam(rptrCall); - m2->addParam(zonerp_cs); - m2->addParam(getIPAddress(s)); - replyQ.putMessage(m2); - return true; -} - -bool IRCDDBApp::sendHeard(const std::string &myCall, - const std::string &myCallExt, - const std::string &yourCall, - const std::string &rpt1, - const std::string &rpt2, - unsigned char flag1, - unsigned char flag2, - unsigned char flag3, - const std::string &destination, - const std::string &tx_msg, - const std::string &tx_stats) +bool IRCDDBApp::sendHeard(const std::string &myCall, const std::string &myCallExt, const std::string &yourCall, const std::string &rpt1, const std::string &rpt2, unsigned char flag1, unsigned char flag2, unsigned char flag3, const std::string &destination, const std::string &tx_msg, const std::string &tx_stats) { std::string my = myCall; @@ -537,14 +354,6 @@ bool IRCDDBApp::findUser(const std::string &usrCall) IRCMessage *m = new IRCMessage(srv, std::string("FIND ") + usr ); q->putMessage(m); - } else { - IRCMessage *m2 = new IRCMessage("IDRT_USER"); - m2->addParam(usrCall); - m2->addParam(""); - m2->addParam(""); - m2->addParam(""); - m2->addParam(""); - replyQ.putMessage(m2); } return true; @@ -629,7 +438,8 @@ void IRCDDBApp::doUpdate(std::string &msg) if (! std::regex_match(timeToken, timePattern)) return; // no time string after date string - time_t dt = parseTime(std::string(tk + " " + timeToken)); + std::string tstr(std::string(tk + " " + timeToken)); // used to update user time + auto rtime = parseTime(tstr); // used to update maxTime for sendlist if ((tableID == 0) || (tableID == 1)) { if (0 == tkz.size()) @@ -653,63 +463,33 @@ void IRCDDBApp::doUpdate(std::string &msg) //printf("TABLE %d %s %s\n", tableID, key.c_str(), value.c_str()); if (tableID == 1) { - rptrMapMutex.lock(); - IRCDDBAppRptrObject newRptr(dt, key, value); + if (initReady && key.compare(0,6, value, 0, 6)) { + std::string rptr(key); + std::string gate(value); - rptrMap[key] = newRptr; - - if (initReady) { - std::string arearp_cs = key; - std::string zonerp_cs = value; - - ReplaceChar(arearp_cs, '_', ' '); - ReplaceChar(zonerp_cs, '_', ' '); - zonerp_cs[7] = 'G'; - - IRCMessage *m2 = new IRCMessage("IDRT_REPEATER"); - m2->addParam(arearp_cs); - m2->addParam(zonerp_cs); - m2->addParam(getIPAddress(value)); - replyQ.putMessage(m2); + ReplaceChar(rptr, '_', ' '); + ReplaceChar(gate, '_', ' '); + gate[7] = 'G'; + cache->updateRptr(rptr, gate, ""); + if (rtime > maxTime) + maxTime = rtime; } - rptrMapMutex.unlock(); } else if ((tableID == 0) && initReady) { - rptrMapMutex.lock(); + std::string user(key); + std::string rptr(value); - std::string userCallsign = key; - std::string arearp_cs = value; - std::string zonerp_cs; - std::string ip_addr; + ReplaceChar(user, '_', ' '); + ReplaceChar(rptr, '_', ' '); - ReplaceChar(userCallsign, '_', ' '); - ReplaceChar(arearp_cs, '_', ' '); - - if (rptrMap.end() != rptrMap.find(value)) { - IRCDDBAppRptrObject o = rptrMap[value]; - zonerp_cs = o.zonerp_cs; - ReplaceChar(zonerp_cs, '_', ' '); - zonerp_cs[7] = 'G'; - - ip_addr = getIPAddress(o.zonerp_cs); - } - - IRCMessage *m2 = new IRCMessage("IDRT_USER"); - m2->addParam(userCallsign); - m2->addParam(arearp_cs); - m2->addParam(zonerp_cs); - m2->addParam(ip_addr); - m2->addParam(tk + std::string(" ") + timeToken); - replyQ.putMessage(m2); - - rptrMapMutex.unlock(); + cache->updateUser(user, rptr, "", "", tstr); } } } } -static std::string getTableIDString(int tableID, bool spaceBeforeNumber) +std::string IRCDDBApp::getTableIDString(int tableID, bool spaceBeforeNumber) { if (tableID == 0) { return std::string(""); @@ -790,11 +570,10 @@ IRCMessageQueue *IRCDDBApp::getSendQ() return sendQ; } -static std::string getLastEntryTime(int tableID) +std::string IRCDDBApp::getLastEntryTime(int tableID) { - if (tableID == 1) { - struct tm *ptm = gmtime(&IRCDDBAppRptrObject::maxTime); + struct tm *ptm = gmtime(&maxTime); char tstr[80]; strftime(tstr, 80, "%Y-%m-%d %H:%M:%S", ptm); std::string max = tstr; diff --git a/ircddb/IRCDDBApp.h b/ircddb/IRCDDBApp.h index 75b1b74..3534e7e 100644 --- a/ircddb/IRCDDBApp.h +++ b/ircddb/IRCDDBApp.h @@ -9,53 +9,6 @@ #include "IRCDDB.h" #include "IRCMessageQueue.h" -class IRCDDBAppGateObject -{ -public: - - std::string nick; - std::string name; - std::string host; - bool op; - unsigned int usn; - - IRCDDBAppGateObject() {} - - IRCDDBAppGateObject(const std::string &n, const std::string &nm, const std::string &h) { - nick = n; - name = nm; - host = h; - op = false; - usn = counter; - counter++; - } - static unsigned int counter; -}; - -class IRCDDBAppRptrObject -{ -public: - - std::string arearp_cs; - time_t lastChanged; - std::string zonerp_cs; - - IRCDDBAppRptrObject() { - } - - IRCDDBAppRptrObject(time_t dt, std::string &repeaterCallsign, std::string &gatewayCallsign) { - arearp_cs = repeaterCallsign; - lastChanged = dt; - zonerp_cs = gatewayCallsign; - - if (dt > maxTime) { - maxTime = dt; - } - } - - static time_t maxTime; -}; - class IRCDDBApp { public: @@ -66,14 +19,12 @@ public: void userLeave(const std::string &nick); - void userChanOp(const std::string &nick, bool op); void userListReset(); void msgChannel(IRCMessage *m); void msgQuery(IRCMessage *m); void setCurrentNick(const std::string &nick); - void setTopic(const std::string &topic); void setBestServer(const std::string &ircUser); @@ -91,8 +42,6 @@ public: IRCMessage *getReplyMessage(); bool findUser(const std::string &s); - bool findRepeater(const std::string &s); - bool findGateway(const std::string &s); bool sendHeard(const std::string &myCall, const std::string &myCallExt, const std::string &yourCall, const std::string &rpt1, const std::string &rpt2, unsigned char flag1, unsigned char flag2, unsigned char flag3, const std::string &destination, const std::string &tx_msg, const std::string &tx_stats); @@ -108,19 +57,17 @@ protected: void Entry(); private: + const int numberOfTables; void doUpdate(std::string &msg); void doNotFound(std::string &msg, std::string &retval); - std::string getIPAddress(std::string &zonerp_cs); bool findServerUser(); + std::string getTableIDString(int tableID, bool spaceBeforeNumber); + std::string getLastEntryTime(int tableID); std::future worker_thread; IRCMessageQueue *sendQ; IRCMessageQueue replyQ; CCacheManager *cache; - std::map user; - std::mutex userMapMutex; - std::map rptrMap; - std::mutex rptrMapMutex; std::map moduleMap; std::mutex moduleMapMutex; std::map locationMap; @@ -139,6 +86,7 @@ private: int timer; int infoTimer; int wdTimer; + time_t maxTime; std::string updateChannel; std::string channelTopic; diff --git a/ircddb/IRCProtocol.cpp b/ircddb/IRCProtocol.cpp index e3076cd..911371a 100644 --- a/ircddb/IRCProtocol.cpp +++ b/ircddb/IRCProtocol.cpp @@ -160,28 +160,11 @@ bool IRCProtocol::processQueues(IRCMessageQueue *recvQ, IRCMessageQueue *sendQ) if (app != NULL) { app->userLeave( m->getPrefixNick() ); } - } else if (0 == m->command.compare("MODE")) { - if ((m->numParams >= 3) && 0==m->params[0].compare(channel)) { - if (app != NULL) { - size_t i; - std::string mode = m->params[1]; - - for (i=1; inumParams>=(i+2); i++) { - if (mode[i] == 'o') { - if (mode[0] == '+') { - app->userChanOp(m->params[i+1], true); - } else if (mode[0] == '-') { - app->userChanOp(m->params[i+1], false); - } - } - } // for - } - } } else if (0 == m->command.compare("PRIVMSG")) { if (app) { - std::string out; - m->composeMessage(out); - out.pop_back(); out.pop_back(); + // std::string out; + // m->composeMessage(out); + // out.pop_back(); out.pop_back(); if (2 == m->numParams) { if (0 == m->params[0].compare(channel)) { app->msgChannel(m); @@ -200,10 +183,6 @@ bool IRCProtocol::processQueues(IRCMessageQueue *recvQ, IRCMessageQueue *sendQ) if ((m->numParams >= 7) && 0==m->params[0].compare(currentNick) && 0==m->params[1].compare(channel)) { if (app != NULL) { app->userJoin(m->params[5], m->params[2], m->params[3]); - app->userChanOp (m->params[5], 0==m->params[6].compare("H@")); - // this mod is for ngircd - // app->userChanOp (m->params[5], std::string::npos!=m->params[6].find('H') && std::string::npos!=m->params[6].find('@')); - // NOT NEEDED, W1BSB fixed it in ngircd } } } else if (0 == m->command.compare("433")) { // nick collision @@ -211,10 +190,6 @@ bool IRCProtocol::processQueues(IRCMessageQueue *recvQ, IRCMessageQueue *sendQ) state = 3; // nick collision, choose new nick timer = 10; // wait 5 seconds.. } - } else if (0==m->command.compare("332") || 0==m->command.compare("TOPIC")) { // topic - if ((m->numParams == 2) && (app != NULL) && 0==m->params[0].compare(channel)) { - app->setTopic(m->params[1]); - } } delete m;