- The first part

- Added CodeDocs config file for customization
- Fixing LGTM alerts
- LGTM bug fixed again
- added token option to hyperion-remote
- fix DBManager::getDB()
- next bugfix
- correct broken signal from SettingManager to Hyperion
- Token list is created after the schema is fetched

Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
Paulchen-Panther
2019-07-12 16:54:26 +02:00
parent 4fc745e748
commit ea796160af
72 changed files with 2546 additions and 485 deletions

54
include/utils/NetOrigin.h Normal file
View File

@@ -0,0 +1,54 @@
#pragma once
// qt
#include <QHostAddress>
#include <QJsonArray>
// utils
#include <utils/Logger.h>
#include <utils/settings.h>
///
/// @brief Checks the origin ip addresses for access allowed
///
class NetOrigin : public QObject
{
Q_OBJECT
private:
friend class HyperionDaemon;
NetOrigin(QObject* parent = 0, Logger* log = Logger::getInstance("NETWORK"));
public:
///
/// @brief Check if address is allowed to connect. The local address is the network adapter ip this connection comes from
/// @param address The peer address
/// @param local The local address of the socket (Differs based on NetworkAdapter IP or localhost)
/// @return True when allowed, else false
///
bool accessAllowed(const QHostAddress& address, const QHostAddress& local);
///
/// @brief Check if address is in subnet of local
/// @return True or false
///
bool isLocalAddress(const QHostAddress& address, const QHostAddress& local);
static NetOrigin* getInstance(){ return instance; };
static NetOrigin* instance;
private slots:
///
/// @brief Handle settings update from SettingsManager
/// @param type settingyType from enum
/// @param config configuration object
///
void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config);
private:
Logger* _log;
/// True when internet access is allowed
bool _internetAccessAllowed;
/// Whitelisted ip addresses
QList<QHostAddress> _ipWhitelist;
};