diff --git a/reflector/CNotificationQueue.h b/reflector/CNotificationQueue.h
deleted file mode 100644
index f0bc210..0000000
--- a/reflector/CNotificationQueue.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright © 2015 Jean-Luc. All rights reserved.
-
-// urfd -- The universal reflector
-// Copyright © 2021 Thomas A. Early N7TAE
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-
-#pragma once
-
-#include
-#include
-
-#include "Notification.h"
-
-class CNotificationQueue
-{
-public:
- // constructor
- CNotificationQueue() {}
-
- // destructor
- ~CNotificationQueue() {}
-
- // lock
- void Lock() { m_Mutex.lock(); }
- void Unlock() { m_Mutex.unlock(); }
-
- // pass thru
- CNotification front() { return queue.front(); }
- void pop() { queue.pop(); }
- void push(CNotification note) { queue.push(note); }
- bool empty() const { return queue.empty(); }
-
-protected:
- // data
- std::mutex m_Mutex;
- std::queue queue;
-};
diff --git a/reflector/InterlinkMapItem.h b/reflector/InterlinkMapItem.h
index d0973fe..560ed0a 100644
--- a/reflector/InterlinkMapItem.h
+++ b/reflector/InterlinkMapItem.h
@@ -38,8 +38,8 @@ public:
CInterlinkMapItem(const char *addr, const char *mods, uint16_t port);
// Update things
- void UpdateIP(bool IPv6NotConfigured);
#ifndef NO_DHT
+ void UpdateIP(bool IPv6NotConfigured);
void UpdateItem(const std::string &cmods, const std::string &ipv4, const std::string &ipv6, uint16_t port, const std::string &tcmods);
#endif
@@ -69,6 +69,6 @@ private:
#ifndef NO_DHT
bool m_Updated;
- std::string m_CMods, m_IPv4, m_IPv6, m_TCMods;
+ std::string m_CMods, m_TCMods, m_IPv4, m_IPv6;
#endif
};
diff --git a/reflector/Notification.cpp b/reflector/Notification.cpp
deleted file mode 100644
index 6808a02..0000000
--- a/reflector/Notification.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright © 2015 Jean-Luc. All rights reserved.
-
-// urfd -- The universal reflector
-// Copyright © 2021 Thomas A. Early N7TAE
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-
-
-#include "Notification.h"
-
-CNotification::CNotification()
-{
- // init variables
- m_iId = NOTIFICATION_NONE;
-}
-
-CNotification::CNotification(int iId)
-{
- m_iId = iId;
-}
-
-CNotification::CNotification(int iId, const CCallsign &Callsign)
-{
- m_iId = iId;
- m_Callsign = Callsign;
-}
diff --git a/reflector/Notification.h b/reflector/Notification.h
deleted file mode 100644
index 3db4e0b..0000000
--- a/reflector/Notification.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright © 2015 Jean-Luc. All rights reserved.
-
-// urfd -- The universal reflector
-// Copyright © 2021 Thomas A. Early N7TAE
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-
-#pragma once
-
-#include "Callsign.h"
-
-////////////////////////////////////////////////////////////////////////////////////////
-
-// Id
-#define NOTIFICATION_NONE 0
-#define NOTIFICATION_CLIENTS 1
-#define NOTIFICATION_USERS 2
-#define NOTIFICATION_STREAM_OPEN 3
-#define NOTIFICATION_STREAM_CLOSE 4
-#define NOTIFICATION_PEERS 5
-
-////////////////////////////////////////////////////////////////////////////////////////
-// class
-
-class CNotification
-{
-public:
- // constructor
- CNotification();
- CNotification(int);
- CNotification(int, const CCallsign &);
-
- // get
- int GetId(void) const { return m_iId; }
- const CCallsign &GetCallsign(void) const { return m_Callsign; }
-
-protected:
- // data
- int m_iId;
- CCallsign m_Callsign;
-
-};
diff --git a/reflector/NotificationQueue.h b/reflector/NotificationQueue.h
deleted file mode 100644
index 70b894a..0000000
--- a/reflector/NotificationQueue.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright © 2015 Jean-Luc. All rights reserved.
-
-// urfd -- The universal reflector
-// Copyright © 2021 Thomas A. Early N7TAE
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-
-#pragma once
-
-#include
-#include
-
-#include "Notification.h"
-
-
-////////////////////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////////////////////
-// class
-
-class CNotificationQueue
-{
-public:
- // lock
- void Lock() { m_Mutex.lock(); }
- void Unlock() { m_Mutex.unlock(); }
-
- // pass thru
- CNotification front() { return queue.front(); }
- void pop() { queue.pop(); }
- void push(CNotification note) { queue.push(note); }
- bool empty() const { return queue.empty(); }
-
-protected:
- // data
- std::mutex m_Mutex;
- std::queue queue;
-};
diff --git a/reflector/Reflector.cpp b/reflector/Reflector.cpp
index 6367126..8c9a1c8 100644
--- a/reflector/Reflector.cpp
+++ b/reflector/Reflector.cpp
@@ -236,7 +236,7 @@ std::shared_ptr CReflector::OpenStream(std::unique_ptrPush(std::move(DvHeader));
// notify
- OnStreamOpen(stream->GetUserCallsign());
+ //OnStreamOpen(stream->GetUserCallsign());
}
return stream;
@@ -264,7 +264,7 @@ void CReflector::CloseStream(std::shared_ptr stream)
client->NotAMaster();
// notify
- OnStreamClose(stream->GetUserCallsign());
+ //OnStreamClose(stream->GetUserCallsign());
std::cout << "Closing stream of module " << GetStreamModule(stream) << std::endl;
}
@@ -381,48 +381,32 @@ void CReflector::XmlReportThread()
void CReflector::OnPeersChanged(void)
{
- CNotification notification(NOTIFICATION_PEERS);
-
- m_Notifications.Lock();
- m_Notifications.push(notification);
- m_Notifications.Unlock();
+#ifndef NO_DHT
+ PutDHTPeers();
+#endif
}
void CReflector::OnClientsChanged(void)
{
- CNotification notification(NOTIFICATION_CLIENTS);
-
- m_Notifications.Lock();
- m_Notifications.push(notification);
- m_Notifications.Unlock();
+#ifndef NO_DHT
+ PutDHTClients();
+#endif
}
void CReflector::OnUsersChanged(void)
{
- CNotification notification(NOTIFICATION_USERS);
-
- m_Notifications.Lock();
- m_Notifications.push(notification);
- m_Notifications.Unlock();
+#ifndef NO_DHT
+ PutDHTUsers();
+#endif
}
-void CReflector::OnStreamOpen(const CCallsign &callsign)
-{
- CNotification notification(NOTIFICATION_STREAM_OPEN, callsign);
+// void CReflector::OnStreamOpen(const CCallsign &callsign)
+// {
+// }
- m_Notifications.Lock();
- m_Notifications.push(notification);
- m_Notifications.Unlock();
-}
+// void CReflector::OnStreamClose(const CCallsign &callsign)
+// {
-void CReflector::OnStreamClose(const CCallsign &callsign)
-{
- CNotification notification(NOTIFICATION_STREAM_CLOSE, callsign);
-
- m_Notifications.Lock();
- m_Notifications.push(notification);
- m_Notifications.Unlock();
-}
////////////////////////////////////////////////////////////////////////////////////////
// modules & queues
diff --git a/reflector/Reflector.h b/reflector/Reflector.h
index 5292713..2f8376d 100644
--- a/reflector/Reflector.h
+++ b/reflector/Reflector.h
@@ -25,7 +25,6 @@
#include "Peers.h"
#include "Protocols.h"
#include "PacketStream.h"
-#include "NotificationQueue.h"
#ifndef NO_DHT
#include "urfd-dht-values.h"
@@ -80,8 +79,8 @@ public:
void OnPeersChanged(void);
void OnClientsChanged(void);
void OnUsersChanged(void);
- void OnStreamOpen(const CCallsign &);
- void OnStreamClose(const CCallsign &);
+ // void OnStreamOpen(const CCallsign &);
+ // void OnStreamClose(const CCallsign &);
#ifndef NO_DHT
// Publish DHT
@@ -124,9 +123,6 @@ protected:
std::unordered_map> m_RouterFuture;
std::future m_XmlReportFuture;
- // notifications
- CNotificationQueue m_Notifications;
-
#ifndef NO_DHT
// Distributed Hash Table
dht::DhtRunner node;
diff --git a/reflector/URFProtocol.cpp b/reflector/URFProtocol.cpp
index 42db8d6..35a6985 100644
--- a/reflector/URFProtocol.cpp
+++ b/reflector/URFProtocol.cpp
@@ -314,10 +314,49 @@ void CURFProtocol::HandlePeerLinks(void)
const auto cs = it->first;
if ((0 == cs.substr(0, 3).compare("URF")) && (nullptr==peers->FindPeer(CCallsign(cs), EProtocol::urf)))
{
- // send connect packet to re-initiate peer link
- EncodeConnectPacket(&buffer, it->second.GetModules().c_str());
- Send(buffer, it->second.GetIp(), it->second.GetPort());
- std::cout << "Sending connect packet to URF peer " << cs << " @ " << it->second.GetIp() << " for modules " << it->second.GetModules() << std::endl;
+#ifndef NO_DHT
+ it->second.UpdateIP(g_Configure.GetString(g_Keys.ip.ipv6address).empty());
+ if (it->second.GetIp().IsSet())
+ {
+ bool ok = true;
+ // does everything match up?
+ for (const auto c : it->second.GetModules())
+ {
+ if (std::string::npos == g_Configure.GetString(g_Keys.modules.modules).find(c))
+ { // is the local module not config'ed?
+ ok = false;
+ std::cerr << "This reflector has no module '" << c << "', so it can't interlink with " << it->first << std::endl;
+ }
+ else if (it->second.UsesDHT())
+ {
+ if (std::string::npos == it->second.GetCMods().find(c))
+ { // the remote module not config'ed!
+ ok = false;
+ std::cerr << it->first << " has no module '" << c << "'" << std::endl;
+ }
+ else if ((std::string::npos == it->second.GetTCMods().find(c)) != (std::string::npos == g_Configure.GetString(g_Keys.modules.tcmodules).find(c)))
+ { // are the transcoding states on both sides mismatched?
+ ok = false;
+ std::cerr << "The encryption states for module '" << c << "' don't match for this reflector and " << it->first << std::endl;
+ }
+ }
+ }
+ if (ok)
+ {
+
+#endif
+ // send connect packet to re-initiate peer link
+ EncodeConnectPacket(&buffer, it->second.GetModules().c_str());
+ Send(buffer, it->second.GetIp(), it->second.GetPort());
+ std::cout << "Sending connect packet to URF peer " << cs << " @ " << it->second.GetIp() << " for modules " << it->second.GetModules() << std::endl;
+#ifndef NO_DHT
+ }
+ }
+ else // m_Ip is not set!
+ {
+ g_Reflector.GetDHTConfig(it->first);
+ }
+#endif
}
}
diff --git a/reflector/Version.cpp b/reflector/Version.cpp
index 35d3c9d..4187f81 100644
--- a/reflector/Version.cpp
+++ b/reflector/Version.cpp
@@ -85,5 +85,8 @@ bool CVersion::operator <(const CVersion &v) const
std::ostream &operator <<(std::ostream &os, const CVersion &v)
{
os << v.GetMajor() << '.' << v.GetMinor() << '.' << v.GetRevision();
+#ifndef NO_DHT
+ os << "-dht";
+#endif
return os;
};