comm_data.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Tencent is pleased to support the open source community by making Mars available.
  2. // Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
  3. // Licensed under the MIT License (the "License"); you may not use this file except in
  4. // compliance with the License. You may obtain a copy of the License at
  5. // http://opensource.org/licenses/MIT
  6. // Unless required by applicable law or agreed to in writing, software distributed under the License is
  7. // distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  8. // either express or implied. See the License for the specific language governing permissions and
  9. // limitations under the License.
  10. //
  11. // comm_data.h
  12. // comm
  13. //
  14. // Created by garry on 2017/2/17.
  15. //
  16. #ifndef comm_data_h
  17. #define comm_data_h
  18. #include <string>
  19. #include <stdint.h>
  20. namespace mars {
  21. namespace comm {
  22. enum ProxyType {
  23. kProxyNone = 0,
  24. kProxyHttpTunel,
  25. kProxySocks5,
  26. kProxyHttp,
  27. };
  28. class ProxyInfo {
  29. public:
  30. ProxyInfo():ProxyInfo(kProxyNone, "", "", 0, "", ""){}
  31. ProxyInfo(ProxyType _type, const std::string& _host, const std::string& _ip, uint16_t _port, const std::string& _username, const std::string& _password)
  32. :type(_type), host(_host), ip(_ip), port(_port), username(_username), password(_password){}
  33. bool IsValid() const {
  34. return kProxyNone == type || ((!ip.empty() || !host.empty()) && port > 0);
  35. }
  36. public:
  37. ProxyType type;
  38. std::string host;
  39. std::string ip;
  40. uint16_t port;
  41. std::string username;
  42. std::string password;
  43. };
  44. }
  45. }
  46. #endif /* comm_data_h */