diff --git a/dashboard/img/flags/nie.png b/dashboard/img/flags/nie.png new file mode 100755 index 0000000..83c133d Binary files /dev/null and b/dashboard/img/flags/nie.png differ diff --git a/dashboard/pgs/country.csv b/dashboard/pgs/country.csv old mode 100644 new mode 100755 index 2d1d6c1..0d140b8 --- a/dashboard/pgs/country.csv +++ b/dashboard/pgs/country.csv @@ -6,7 +6,7 @@ American Samoa;AS;KH8 Andorra;AD;C3 Angola;AO;D2-D3 Anguilla;AI;VP2E -Antarctica;AQ;CE9-KC4 +Antarctica;AQ;CE9 Antigua and Barbuda;AG;V2 Argentina;AR;LO-LP-LQ-LR-LS-LT-LU-LV-LW Armenia;AM;EK @@ -104,7 +104,7 @@ India;IN;VU Indonesia;ID;YB-YC-YD-YE-YF-YG-YH Iran Islamic Republic of;IR;EP-EQ Iraq;IQ;YI -Ireland;IE;EI-EJ-MI-GI +Ireland;IE;EI-EJ Isle of Man;IM;GD-GT Israel;IL;4X-4Z Italy;IT;I0-I1-I2-I3-I4-I5-I6-I7-I8-I9-IK-IN-IQ-IR-IS-IT-IU-IV-IW-IZ @@ -162,6 +162,7 @@ Niger;NE;5U Nigeria;NG;5N Niue;NU;ZK2 Norfolk Island;NF;VK9N +Northern Ireland;NIE;GI-MI Northern Mariana Islands;MP;KH0 Norway;NO;LA-LB-LC-LD-LE-LF-LG-LH-LI-LJ-LK-LL-LM-LN Oman;OM;YP-YQ-YR @@ -174,7 +175,7 @@ Paraguay;PY;ZP Peru;PE;OA-OB-OC Philippines;PH;DU-DV-DW-DX-DY-DZ-4D-4E-4F-4G-4H-4I Pitcairn;PN;VP6 -Poland;PL;SN-SO-SP-SQ-SR +Poland;PL;3Z6-SN-SO-SP-SQ-SR Portugal;PT;CT-CU3 Puerto Rico;PR;KP3-KP4 Qatar;QA;A7 @@ -234,7 +235,7 @@ Uganda;UG;5X Ukraine;UA;UR-US-UT-UU-UV-UW-UX-UY-UZ United Arab Emirates;AE;A6 United Kingdom;GB;2E-M0-M1-M2-M3-M4-M5-M6-M7-M8-M9-MB-MM-G0-G1-G2-G3-G4-G5-G6-G7-G8-G9-GX -United States;US;K0-K1-K2-K3-K4-K5-K6-K7-K8-K9-KA-KB-KC-KD-KE-KF-KG-KI-KJ-KK-KM-KN-KO-KQ-KR-KS-KT-KU-KV-KW-KX-KY-KZ-W0-W1-W2-W3-W4-W5-W6-W7-W8-W9-WA-WB-WD-WV-WX-WZ-N0-N1-N2-N3-N4-N5-N6-N7-N8-N9-NE-NN-NO-NS-AA-AB-AC-AD-AE-AF-AG-AH-AI-AJ-AK +United States;US;K0-K1-K2-K3-K4-K5-K6-K7-K8-K9-KA-KB-KC-KD-KE-KF-KG-KI-KJ-KK-KM-KN-KO-KQ-KR-KS-KT-KU-KV-KW-KX-KY-KZ-W0-W1-W2-W3-W4-W5-W6-W7-W8-W9-WA-WB-WD-WF-WR-WV-WX-WZ-N0-N1-N2-N3-N4-N5-N6-N7-N8-N9-NE-NG-NN-NO-NQ-NS-NW-AA-AB-AC-AD-AE-AF-AG-AH-AI-AJ-AK United States Minor Outlying Islands;UM; Uruguay;UY;CV-CW-CX Uzbekistan;UZ;UJ-UK-UL-UM diff --git a/readme b/readme index d5287d7..0f46729 100644 --- a/readme +++ b/readme @@ -52,7 +52,7 @@ Debian 7 (Wheezy) 32 and 64bit: # make clean # make install -// copy startup script "xlxd" to /etc/init.d +// copy startup script "xlxd" to /etc/init.d # cp ~/xlxd/scripts/xlxd /etc/init.d/xlxd // adapt the default startup parameters to your needs diff --git a/src/cdcsprotocol.cpp b/src/cdcsprotocol.cpp index 0765c24..bab9cf1 100644 --- a/src/cdcsprotocol.cpp +++ b/src/cdcsprotocol.cpp @@ -124,18 +124,30 @@ void CDcsProtocol::Task(void) std::cout << "DCS connect packet for module " << ToLinkModule << " from " << Callsign << " at " << Ip << std::endl; // callsign authorized? - if ( g_GateKeeper.MayLink(Callsign, Ip, PROTOCOL_DCS) ) + if ( g_GateKeeper.MayLink(Callsign, Ip, PROTOCOL_DCS) && g_Reflector.IsValidModule(ToLinkModule) ) { - // acknowledge the request - EncodeConnectAckPacket(Callsign, ToLinkModule, &Buffer); - m_Socket.Send(Buffer, Ip); - - // create the client - CDcsClient *client = new CDcsClient(Callsign, Ip, ToLinkModule); - - // and append - g_Reflector.GetClients()->AddClient(client); - g_Reflector.ReleaseClients(); + // valid module ? + if ( g_Reflector.IsValidModule(ToLinkModule) ) + { + // acknowledge the request + EncodeConnectAckPacket(Callsign, ToLinkModule, &Buffer); + m_Socket.Send(Buffer, Ip); + + // create the client + CDcsClient *client = new CDcsClient(Callsign, Ip, ToLinkModule); + + // and append + g_Reflector.GetClients()->AddClient(client); + g_Reflector.ReleaseClients(); + } + else + { + std::cout << "DCS node " << Callsign << " connect attempt on non-existing module" << std::endl; + + // deny the request + EncodeConnectNackPacket(Callsign, ToLinkModule, &Buffer); + m_Socket.Send(Buffer, Ip); + } } else { @@ -149,12 +161,16 @@ void CDcsProtocol::Task(void) { std::cout << "DCS disconnect packet from " << Callsign << " at " << Ip << std::endl; - // find client & remove it + // find client CClients *clients = g_Reflector.GetClients(); CClient *client = clients->FindClient(Ip, PROTOCOL_DCS); if ( client != NULL ) { + // remove it clients->RemoveClient(client); + // and acknowledge the disconnect + EncodeConnectNackPacket(Callsign, ' ', &Buffer); + m_Socket.Send(Buffer, Ip); } g_Reflector.ReleaseClients(); } diff --git a/src/cdextraprotocol.cpp b/src/cdextraprotocol.cpp index 4708603..43c1123 100644 --- a/src/cdextraprotocol.cpp +++ b/src/cdextraprotocol.cpp @@ -112,16 +112,28 @@ void CDextraProtocol::Task(void) // callsign authorized? if ( g_GateKeeper.MayLink(Callsign, Ip, PROTOCOL_DEXTRA) ) { - // acknowledge the request - EncodeConnectAckPacket(&Buffer, ProtRev); - m_Socket.Send(Buffer, Ip); - - // create the client - CDextraClient *client = new CDextraClient(Callsign, Ip, ToLinkModule, ProtRev); - - // and append - g_Reflector.GetClients()->AddClient(client); - g_Reflector.ReleaseClients(); + // valid module ? + if ( g_Reflector.IsValidModule(ToLinkModule) ) + { + // acknowledge the request + EncodeConnectAckPacket(&Buffer, ProtRev); + m_Socket.Send(Buffer, Ip); + + // create the client + CDextraClient *client = new CDextraClient(Callsign, Ip, ToLinkModule, ProtRev); + + // and append + g_Reflector.GetClients()->AddClient(client); + g_Reflector.ReleaseClients(); + } + else + { + std::cout << "DExtra node " << Callsign << " connect attempt on non-existing module" << std::endl; + + // deny the request + EncodeConnectNackPacket(&Buffer); + m_Socket.Send(Buffer, Ip); + } } else { diff --git a/src/cdplusprotocol.cpp b/src/cdplusprotocol.cpp index 03427c5..f56ab7f 100644 --- a/src/cdplusprotocol.cpp +++ b/src/cdplusprotocol.cpp @@ -202,36 +202,44 @@ bool CDplusProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip) // no stream open yet, open a new one CCallsign via(Header->GetRpt1Callsign()); - // find this client - CClient *client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_DPLUS); - if ( client != NULL ) + // first, check module is valid + if ( g_Reflector.IsValidModule(Header->GetRpt1Module()) ) { - // now we knwo if it's a dextra dongle or a genuine dplus node - if ( Header->GetRpt2Callsign().HasSameCallsignWithWidlcard(CCallsign("XRF*")) ) + // find this client + CClient *client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_DPLUS); + if ( client != NULL ) { - client->SetDextraDongle(); - } - // now we know its module, let's update it - if ( !client->HasModule() ) - { - client->SetModule(Header->GetRpt1Module()); - } - // get client callsign - via = client->GetCallsign(); - // and try to open the stream - if ( (stream = g_Reflector.OpenStream(Header, client)) != NULL ) - { - // keep the handle - m_Streams.push_back(stream); - newstream = true; + // now we know if it's a dextra dongle or a genuine dplus node + if ( Header->GetRpt2Callsign().HasSameCallsignWithWidlcard(CCallsign("XRF*")) ) + { + client->SetDextraDongle(); + } + // now we know its module, let's update it + if ( !client->HasModule() ) + { + client->SetModule(Header->GetRpt1Module()); + } + // get client callsign + via = client->GetCallsign(); + // and try to open the stream + if ( (stream = g_Reflector.OpenStream(Header, client)) != NULL ) + { + // keep the handle + m_Streams.push_back(stream); + newstream = true; + } } + // release + g_Reflector.ReleaseClients(); + + // update last heard + g_Reflector.GetUsers()->Hearing(Header->GetMyCallsign(), via); + g_Reflector.ReleaseUsers(); + } + else + { + std::cout << "DPlus node " << via << " link attempt on non-existing module" << std::endl; } - // release - g_Reflector.ReleaseClients(); - - // update last heard - g_Reflector.GetUsers()->Hearing(Header->GetMyCallsign(), via); - g_Reflector.ReleaseUsers(); } else { diff --git a/src/creflector.h b/src/creflector.h index 2370280..341a1a2 100644 --- a/src/creflector.h +++ b/src/creflector.h @@ -77,7 +77,7 @@ public: void ReleaseUsers(void) { m_Users.Unlock(); } // get - bool IsValidModule(char c) const { return true; } + bool IsValidModule(char c) const { return (GetModuleIndex(c) >= 0); } int GetModuleIndex(char) const; char GetModuleLetter(int i) const { return 'A' + (char)i; } diff --git a/src/cxlxprotocol.cpp b/src/cxlxprotocol.cpp index 9643bdb..b277925 100644 --- a/src/cxlxprotocol.cpp +++ b/src/cxlxprotocol.cpp @@ -131,11 +131,8 @@ void CXlxProtocol::Task(void) m_Socket.Send(Buffer, Ip); } } - // done g_Reflector.ReleaseClients(); - - } else if ( IsValidDisconnectPacket(Buffer, &Callsign) ) { @@ -223,12 +220,10 @@ void CXlxProtocol::HandleQueue(void) { // is this client busy ? // here check that origin module of the stream is listed in client xlx - // TODO: and check that client of origin is not another XLX to avoid loops if ( !client->IsAMaster() && client->HasThisReflectorModule(packet->GetModuleId()) ) { // no, send the packet m_Socket.Send(buffer, client->GetIp()); - } } g_Reflector.ReleaseClients(); @@ -278,8 +273,7 @@ void CXlxProtocol::HandleKeepalives(void) // remove it std::cout << "XLX peer " << client->GetCallsign() << " keepalive timeout" << std::endl; clients->RemoveClient(client); - } - + } } g_Reflector.ReleaseClients(); } diff --git a/src/main.h b/src/main.h index ab40281..b99a70b 100644 --- a/src/main.h +++ b/src/main.h @@ -48,7 +48,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 -#define VERSION_REVISION 5 +#define VERSION_REVISION 6 // global ------------------------------------------------------ @@ -57,7 +57,7 @@ // reflector --------------------------------------------------- -#define NB_OF_MODULES 4 +#define NB_OF_MODULES 8 // protocols --------------------------------------------------- @@ -87,8 +87,8 @@ // XLX #define XLX_PORT 10002 // UDP port -#define XLX_KEEPALIVE_PERIOD 3 // in seconds -#define XLX_KEEPALIVE_TIMEOUT (XLX_KEEPALIVE_PERIOD*10) // in seconds +#define XLX_KEEPALIVE_PERIOD 1 // in seconds +#define XLX_KEEPALIVE_TIMEOUT (XLX_KEEPALIVE_PERIOD*30) // in seconds // xml & json reporting -----------------------------------------