From 254f15e3a0b7d589d12d374c45ee665e8ac2ecb5 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Wed, 10 Apr 2019 16:13:16 -0700 Subject: [PATCH] got rid of getAllIPV4Addresses --- ircddb/IRCDDBApp.cpp | 40 ----------------------- ircddb/IRCutils.cpp | 78 -------------------------------------------- ircddb/IRCutils.h | 2 -- 3 files changed, 120 deletions(-) diff --git a/ircddb/IRCDDBApp.cpp b/ircddb/IRCDDBApp.cpp index 340629a..83a49b5 100644 --- a/ircddb/IRCDDBApp.cpp +++ b/ircddb/IRCDDBApp.cpp @@ -472,48 +472,8 @@ bool IRCDDBApp::findGateway(const std::string &gwCall) return true; } -static void findReflector(const std::string &rptrCall, IRCDDBAppPrivate *d) -{ - std::string zonerp_cs; - std::string ipAddr; - -#define MAXIPV4ADDR 5 - struct sockaddr_in addr[MAXIPV4ADDR]; - unsigned int numAddr = 0; - - char host_name[80]; - - std::string host = rptrCall.substr(0,6) + ".reflector.ircddb.net"; - - safeStringCopy(host_name, host.c_str(), sizeof host_name); - - if (getAllIPV4Addresses(host_name, 0, &numAddr, addr, MAXIPV4ADDR) == 0) { - if (numAddr > 0) { - unsigned char *a = (unsigned char *) &addr[0].sin_addr; - char buf[16]; - snprintf(buf, 16, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]); - ipAddr = buf; - zonerp_cs = rptrCall; - zonerp_cs[7] = 'G'; - } - } - - - IRCMessage *m2 = new IRCMessage("IDRT_REPEATER"); - m2->addParam(rptrCall); - m2->addParam(zonerp_cs); - m2->addParam(ipAddr); - d->replyQ.putMessage(m2); -} - bool IRCDDBApp::findRepeater(const std::string &rptrCall) { - - if (0==rptrCall.compare(0, 3, "XRF") || 0==rptrCall.compare(0, 3, "REF")) { - findReflector(rptrCall, d); - return true; - } - std::string arearp_cs = rptrCall; ReplaceChar(arearp_cs, ' ', '_'); diff --git a/ircddb/IRCutils.cpp b/ircddb/IRCutils.cpp index 9076b66..c844c94 100644 --- a/ircddb/IRCutils.cpp +++ b/ircddb/IRCutils.cpp @@ -35,84 +35,6 @@ std::vector stringTokenizer(const std::string &s) return result; } -int getAllIPV4Addresses(const char * name, unsigned short port, unsigned int * num, struct sockaddr_in * addr, unsigned int max_addr) -{ - - struct addrinfo hints; - struct addrinfo * res; - - memset(&hints, 0x00, sizeof(struct addrinfo)); - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_STREAM; - - int r = getaddrinfo(name, NULL, &hints, &res); - - if (r == 0) { - struct addrinfo * rp; - unsigned int numAddr = 0; - - for (rp = res; rp != NULL; rp = rp->ai_next) { - if (rp->ai_family == AF_INET) - numAddr ++; - } - - if (numAddr > 0) { - if (numAddr > max_addr) - numAddr = max_addr; - - int * shuffle = new int[numAddr]; - - unsigned int i; - - for (i=0; i < numAddr; i++) - shuffle[i] = i; - - for (i=0; i < (numAddr - 1); i++) { - if (rand() & 1) { - int tmp; - tmp = shuffle[i]; - shuffle[i] = shuffle[i+1]; - shuffle[i+1] = tmp; - } - } - - for (i=(numAddr - 1); i > 0; i--) { - if (rand() & 1) { - int tmp; - tmp = shuffle[i]; - shuffle[i] = shuffle[i-1]; - shuffle[i-1] = tmp; - } - } - - for (rp = res, i=0 ; (rp != NULL) && (i < numAddr); rp = rp->ai_next) { - if (rp->ai_family == AF_INET) { - memcpy( addr+shuffle[i], rp->ai_addr, sizeof (struct sockaddr_in) ); - - addr[shuffle[i]].sin_port = htons(port); - - i++; - } - } - - delete[] shuffle; - } - - *num = numAddr; - - freeaddrinfo(res); - - return 0; - - } else { - printf("getaddrinfo: %s\n", gai_strerror(r)); - - return 1; - } - - -} - void safeStringCopy (char *dest, const char *src, unsigned int buf_size) { unsigned int i = 0; diff --git a/ircddb/IRCutils.h b/ircddb/IRCutils.h index d139ed6..b2fef99 100644 --- a/ircddb/IRCutils.h +++ b/ircddb/IRCutils.h @@ -27,8 +27,6 @@ time_t parseTime(const std::string str); std::vector stringTokenizer(const std::string &str); -int getAllIPV4Addresses(const char *name, unsigned short port, unsigned int *num, struct sockaddr_in *addr, unsigned int max_addr); - void safeStringCopy(char * dest, const char * src, unsigned int buf_size); char *getCurrentTime(void);