diff options
| author | tobtoht <tob@featherwallet.org> | 2026-04-20 07:49:04 +0000 |
|---|---|---|
| committer | tobtoht <tob@featherwallet.org> | 2026-04-20 07:49:04 +0000 |
| commit | 8b6be66bef8cce6e074074b7329be9509b93dbb8 (patch) | |
| tree | 6dee62eec590447f49e6a29d649c294f4757a2a4 /src/net/parse.h | |
| parent | e75125a30b1f70e74eded99d3fc4f3e98938c6d5 (diff) | |
| parent | ce5437f0677966c15d2946bc7c068975aa6bfd83 (diff) | |
| download | monzero-core-8b6be66bef8cce6e074074b7329be9509b93dbb8.tar.gz monzero-core-8b6be66bef8cce6e074074b7329be9509b93dbb8.tar.xz monzero-core-8b6be66bef8cce6e074074b7329be9509b93dbb8.zip | |
Merge pull request #10411
ce5437f Add Socks v5 support to daemon and wallet (Lee *!* Clagett)
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; + }; + } +} |
