1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef COMMUNICATION_NETSTACK_SOCKS5_METHOD_H 17 #define COMMUNICATION_NETSTACK_SOCKS5_METHOD_H 18 19 #include <memory> 20 #include <string> 21 #include <sys/types.h> 22 23 #include "net_address.h" 24 #include "socks5.h" 25 #include "socks5_package.h" 26 27 namespace OHOS { 28 namespace NetStack { 29 namespace Socks5 { 30 class Socks5Instance; 31 class Socks5Method { 32 public: Socks5Method(std::shared_ptr<Socks5Instance> socks5Inst)33 Socks5Method(std::shared_ptr<Socks5Instance> socks5Inst) : socks5Inst_(socks5Inst){}; 34 virtual ~Socks5Method() = default; 35 36 virtual bool RequestAuth(std::int32_t socketId, const std::string &userName, const std::string &password, 37 const Socks5ProxyAddress &proxy) = 0; 38 virtual std::pair<bool, Socks5ProxyResponse> RequestProxy(std::int32_t socketId, Socks5Command command, 39 const Socket::NetAddress &destAddr, const Socks5ProxyAddress &proxy) = 0; 40 GetSocks5Instance()41 std::shared_ptr<Socks5Instance> &GetSocks5Instance() 42 { 43 return socks5Inst_; 44 } 45 46 private: 47 std::shared_ptr<Socks5Instance> socks5Inst_{nullptr}; 48 }; 49 } // Socks5 50 } // NetStack 51 } // OHOS 52 #endif // COMMUNICATION_NETSTACK_SOCKS5_METHOD_H 53