Reinstate the IP address logging for the reflector.
This commit is contained in:
parent
79cf5aa89b
commit
035249b5e0
4 changed files with 47 additions and 8 deletions
|
@ -160,6 +160,34 @@ bool CUDPSocket::isNone(const sockaddr_storage& addr)
|
|||
return ((addr.ss_family == AF_INET) && (in->sin_addr.s_addr == htonl(INADDR_NONE)));
|
||||
}
|
||||
|
||||
char* CUDPSocket::display(const sockaddr_storage& addr, char* buffer, unsigned int length)
|
||||
{
|
||||
assert(buffer != NULL);
|
||||
assert(length > INET6_ADDRSTRLEN);
|
||||
|
||||
switch (addr.ss_family) {
|
||||
case AF_INET: {
|
||||
struct sockaddr_in* in4 = (struct sockaddr_in*)&addr;
|
||||
::inet_ntop(AF_INET, &in4, buffer, length);
|
||||
::sprintf(buffer + ::strlen(buffer), ":%u", in4->sin_port);
|
||||
}
|
||||
break;
|
||||
|
||||
case AF_INET6: {
|
||||
struct sockaddr_in6* in6 = (struct sockaddr_in6*)&addr;
|
||||
::inet_ntop(AF_INET6, &in6, buffer, length);
|
||||
::sprintf(buffer + ::strlen(buffer), ":%u", in6->sin6_port);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
::strcpy(buffer, "Unknown");
|
||||
break;
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
bool CUDPSocket::open(const sockaddr_storage& address)
|
||||
{
|
||||
return open(address.ss_family);
|
||||
|
|
|
@ -70,6 +70,8 @@ public:
|
|||
|
||||
static bool isNone(const sockaddr_storage& addr);
|
||||
|
||||
static char* display(const sockaddr_storage& address, char* buffer, unsigned int length);
|
||||
|
||||
private:
|
||||
std::string m_address_save;
|
||||
unsigned short m_port_save;
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
#if !defined(VERSION_H)
|
||||
#define VERSION_H
|
||||
|
||||
const char* VERSION = "20201101";
|
||||
const char* VERSION = "20201124";
|
||||
|
||||
#endif
|
||||
|
|
|
@ -211,12 +211,16 @@ void CYSFReflector::run()
|
|||
rpt->m_addrLen = addrLen;
|
||||
m_repeaters.push_back(rpt);
|
||||
network.setCount(m_repeaters.size());
|
||||
LogMessage("Adding %s", rpt->m_callsign.c_str());
|
||||
|
||||
char buff[80U];
|
||||
LogMessage("Adding %s (%s)", rpt->m_callsign.c_str(), CUDPSocket::display(addr, buff, 80U));
|
||||
}
|
||||
rpt->m_timer.start();
|
||||
network.writePoll(addr, addrLen);
|
||||
} else if (::memcmp(buffer + 0U, "YSFU", 4U) == 0 && rpt != NULL) {
|
||||
LogMessage("Removing %s unlinked", rpt->m_callsign.c_str());
|
||||
char buff[80U];
|
||||
LogMessage("Removing %s (%s) unlinked", rpt->m_callsign.c_str(), CUDPSocket::display(addr, buff, 80U));
|
||||
|
||||
for (std::vector<CYSFRepeater*>::iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
|
||||
CYSFRepeater* itRpt = *it;
|
||||
if (CUDPSocket::match(itRpt->m_addr, rpt->m_addr)) {
|
||||
|
@ -291,7 +295,9 @@ void CYSFReflector::run()
|
|||
for (std::vector<CYSFRepeater*>::iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
|
||||
CYSFRepeater* itRpt = *it;
|
||||
if (itRpt->m_timer.hasExpired()) {
|
||||
LogMessage("Removing %s disappeared", itRpt->m_callsign.c_str());
|
||||
char buff[80U];
|
||||
LogMessage("Removing %s (%s) disappeared", itRpt->m_callsign.c_str(), CUDPSocket::display(itRpt->m_addr, buff, 80U));
|
||||
|
||||
m_repeaters.erase(it);
|
||||
delete itRpt;
|
||||
network.setCount(m_repeaters.size());
|
||||
|
@ -340,9 +346,12 @@ void CYSFReflector::dumpRepeaters() const
|
|||
LogMessage("Currently linked repeaters/gateways:");
|
||||
|
||||
for (std::vector<CYSFRepeater*>::const_iterator it = m_repeaters.begin(); it != m_repeaters.end(); ++it) {
|
||||
std::string callsign = (*it)->m_callsign;
|
||||
unsigned int timer = (*it)->m_timer.getTimer();
|
||||
unsigned int timeout = (*it)->m_timer.getTimeout();
|
||||
LogMessage(" %s: %u/%u", callsign.c_str(), timer, timeout);
|
||||
std::string callsign = (*it)->m_callsign;
|
||||
sockaddr_storage addr = (*it)->m_addr;
|
||||
unsigned int timer = (*it)->m_timer.getTimer();
|
||||
unsigned int timeout = (*it)->m_timer.getTimeout();
|
||||
|
||||
char buffer[80U];
|
||||
LogMessage(" %s: %s %u/%u", callsign.c_str(), CUDPSocket::display(addr, buffer, 80U), timer, timeout);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue