resolver.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef MAINSERVER_H
  2. #define MAINSERVER_H
  3. #include "jsonanswer.h"
  4. #include <QObject>
  5. #include <QTcpServer>
  6. #include <QHostAddress>
  7. #include <QSharedPointer>
  8. const size_t ADDRIPV6_SIZE = 16;
  9. typedef std::array<uint8_t, ADDRIPV6_SIZE> Address;
  10. class Resolver : public QObject
  11. {
  12. Q_OBJECT
  13. public:
  14. explicit Resolver(const QString&, quint16, QObject* parent = nullptr);
  15. void disableAPI();
  16. void disableWebPage();
  17. void disableResolv();
  18. private slots:
  19. void slotNewUser();
  20. void slotReadyClient();
  21. private:
  22. QTcpServer* m_tcpServer;
  23. QHostAddress m_address;
  24. quint16 m_port;
  25. void convertStrToRaw(const QString& str, Address& array);
  26. QString getBase32(const Address& rawAddr);
  27. QString decodeMeshToIP(const QString& meshname);
  28. std::string pickupStringForMeshname(std::string str);
  29. QString getAddress(const Address& rawAddr);
  30. void startPage(QSharedPointer<QTextStream>, bool);
  31. void startPageWithMessage(const QString &, QSharedPointer<QTextStream>, const QString&, bool);
  32. void processPage(const QString&, QSharedPointer<QTextStream>, bool);
  33. void toMeship(const QString&, QSharedPointer<QTextStream>, bool);
  34. void toIp(const QString&, QSharedPointer<QTextStream>, bool);
  35. void toRealResolv(const QString&, QSharedPointer<QTextStream>, bool);
  36. void toVersion(const QString&, QSharedPointer<QTextStream>, bool);
  37. bool m_NoApi;
  38. bool m_NoHttp;
  39. bool m_NoResolve;
  40. };
  41. #endif // MAINSERVER_H