Add proxy types

This commit is contained in:
sha512sum 2024-08-31 18:17:53 +00:00
parent 3f04552491
commit 7ac2d7688e

View file

@ -0,0 +1,39 @@
#pragma once
#include <larra/utils.hpp>
#include <variant>
namespace larra::xmpp {
struct HttpProxy {
std::string hostname;
std::uint16_t port;
template <typename Self>
constexpr auto Hostname(this Self&& self, std::string hostname) -> HttpProxy {
return utils::FieldSetHelper::With<"hostname", HttpProxy>(std::forward<Self>(self), std::move(hostname));
}
template <typename Self>
constexpr auto Port(this Self&& self, std::uint16_t port) -> HttpProxy {
return utils::FieldSetHelper::With<"port", HttpProxy>(std::forward<Self>(self), port);
}
};
struct Socks5Proxy {
std::string hostname;
std::uint16_t port;
template <typename Self>
constexpr auto Hostname(this Self&& self, std::string hostname) -> Socks5Proxy {
return utils::FieldSetHelper::With<"hostname", Socks5Proxy>(std::forward<Self>(self), std::move(hostname));
}
template <typename Self>
constexpr auto Port(this Self&& self, std::uint16_t port) -> Socks5Proxy {
return utils::FieldSetHelper::With<"port", Socks5Proxy>(std::forward<Self>(self), port);
}
};
struct NoProxy {};
struct SystemConfiguredProxy {};
using Proxy = std::variant<SystemConfiguredProxy, HttpProxy, Socks5Proxy, NoProxy>;
} // namespace larra::xmpp