tunnelconstructor.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #include "notepad.h"
  3. #include "tunneltype.h"
  4. #include <string>
  5. class TunnelConstructor
  6. {
  7. public:
  8. struct Pair
  9. {
  10. int8_t inbound = 3;
  11. int8_t outbound = 3;
  12. };
  13. TunnelConstructor();
  14. bool setName(std::string name);
  15. bool setTunnelType(TunnelType type);
  16. bool setLength(int8_t inbound, int8_t outbound);
  17. bool setLengthVariance(int8_t inbound, int8_t outbound);
  18. bool setQuantity(int8_t inbound, int8_t outbound);
  19. bool setBlindedLeaseSet(bool isBlinded);
  20. bool setTransient(bool isTransient);
  21. bool setKeepAlive(int8_t interval);
  22. bool setComments(bool enabled);
  23. std::string name() const { return name_; }
  24. TunnelType tunnelType() const { return tunnelType_; }
  25. Pair length() const { return length_; }
  26. Pair lengthVariance() const { return lengthVariance_; }
  27. Pair quantity() const { return quantity_; }
  28. bool isBlinded() const { return blinded_; }
  29. bool isTransient() const { return transient_; }
  30. uint8_t keepAliveInterval() const { return keepAliveInterval_; }
  31. bool isCommentsEnabled() const { return comments_; }
  32. std::u8string generate() const;
  33. void setLang(Notepad::Lang lang) { lang_ = lang; }
  34. std::u8string errorString() const { return errorString_; }
  35. static std::string tunnelTypeToString(TunnelType type);
  36. static TunnelType stringToTunnelType(const std::string& type);
  37. static bool isClientType(TunnelType type); // otherwise this is server
  38. private:
  39. std::string name_ = "TUNNEL";
  40. TunnelType tunnelType_ = TunnelType::TcpClient;
  41. Pair length_;
  42. Pair lengthVariance_;
  43. Pair quantity_;
  44. bool transient_ = false;
  45. bool blinded_ = false;
  46. uint8_t keepAliveInterval_ = 0;
  47. Notepad::Lang lang_ = Notepad::Lang::en;
  48. bool comments_ = true;
  49. std::u8string errorString_;
  50. };