21class ViaVPN :
public RC<thread_unsafe_refcount>
38 return opt.
exists(
"vpn-connection-info");
43 const Option &o = opt.
get(
"vpn-connection-info");
49 const std::string &gw)
63 template <
typename HOST>
80 template <
typename LISTEN_ITEM>
84 if (listen_item.addr.empty())
85 throw via_vpn_error(
"listen_item is empty");
88 if (listen_item.addr[0] ==
'@')
97 throw via_vpn_error(
"cannot find local address in " + listen_item.addr);
99 OPENVPN_LOG(
"using local address " <<
ret.to_string() <<
" for " << listen_item.directive <<
' ' << listen_item.addr);
103 return IP::Addr(listen_item.addr, listen_item.directive);
130 const Json::Value &root,
131 const std::string &name,
132 const std::string &title)
135 if (dest.empty() && !value.empty())
136 dest = std::move(value);
142 if (s1.empty() && !s2.empty())
152 else if (gw ==
"gw4")
154 else if (gw ==
"gw6")
157 throw via_vpn_error(
"ViaVPN: bad gw parameter");
const Option & get(const std::string &name) const
bool exists(const std::string &name) const
std::string get_optional(const size_t index, const size_t max_len) const
const std::string & get(const size_t index, const size_t max_len) const
Reference count base class for objects tracked by RCPtr. Disallows copying and assignment.
OPENVPN_EXCEPTION(via_vpn_error)
static void maybe_swap(std::string &s1, std::string &s2)
ViaVPN(std::string conn_info_fn, const std::string &gw)
ViaVPN(const OptionList &opt)
static GatewayType parse_gw_type(const std::string &gw)
std::string connection_info_fn
static ViaVPN::Ptr client_new_if_enabled(const OptionList &opt)
Json::Value client_update_host(HOST &host) const
static std::string gw_type_to_string(const GatewayType gw_type)
static void set_host_field(std::string &dest, const Json::Value &root, const std::string &name, const std::string &title)
static bool is_enabled(const OptionList &opt)
std::string to_string() const
IP::Addr client_ip() const
static IP::Addr server_local_addr(const LISTEN_ITEM &listen_item, const GatewayType gw_type)
#define OPENVPN_LOG(args)
Json::Value parse_from_file(const std::string &fn)
std::string get_string_optional(const Json::Value &root, const NAME &name, const std::string &default_value, const TITLE &title)