mtproto_proxy_data.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. namespace MTP {
  9. struct ProxyData {
  10. enum class Settings {
  11. System,
  12. Enabled,
  13. Disabled,
  14. };
  15. enum class Type {
  16. None,
  17. Socks5,
  18. Http,
  19. Mtproto,
  20. };
  21. enum class Status {
  22. Valid,
  23. Unsupported,
  24. Invalid,
  25. };
  26. Type type = Type::None;
  27. QString host;
  28. uint32 port = 0;
  29. QString user, password;
  30. std::vector<QString> resolvedIPs;
  31. crl::time resolvedExpireAt = 0;
  32. [[nodiscard]] bool valid() const;
  33. [[nodiscard]] Status status() const;
  34. [[nodiscard]] bool supportsCalls() const;
  35. [[nodiscard]] bool tryCustomResolve() const;
  36. [[nodiscard]] bytes::vector secretFromMtprotoPassword() const;
  37. [[nodiscard]] explicit operator bool() const;
  38. [[nodiscard]] bool operator==(const ProxyData &other) const;
  39. [[nodiscard]] bool operator!=(const ProxyData &other) const;
  40. [[nodiscard]] static bool ValidMtprotoPassword(const QString &password);
  41. [[nodiscard]] static Status MtprotoPasswordStatus(
  42. const QString &password);
  43. };
  44. [[nodiscard]] ProxyData ToDirectIpProxy(
  45. const ProxyData &proxy,
  46. int ipIndex = 0);
  47. [[nodiscard]] QNetworkProxy ToNetworkProxy(const ProxyData &proxy);
  48. } // namespace MTP