Files
amnezia-client/client/core/utils/networkUtilities.h
T

39 lines
1.4 KiB
C++
Raw Normal View History

2024-03-27 11:02:34 +00:00
#ifndef NETWORKUTILITIES_H
#define NETWORKUTILITIES_H
#include <QRegularExpression>
#include <QRegExp>
#include <QString>
2024-04-01 18:45:00 +07:00
#include <QHostAddress>
#include <QNetworkReply>
#include <QtNetwork/qnetworkinterface.h>
2024-03-27 11:02:34 +00:00
class NetworkUtilities : public QObject
{
Q_OBJECT
public:
static QString getIPAddress(const QString &host);
static QString getStringBetween(const QString &s, const QString &a, const QString &b);
static bool checkIPv4Format(const QString &ip);
static bool checkIpSubnetFormat(const QString &ip);
static bool checkIpv6Enabled();
static QPair<QString, QNetworkInterface> getGatewayAndIface();
2024-04-01 18:45:00 +07:00
// Returns the Interface Index that could Route to dst
static int AdapterIndexTo(const QHostAddress& dst);
2024-03-27 11:02:34 +00:00
static QRegularExpression ipAddressRegExp();
static QRegExp ipAddressWithSubnetRegExp();
static QRegExp ipNetwork24RegExp();
static QRegExp ipPortRegExp();
static QRegExp domainRegExp();
static QString netMaskFromIpWithSubnet(const QString ip);
static QString ipAddressFromIpWithSubnet(const QString ip);
static QStringList summarizeRoutes(const QStringList &ips, const QString cidr);
2026-05-07 22:30:18 +03:00
/// True for RFC1918 / IPv4 link-local / IPv6 ULA or IPv6 link-local (dev-only LAN gateway with tools/local_gateway).
static bool hostIsPrivateLanAddress(const QString &host);
2024-03-27 11:02:34 +00:00
};
#endif // NETWORKUTILITIES_H