| 802 | }; |
| 803 | |
| 804 | std::unique_ptr<Sock> ConnectThroughProxy(const Proxy& proxy, |
| 805 | const std::string& dest, |
| 806 | uint16_t port, |
| 807 | bool& proxy_connection_failed) |
| 808 | { |
| 809 | // first connect to proxy server |
| 810 | auto sock = proxy.Connect(); |
| 811 | if (!sock) { |
| 812 | proxy_connection_failed = true; |
| 813 | return {}; |
| 814 | } |
| 815 | |
| 816 | // do socks negotiation |
| 817 | if (proxy.m_tor_stream_isolation) { |
| 818 | static TorStreamIsolationCredentialsGenerator generator; |
| 819 | ProxyCredentials random_auth{generator.Generate()}; |
| 820 | if (!Socks5(dest, port, &random_auth, *sock)) { |
| 821 | return {}; |
| 822 | } |
| 823 | } else { |
| 824 | if (!Socks5(dest, port, nullptr, *sock)) { |
| 825 | return {}; |
| 826 | } |
| 827 | } |
| 828 | return sock; |
| 829 | } |
| 830 | |
| 831 | CSubNet LookupSubNet(const std::string& subnet_str) |
| 832 | { |
no test coverage detected