From 2159abb4187a7b2ba426889f1b4cd6baddbe56fc Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 26 Sep 2017 14:58:22 +0100 Subject: [PATCH] Simplify the format of the XLX Hosts file a little. --- Conf.cpp | 16 +++ Conf.h | 4 + DMRGateway.cpp | 14 ++- DMRGateway.h | 2 + DMRGateway.ini | 2 + Reflectors.cpp | 10 +- Reflectors.h | 6 +- XLXHosts.txt | 251 +++++++++++++++++++++++----------------------- XLXHostsupdate.sh | 4 +- 9 files changed, 167 insertions(+), 142 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 88c6ca3..70b8d9a 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -90,6 +90,8 @@ m_xlxNetworkEnabled(false), m_xlxNetworkId(0U), m_xlxNetworkFile(), m_xlxNetworkReloadTime(0U), +m_xlxNetworkPort(62030U), +m_xlxNetworkPassword("passw0rd"), m_xlxNetworkLocal(0U), m_xlxNetworkSlot(1U), m_xlxNetworkTG(8U), @@ -192,6 +194,10 @@ bool CConf::read() m_xlxNetworkFile = value; else if (::strcmp(key, "ReloadTime") == 0) m_xlxNetworkReloadTime = (unsigned int)::atoi(value); + else if (::strcmp(key, "Port") == 0) + m_xlxNetworkPort = (unsigned int)::atoi(value); + else if (::strcmp(key, "Password") == 0) + m_xlxNetworkPassword = value; else if (::strcmp(key, "Local") == 0) m_xlxNetworkLocal = (unsigned int)::atoi(value); else if (::strcmp(key, "Slot") == 0) @@ -486,6 +492,16 @@ unsigned int CConf::getXLXNetworkReloadTime() const return m_xlxNetworkReloadTime; } +unsigned int CConf::getXLXNetworkPort() const +{ + return m_xlxNetworkPort; +} + +std::string CConf::getXLXNetworkPassword() const +{ + return m_xlxNetworkPassword; +} + unsigned int CConf::getXLXNetworkLocal() const { return m_xlxNetworkLocal; diff --git a/Conf.h b/Conf.h index 8f58171..6a3deaf 100644 --- a/Conf.h +++ b/Conf.h @@ -124,6 +124,8 @@ public: unsigned int getXLXNetworkId() const; std::string getXLXNetworkFile() const; unsigned int getXLXNetworkReloadTime() const; + unsigned int getXLXNetworkPort() const; + std::string getXLXNetworkPassword() const; unsigned int getXLXNetworkLocal() const; unsigned int getXLXNetworkSlot() const; unsigned int getXLXNetworkTG() const; @@ -191,6 +193,8 @@ private: unsigned int m_xlxNetworkId; std::string m_xlxNetworkFile; unsigned int m_xlxNetworkReloadTime; + unsigned int m_xlxNetworkPort; + std::string m_xlxNetworkPassword; unsigned int m_xlxNetworkLocal; unsigned int m_xlxNetworkSlot; unsigned int m_xlxNetworkTG; diff --git a/DMRGateway.cpp b/DMRGateway.cpp index 9d44285..84ca190 100644 --- a/DMRGateway.cpp +++ b/DMRGateway.cpp @@ -144,6 +144,8 @@ m_xlxSlot(0U), m_xlxTG(0U), m_xlxBase(0U), m_xlxLocal(0U), +m_xlxPort(62030U), +m_xlxPassword("passw0rd"), m_xlxStartup(950U), m_xlxRoom(4000U), m_xlxRelink(1000U), @@ -1107,9 +1109,11 @@ bool CDMRGateway::createXLXNetwork() return false; } - m_xlxLocal = m_conf.getXLXNetworkLocal(); - m_xlxId = m_conf.getXLXNetworkId(); - m_xlxDebug = m_conf.getXLXNetworkDebug(); + m_xlxLocal = m_conf.getXLXNetworkLocal(); + m_xlxPort = m_conf.getXLXNetworkPort(); + m_xlxPassword = m_conf.getXLXNetworkPassword(); + m_xlxId = m_conf.getXLXNetworkId(); + m_xlxDebug = m_conf.getXLXNetworkDebug(); if (m_xlxId == 0U) m_xlxId = m_repeater->getId(); @@ -1124,10 +1128,12 @@ bool CDMRGateway::createXLXNetwork() LogInfo("XLX Network Parameters"); LogInfo(" Id: %u", m_xlxId); LogInfo(" Hosts file: %s", fileName.c_str()); + LogInfo(" Reload time: %u minutes", reloadTime); if (m_xlxLocal > 0U) LogInfo(" Local: %u", m_xlxLocal); else LogInfo(" Local: random"); + LogInfo(" Port: %u", m_xlxPort); LogInfo(" Slot: %u", m_xlxSlot); LogInfo(" TG: %u", m_xlxTG); LogInfo(" Base: %u", m_xlxBase); @@ -1164,7 +1170,7 @@ bool CDMRGateway::linkXLX(unsigned int number) m_xlxConnected = false; m_xlxRelink.stop(); - m_xlxNetwork = new CDMRNetwork(reflector->m_address, reflector->m_port, m_xlxLocal, m_xlxId, reflector->m_password, "XLX", m_xlxDebug); + m_xlxNetwork = new CDMRNetwork(reflector->m_address, m_xlxPort, m_xlxLocal, m_xlxId, m_xlxPassword, "XLX", m_xlxDebug); unsigned char config[400U]; unsigned int len = m_repeater->getConfig(config); diff --git a/DMRGateway.h b/DMRGateway.h index 6c3d89d..7f385f4 100644 --- a/DMRGateway.h +++ b/DMRGateway.h @@ -54,6 +54,8 @@ private: unsigned int m_xlxTG; unsigned int m_xlxBase; unsigned int m_xlxLocal; + unsigned int m_xlxPort; + std::string m_xlxPassword; unsigned int m_xlxStartup; unsigned int m_xlxRoom; CTimer m_xlxRelink; diff --git a/DMRGateway.ini b/DMRGateway.ini index 1a802ea..31d4fb9 100644 --- a/DMRGateway.ini +++ b/DMRGateway.ini @@ -25,6 +25,8 @@ Directory=./Audio [XLX Network] Enabled=1 File=XLXHosts.txt +Port=62030 +Password=passw0rd ReloadTime=60 # Local=3351 Slot=1 diff --git a/Reflectors.cpp b/Reflectors.cpp index ef6d338..308ccf5 100644 --- a/Reflectors.cpp +++ b/Reflectors.cpp @@ -59,17 +59,13 @@ bool CReflectors::load() char* p1 = ::strtok(buffer, ";\r\n"); char* p2 = ::strtok(NULL, ";\r\n"); - char* p3 = ::strtok(NULL, ";\r\n"); - char* p4 = ::strtok(NULL, ";\r\n"); - char* p5 = ::strtok(NULL, "\r\n"); + char* p3 = ::strtok(NULL, "\r\n"); - if (p1 != NULL && p2 != NULL && p3 != NULL && p4 != NULL && p5 != NULL) { + if (p1 != NULL && p2 != NULL && p3 != NULL) { CReflector* refl = new CReflector; refl->m_id = (unsigned int)::atoi(p1); refl->m_address = std::string(p2); - refl->m_port = (unsigned int)::atoi(p3); - refl->m_startup = (unsigned int)::atoi(p4); - refl->m_password = std::string(p5); + refl->m_startup = (unsigned int)::atoi(p3); m_reflectors.push_back(refl); } } diff --git a/Reflectors.h b/Reflectors.h index cac5f84..fbf4614 100644 --- a/Reflectors.h +++ b/Reflectors.h @@ -29,17 +29,13 @@ public: CReflector() : m_id(0U), m_address(), - m_port(0U), - m_startup(0U), - m_password() + m_startup(0U) { } unsigned int m_id; std::string m_address; - unsigned int m_port; unsigned int m_startup; - std::string m_password; }; class CReflectors { diff --git a/XLXHosts.txt b/XLXHosts.txt index ffc49e6..5494317 100644 --- a/XLXHosts.txt +++ b/XLXHosts.txt @@ -1,125 +1,128 @@ # The format of this file is: -# XLX Number;host;port;default;password -000;206.208.56.92;62030;4004;passw0rd -001;77.57.43.220;62030;4004;passw0rd -002;64.137.191.177;62030;4004;passw0rd -004;44.103.34.3;62030;4004;passw0rd -007;212.227.203.37;62030;4004;passw0rd -015;176.10.105.212;62030;4004;passw0rd -017;81.169.228.115;62030;4004;passw0rd -018;149.202.61.56;62030;4004;passw0rd -020;94.177.164.25;62030;4004;passw0rd -022;83.137.45.116;62030;4004;passw0rd -023;185.177.59.166;62030;4004;passw0rd -024;94.199.172.148;62030;4004;passw0rd -031;185.122.56.190;62030;4004;passw0rd -039;185.203.118.66;62030;4004;passw0rd -040;109.71.45.29;62030;4004;passw0rd -046;176.10.140.161;62030;4004;passw0rd -047;121.94.218.243;62030;4004;passw0rd -051;93.186.254.219;62030;4004;passw0rd -060;212.237.36.181;62030;4004;passw0rd -064;202.241.175.133;62030;4004;passw0rd -068;92.222.145.202;62030;4004;passw0rd -069;89.36.214.120;62030;4004;passw0rd -075;5.135.162..136;62030;4004;passw0rd -076;203.137.116.117;62030;4004;passw0rd -078;109.10.128.221;62030;4004;passw0rd -079;121.162.91.94;62030;4004;passw0rd -087;44.137.36.209;62030;4004;passw0rd -088;194.109.192.235;62030;4004;passw0rd -089;194.109.192.236;62030;4004;passw0rd -090;91.92.136.252;62030;4004;passw0rd -095;58.1.93.223;62030;4004;passw0rd -099;212..237.59.103;62030;4004;passw0rd -100;96.94.7.196;62030;4004;passw0rd -101;104.233.105.86;62030;4004;passw0rd -103;64.137.248.42;62030;4004;passw0rd -104;206.208.56.93;62030;4004;passw0rd -111;61.214.140.24;62030;4004;passw0rd -112;216.45.55.151;62030;4004;passw0rd -114;91.121.136.94;62030;4004;passw0rd -118;5.249.148.252;62030;4004;passw0rd -121;174.37.249.156;62030;4004;passw0rd -124;211.14.169.234;62030;4004;passw0rd -145;178.59.23.138;62030;4004;passw0rd -170;210.178.113.173;62030;4004;passw0rd -171;121.162.91.45;62030;4004;passw0rd -206;193.190.240.227;62030;4004;passw0rd -208;151.80.155.39;62030;4004;passw0rd -210;45.62.210.243;62030;4004;passw0rd -214;185.47.129.230;62030;4004;passw0rd -222;93.189.136.50;62030;4004;passw0rd -228;212.237.33.114;62030;4004;passw0rd -232;213.47.219.169;62030;4004;passw0rd -241;151.80.158.227;62030;4004;passw0rd -246;172.93.48.159;62030;4004;passw0rd -248;158.69.206.45;62030;4004;passw0rd -255;245.115.35.52;62030;4004;passw0rd -265;51.255.43.60;62030;4004;passw0rd -270;158.64.26..132;62030;4004;passw0rd -291;60.112.168.104;62030;4004;passw0rd -295;45.62.238.78;62030;4004;passw0rd -298;122.131.154.87;62030;4004;passw0rd -299;125.236.227.43;62030;4004;passw0rd -300;64.137.172.56;62030;4004;passw0rd -307;104.36.40.243;62030;4004;passw0rd -311;78.47.206.12;62030;4004;passw0rd -313;34.213.108.164;62030;4001;passw0rd -339;198.98.53.247;62030;4004;passw0rd -357;52.39.82.54;62030;4004;passw0rd -359;79.232.250.96;62030;4004;passw0rd -365;59.139.141.204;62030;4004;passw0rd -373;101.143.24.88;62030;4004;passw0rd -382;61.116.7.187;62030;4004;passw0rd -389;xlxdmr.duckdns.org;62030;4004;passw0rd -390;31.14.140.230;62030;4004;passw0rd -398;45.62.243.153;62030;4004;passw0rd -412;42.151.97.55;62030;4004;passw0rd -441;203.137.99.110;62030;4004;passw0rd -444;188.68.37.51;62030;4004;passw0rd -450;64.137.161.11;62030;4004;passw0rd -486;51.255.172.249;62030;4004;passw0rd -502;74..208.88.137;62030;4004;passw0rd -518;176.9.1.168;62030;4004;passw0rd -538;133.137.49.171;62030;4004;passw0rd -550;151.80.141.175;62030;4004;passw0rd -555;64.137.186..11;62030;4004;passw0rd -569;58.70.25.88;62030;4004;passw0rd -595;218.226.193.157;62030;4004;passw0rd -601;51.141.52.193;62030;4004;passw0rd -626;202.137.244.157;62030;4004;passw0rd -706;93.186.255.126;62030;4004;passw0rd -707;90.145.156.196;62030;4004;passw0rd -708;202.218.37.62;62030;4004;passw0rd -709;212.237.34.32;62030;4004;passw0rd -711;212.237..18.27;62030;4004;passw0rd -714;85.214.119.76;62030;4004;passw0rd -724;191.232.36.180;62030;4004;passw0rd -746;178.254.34.44;62030;4004;passw0rd -750;203.86.206.49;62030;4004;passw0rd -766;201.62.48.61;62030;4004;passw0rd -773;94.177.175.230;62030;4004;passw0rd -781;175.179.238.153;62030;4004;passw0rd -801;77.117.214.188;62030;4004;passw0rd -812;126.25.168.252;62030;4004;passw0rd -813;97.76.81.165;62030;4004;passw0rd -850;88.198.94.77;62030;4004;passw0rd -886;118.163.103.178;62030;4004;passw0rd -887;118.163.103..177;62030;4004;passw0rd -888;31.14.135.7;62030;4004;passw0rd -897;212.237.2.183;62030;4004;passw0rd -908;92.222.23.124;62030;4004;passw0rd -909;216.86.147.198;62030;4004;passw0rd -911;5..196.73.89;62030;4004;passw0rd -929;158.69.166.132;62030;4004;passw0rd -930;94.177.160.5;62030;4004;passw0rd -933;37.59.119.115;62030;4004;passw0rd -940;202.218.37.121;62030;4004;passw0rd -950;xlx950.epf.lu;62030;4005;passw0rd -967;95.158.165.32;62030;4004;passw0rd -974;94.177.217.52;62030;4004;passw0rd -976;212.237.36.71;62030;4004;passw0rd -989;75..110.247.252;62030;4004;passw0rd -995;142.116.255.245;62030;4004;passw0rd -997;94.177.187.40;62030;4004;passw0rd +# XLX Number;host;default +000;206.208.56.92;4004 +001;77.57.43.220;4004 +002;64.137.191.177;4004 +004;44.103.34.3;4004 +006;66.154.105.126;4004 +007;212.227.203.37;4004 +011;81.95.126.168;4004 +015;176.10.105.212;4004 +017;81.169.228.115;4004 +018;149.202.61.56;4004 +020;94.177.164.25;4004 +022;83.137.45.116;4004 +023;185.177.59.166;4004 +024;94.199.172.148;4004 +031;185.122.56.190;4004 +039;185.203.118.66;4004 +040;109.71.45.29;4004 +046;176.10.140.161;4004 +047;121.94.218.243;4004 +051;93.186.254.219;4004 +060;212.237.36.181;4004 +064;202.241.175.133;4004 +068;92.222.145.202;4004 +069;89.36.214.120;4004 +075;5.135.162.136;4004 +076;203.137.116.117;4004 +078;109.10.128.221;4004 +079;121.162.91.94;4004 +087;44.137.36.209;4004 +088;194.109.192.235;4004 +089;194.109.192.236;4004 +090;91.92.136.252;4004 +095;58.1.93.223;4004 +098;111.168.208.169;4004 +099;212.237.59.103;4004 +100;96.94.7.196;4004 +101;104.233.105.86;4004 +103;64.137.248.42;4004 +104;206.208.56.93;4004 +111;61.214.140.24;4004 +112;80.211.236.189;4004 +114;91.121.136.94;4004 +118;5.249.148.252;4004 +121;174.37.249.156;4004 +124;211.14.169.234;4004 +145;178.59.23.138;4004 +170;210.178.113.173;4004 +171;121.162.91.45;4004 +206;193.190.240.227;4004 +208;151.80.155.39;4004 +210;45.62.210.243;4004 +214;185.47.129.230;4004 +222;93.189.136.50;4004 +228;212.237.33.114;4004 +232;213.47.219.169;4004 +241;151.80.158.227;4004 +246;172.93.48.159;4004 +255;245.115.35.52;4004 +265;51.255.43.60;4004 +270;158.64.26.132;4004 +291;60.112.168.104;4004 +295;45.62.238.78;4004 +298;122.131.152.178;4004 +299;125.236.227.43;4004 +300;64.137.172.56;4004 +307;104.36.40.243;4004 +311;78.47.206.12;4004 +313;34.213.108.164;4001 +339;198.98.53.247;4004 +357;52.39.82.54;4004 +359;79.232.250.96;4004 +365;59.139.141.204;4004 +373;101.143.24.88;4004 +382;61.116.7.187;4004 +389;106.71.106.79;4004 +390;31.14.140.230;4004 +398;45.62.243.153;4004 +412;42.151.97.55;4004 +441;203.137.99.110;4004 +444;188.68.37.51;4004 +450;64.137.161.11;4004 +486;51.255.172.249;4004 +499;59.157.4.151;4004 +502;74.208.88.137;4004 +518;176.9.1.168;4004 +538;133.137.49.171;4004 +550;151.80.141.175;4004 +555;64.137.186.11;4004 +569;58.70.25.88;4004 +595;218.226.193.157;4004 +601;51.141.52.193;4004 +626;202.137.244.157;4004 +706;93.186.255.126;4004 +707;90.145.156.196;4004 +708;202.218.37.62;4004 +709;212.237.34.32;4004 +711;212.237.18.27;4004 +714;85.214.119.76;4004 +724;191.232.36.180;4004 +746;178.254.34.44;4004 +750;203.86.206.49;4004 +766;201.62.48.61;4004 +773;94.177.175.230;4004 +781;175.179.238.153;4004 +801;77.117.214.188;4004 +812;126.25.168.252;4004 +813;97.76.81.165;4004 +850;88.198.94.77;4004 +886;118.163.103.178;4004 +887;118.163.103.177;4004 +888;31.14.135.7;4004 +897;212.237.2.183;4004 +908;92.222.23.124;4004 +909;216.86.147.198;4004 +911;5.196.73.89;4004 +929;158.69.166.132;4004 +930;94.177.160.5;4004 +933;37.59.119.115;4004 +940;202.218.37.121;4004 +950;158.64.26.134;4005 +967;95.158.165.32;4004 +974;94.177.217.52;4004 +976;212.237.36.71;4004 +989;75.110.247.252;4004 +995;142.116.255.245;4004 +997;94.177.187.40;4004 diff --git a/XLXHostsupdate.sh b/XLXHostsupdate.sh index b8fbf74..d79ed2f 100644 --- a/XLXHostsupdate.sh +++ b/XLXHostsupdate.sh @@ -86,7 +86,7 @@ fi curl http://xlxapi.rlx.lu/api.php?do=GetXLXDMRMaster | awk ' BEGIN { print "# The format of this file is:" - print "# XLX Number;host;port;default;password" + print "# XLX Number;host;default" } /^XLX/ { reflector=4004 @@ -94,7 +94,7 @@ BEGIN { reflector=4001 if ($1 == "XLX950") reflector=4005 - printf "%s;%s;62030;%d;passw0rd\n", substr($1,4), $2, reflector + printf "%s;%s;%d\n", substr($1,4), $2, reflector }' > ${XLXHOSTS} exit 0