diff options
| author | Lee *!* Clagett <code@leeclagett.com> | 2024-08-17 18:37:10 -0400 |
|---|---|---|
| committer | lschomaker1 <lucas.schomaker12@gmail.com> | 2026-04-16 15:52:05 -0500 |
| commit | ce5437f0677966c15d2946bc7c068975aa6bfd83 (patch) | |
| tree | fe34f64934e00f27f4308f6747a0c32efd2edfcd /src/net/parse.h | |
| parent | 54b803603cf0fb450a9b9436b9fe85452e75966f (diff) | |
| download | monzero-core-ce5437f0677966c15d2946bc7c068975aa6bfd83.tar.gz monzero-core-ce5437f0677966c15d2946bc7c068975aa6bfd83.tar.xz monzero-core-ce5437f0677966c15d2946bc7c068975aa6bfd83.zip | |
Add Socks v5 support to daemon and wallet
(cherry picked from commit 23e29a5074f01cbb781f7e76b0c17ad2b6797af0)
Diffstat (limited to 'src/net/parse.h')
| -rw-r--r-- | src/net/parse.h | 79 |
1 files changed, 78 insertions, 1 deletions
diff --git a/src/net/parse.h b/src/net/parse.h index 6ece931c6..68f63fdb9 100644 --- a/src/net/parse.h +++ b/src/net/parse.h @@ -30,14 +30,75 @@ #pragma once #include <boost/asio/ip/tcp.hpp> +#include <boost/optional/optional.hpp> #include <boost/utility/string_ref.hpp> #include <cstdint> #include "common/expect.h" +#include "net/fwd.h" #include "net/net_utils_base.h" namespace net { + //! \brief Separates scheme, authority, and path sections of a URI. + struct scheme_and_authority + { + //! \param uri with optional scheme, authority, and optional path. No URNs. + explicit scheme_and_authority(boost::string_ref uri); + + std::string scheme; + std::string authority; + }; + + //! \brief Separates the userinfo and host+port from URI authority. + struct userinfo_and_hostport + { + //! \param authority portion of a URI. + explicit userinfo_and_hostport(boost::string_ref authority); + + std::string userinfo; + std::string hostport; + }; + + //! \brief Separates the user and pass sections from URI userinfo. + struct user_and_pass + { + user_and_pass() + : user(), pass() + {} + + /*! + * \param userinfo section of a URI. + * \return User and pass with percent encoding removed. `boost::none` + * if bad percent encoding + */ + static boost::optional<user_and_pass> get(boost::string_ref userinfo); + + std::string user; + std::string pass; + }; + + //! \brief Separates scheme, user, pass, and host+port sections of a URI. + struct uri_components + { + uri_components() + : scheme(), userinfo(), hostport() + {} + + /*! + * \param uri with optional scheme, optional user, optional pass, + * authority, and optional path. URN not supported. + * \return Scheme, user, pass, and host+port sections of a URI with + * percent encoding removed on user and pass. `boost::none` if + * bad percent encoding. + */ + static boost::optional<uri_components> get(boost::string_ref uri); + + std::string scheme; + user_and_pass userinfo; + std::string hostport; + }; + /*! * \brief Takes a valid address string (IP, Tor, I2P, or DNS name) and splits it into host and port * @@ -79,5 +140,21 @@ namespace net get_ipv4_subnet_address(boost::string_ref address, bool allow_implicit_32 = false); expect<boost::asio::ip::tcp::endpoint> get_tcp_endpoint(const boost::string_ref address); -} + namespace socks + { + //! \brief Separates TCP address, user+pass, and socks version + struct endpoint + { + endpoint(); + explicit endpoint(const boost::asio::ip::tcp::endpoint& address); + + //! \param uri with optional scheme, optional userinfo, and host+port. + static expect<endpoint> get(boost::string_ref uri); + + boost::asio::ip::tcp::endpoint address; + user_and_pass userinfo; + version ver; + }; + } +} |
