default port depenods on protocol

pull/2/head
Tom Early 3 years ago
parent 5972139ce8
commit c017be2207

@ -5,13 +5,16 @@
# Each entry specifies a remote URF to peer with.
# If no Port is specified, 10017 will be used.
# If DHT is enabled and the target is also DHT-enabled, then you only
# need to specify the URF-Callsign and the Shared-Modules
# format:
# need to specify the URF-Callsign and the Shared-Modules.
# Format:
# <URF-Callsign> <IP-Address> <Shared-Mdoules> <Port>
# examples:
# Examples:
# URF270 158.64.26.132 EF
# URF280 ABC
#
# note: The remote URFD must list this in its interlink file
# Brandmeister links use three params, no port is specified. Example:
# BM3104 162.248.88.117 E
#
# note: Remote URFD must list this in its interlink file
# for the link to be established.
#############################################################################

@ -65,6 +65,8 @@ bool CInterlinkMap::LoadFromFile(const std::string &filename)
{
if (strcmp(token[0], g_Configure.GetString(g_Keys.names.callsign).c_str()))
{
// the default port depends on the protocol type (URF or BM)
int default_port = (0 == memcmp(token[0], "URF", 3)) ? 10017 : 10002;
if (m_InterlinkMap.end() == m_InterlinkMap.find(token[0]))
{
// read remaining tokens
@ -77,17 +79,16 @@ bool CInterlinkMap::LoadFromFile(const std::string &filename)
if (token[2])
{
int port = 10017;
int port = default_port;
if (token[3])
{
port = std::atoi(token[3]);
if (port < 1024 || port > 49000)
{
std::cout << token[0] << " Port " << port << " is out of range, resetting to 10017." << std::endl;
port = 10017;
std::cout << token[0] << " Port " << port << " is out of range, resetting to " << default_port << std::endl;
port = default_port;
}
}
std::cout << "USING PORT " << port << std::endl;
m_InterlinkMap[token[0]] = CInterlinkMapItem(token[1], token[2], (uint16_t)port);
}
#ifndef NO_DHT

Loading…
Cancel
Save

Powered by TurnKey Linux.