logging changes

pull/14/head
Tom Early 7 years ago
parent 2141b2f238
commit 9a10a686c0

@ -51,10 +51,10 @@ bool CDPlusAuthenticator::Process(std::map<std::string, std::string> &gwy_map, c
fprintf(stderr, "DPlus Authorization failed: %s\n", gai_strerror(result));
return true;
}
return authenticate(m_loginCallsign, gwy_map, reflectors, repeaters);
return authenticate(gwy_map, reflectors, repeaters);
}
bool CDPlusAuthenticator::authenticate(const std::string &callsign, std::map<std::string, std::string> &gwy_map, const bool reflectors, const bool repeaters)
bool CDPlusAuthenticator::authenticate(std::map<std::string, std::string> &gwy_map, const bool reflectors, const bool repeaters)
{
unsigned char* buffer = new unsigned char[4096U];
::memset(buffer, ' ', 56U);
@ -64,7 +64,7 @@ bool CDPlusAuthenticator::authenticate(const std::string &callsign, std::map<std
buffer[2U] = 0x01U;
buffer[3U] = 0x00U;
::memcpy(buffer+4, callsign.c_str(), callsign.size());
::memcpy(buffer+4, m_loginCallsign.c_str(), m_loginCallsign.size());
::memcpy(buffer+12, "DV019999", 8);
::memcpy(buffer+28, "W7IB2", 5);
::memcpy(buffer+40, "DHS0257", 7);
@ -78,6 +78,7 @@ bool CDPlusAuthenticator::authenticate(const std::string &callsign, std::map<std
int ret = client.ReadExact(buffer, 2U);
size_t sofar = gwy_map.size();
unsigned int returned = 0;
while (ret == 2) {
unsigned int len = (buffer[1U] & 0x0FU) * 256U + buffer[0U];
@ -107,6 +108,7 @@ bool CDPlusAuthenticator::authenticate(const std::string &callsign, std::map<std
// An empty name or IP address or an inactive gateway/reflector is not added
if (address.size()>0U && name.size()>0U && active) {
returned++;
if (reflectors && 0==name.compare(0, 3, "REF"))
gwy_map[name] = address.append(" 20001");
else if (repeaters && name.compare(0, 3, "REF"))
@ -117,8 +119,9 @@ bool CDPlusAuthenticator::authenticate(const std::string &callsign, std::map<std
ret = client.ReadExact(buffer, 2U);
}
printf("Probably authorized DPlus with %s using callsign %s\n", m_address.c_str(), callsign.c_str());
printf("Added %u DPlus gateways\n", (unsigned int)(gwy_map.size() - sofar));
printf("Probably authorized DPlus on %s using callsign %s\n", m_address.c_str(), m_loginCallsign.c_str());
printf("%s returned %u system\n", m_address.c_str(), returned);
printf("The gateway map increased by %u additional DPlus gateways\n", (unsigned int)(gwy_map.size() - sofar));
client.Close();
delete[] buffer;

@ -36,5 +36,5 @@ private:
CTCPReaderWriterClient client;
void Trim(std::string &s);
bool authenticate(const std::string &callsign, std::map<std::string, std::string> &gwy_map, const bool reflectors, const bool repeaters);
bool authenticate(std::map<std::string, std::string> &gwy_map, const bool reflectors, const bool repeaters);
};

@ -585,6 +585,7 @@ bool CQnetLink::read_config(const char *cfgFile)
cfg.GetValue(key+"link2gate", estr, link2gate, 1, FILENAME_MAX);
cfg.GetValue("log_qso", estr, qso_details);
cfg.GetValue("log_debug", estr, log_debug);
key.assign("file_");
cfg.GetValue(key+"gwys", estr, gwys, 2, FILENAME_MAX);
@ -1786,6 +1787,8 @@ void CQnetLink::Process()
}
/* linked repeaters request */
} else if (length==4 && buf[0]==4 && buf[1]==192 && buf[2]==5 && buf[3]==0) {
if (log_debug)
printf("Got a linked repeater request!\n");
unsigned short i_idx = 0;
unsigned short j_idx = 0;
unsigned short k_idx = 0;
@ -1870,6 +1873,8 @@ void CQnetLink::Process()
}
/* connected user list request */
} else if (length==4 && buf[0]==4 && buf[1]==192 && buf[2]==6 && buf[3]==0) {
if (log_debug)
printf("Got a linked dongle request!!\n");
unsigned short i_idx = 0;
unsigned short j_idx = 0;
unsigned short k_idx = 0;
@ -1949,6 +1954,8 @@ void CQnetLink::Process()
}
/* date request */
} else if (length== 4 && buf[0]==4 && buf[1]==192 && buf[2]==8 && buf[3]==0) {
if (log_debug)
printf("Got a dongle time request!!\n");
time_t ltime;
struct tm tm;
@ -1973,6 +1980,8 @@ void CQnetLink::Process()
}
/* version request */
} else if (length== 4 && buf[0]==4 && buf[1]==192 && buf[2]==3 && buf[3]==0) {
if (log_debug)
printf("Got a version request!!\n");
auto pos = inbound_list.find(ip);
if (pos != inbound_list.end()) {
//SINBOUND *inbound = (SINBOUND *)pos->second;
@ -1986,6 +1995,8 @@ void CQnetLink::Process()
}
}
else if (length==5 && buf[0]==5 && buf[1]==0 && buf[2]==24 && buf[3]==0 && buf[4]==0) {
if (log_debug)
printf("Got a disconnect request!!\n");
/* reply with the same DISCONNECT */
sendto(ref_g2_sock, buf, 5, 0, (struct sockaddr *)&fromDst4, sizeof(struct sockaddr_in));

@ -84,7 +84,7 @@ private:
/* configuration data */
std::string login_call, owner, to_g2_external_ip, my_g2_link_ip, gwys, status_file, qnvoice_file, announce_dir;
bool only_admin_login, only_link_unlink, qso_details, bool_rptr_ack, announce;
bool only_admin_login, only_link_unlink, qso_details, log_debug, bool_rptr_ack, announce;
bool dplus_authorize, dplus_reflectors, dplus_repeaters, dplus_priority;
int rmt_xrf_port, rmt_ref_port, rmt_dcs_port, my_g2_link_port, to_g2_external_port, delay_between, delay_before;
std::string link_at_startup[3];

Loading…
Cancel
Save

Powered by TurnKey Linux.