12#ifndef OPENVPN_CLIENT_OPTFILT_H
13#define OPENVPN_CLIENT_OPTFILT_H
31 if (!opt.
exists(
"pull-filter"))
34 for (
auto i : opt.
get_index(
"pull-filter"))
41 const auto &action_str = o.get(1, -1);
42 if (action_str ==
"accept")
44 else if (action_str ==
"ignore")
46 else if (action_str ==
"reject")
49 throw option_error(ERR_INVALID_OPTION_VAL,
"invalid pull-filter action: " + action_str);
96 && o.
ref(1) ==
"server"
99 throw option_error(ERR_INVALID_CONFIG, o.
escape(
false));
111 if (pull_filter.action !=
Accept)
114 <<
" due to pull-filter: "
116 if (pull_filter.action ==
Reject)
117 throw Option::RejectedException(pushed.
escape(
false));
119 return pull_filter.action;
128 if (!is_safe_conversion<int>(match.
size() - 1))
130 int i =
static_cast<int>(match.
size() - 1);
131 if (!pushed.
get(i, -1).starts_with(match.
get(i, -1)))
136 if (pushed.
get(i, -1) != match.
get(i, -1))
149 const std::string &directive = opt.
ref(0);
150 if (!directive.empty())
152 switch (directive[0])
155 if (directive ==
"block-ipv6")
161 if (directive ==
"client-nat")
167 if (directive ==
"dhcp-option"
168 || directive ==
"dhcp-renew"
169 || directive ==
"dhcp-pre-release" || directive ==
"dhcp-release")
175 if (directive ==
"ip-win32")
181 if (directive ==
"route"
182 || directive ==
"route-ipv6"
183 || directive ==
"route-metric"
184 || directive ==
"redirect-gateway"
185 || directive ==
"redirect-private"
186 || directive ==
"register-dns"
187 || directive ==
"route-delay"
188 || directive ==
"route-method")
194 if (directive ==
"tap-sleep")
const IndexList & get_index(const std::string &name) const
void touch(const std::string &name) const
static Option parse_option_from_line(const std::string &line, Limits *lim)
bool exists(const std::string &name) const
const std::string & get(const size_t index, const size_t max_len) const
std::string escape(const bool csv) const
const std::string & ref(const size_t i) const
std::string render(const unsigned int flags) const
bool filter(const Option &opt) override
std::vector< PullFilter > pull_filter_list_
FilterAction route_nopull_filter_(const Option &opt)
void static_filter_(const Option &o)
FilterAction pull_filter_(const Option &pushed)
bool pull_filter_matches_(const Option &pushed, const Option &match)
PushedOptionsFilter(const OptionList &opt)
FilterAction filter_(const Option &opt)
#define OPENVPN_LOG(args)
static int parse_priority(const std::string &prio_str)