You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

QDnsAxfrClient.h 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // Created by robin on 2/12/18.
  3. //
  4. #ifndef QDNSAGG_QDNSAXFRCLIENT_H
  5. #define QDNSAGG_QDNSAXFRCLIENT_H
  6. #include <QObject>
  7. #include <QHostAddress>
  8. #include "QDnsUdpClient.h"
  9. #include "QDnsTcpClient.h"
  10. namespace QDns
  11. {
  12. namespace Client
  13. {
  14. class QDnsAxfrClient : public QObject
  15. {
  16. Q_OBJECT
  17. public:
  18. enum ErrorCode
  19. {
  20. Unknown = 0,
  21. ClientError = 1,
  22. NoFirstSOA = 2,
  23. NoLastSOA = 3,
  24. ExtraRecords = 4
  25. };
  26. Q_ENUM(ErrorCode)
  27. struct OnAnswerParams
  28. {
  29. quint64 reserved;
  30. QList<QDns::Base::QDnsResourceRecord> records;
  31. };
  32. struct OnErrorParams
  33. {
  34. quint64 reserved;
  35. ErrorCode error;
  36. QDnsClient::OnErrorParams clientError;
  37. };
  38. explicit QDnsAxfrClient(const QString& zone, const QHostAddress& host, quint16 port = 53, QObject* parent = nullptr);
  39. signals:
  40. void onAnswer(OnAnswerParams);
  41. void onError(OnErrorParams);
  42. public slots:
  43. void transfer();
  44. private slots:
  45. void onClientStateChanged(const QDnsClient::OnStateChangedParams& params);
  46. void onClientAnswer(const QDnsClient::OnAnswerParams& params);
  47. void onClientError(const QDnsClient::OnErrorParams& params);
  48. private:
  49. enum AxfrStatus
  50. {
  51. FirstSOA,
  52. Records,
  53. LastSOA
  54. };
  55. void processPacket(const QDns::Base::QDnsPacket& packet);
  56. QString m_zone;
  57. AxfrStatus m_status;
  58. QDns::Client::QDnsUdpClient* m_udpClient;
  59. QDns::Client::QDnsTcpClient* m_tcpClient;
  60. QList<QDns::Base::QDnsResourceRecord> m_records;
  61. };
  62. }
  63. }
  64. #endif //QDNSAGG_QDNSAXFRCLIENT_H