12#ifndef OPENVPN_CLIENT_OPTFILT_H
13#define OPENVPN_CLIENT_OPTFILT_H
32 if (!opt.
exists(
"pull-filter"))
35 for (
auto i : opt.
get_index(
"pull-filter"))
42 const auto &action_str = o.get(1, -1);
43 if (action_str ==
"accept")
45 else if (action_str ==
"ignore")
47 else if (action_str ==
"reject")
50 throw option_error(ERR_INVALID_OPTION_VAL,
"invalid pull-filter action: " + action_str);
97 && o.
ref(1) ==
"server"
100 throw option_error(ERR_INVALID_CONFIG, o.
escape(
false));
112 if (pull_filter.action !=
Accept)
115 <<
" due to pull-filter: "
117 if (pull_filter.action ==
Reject)
118 throw Option::RejectedException(pushed.
escape(
false));
120 return pull_filter.action;
129 if (!is_safe_conversion<int>(match.
size() - 1))
131 int i =
static_cast<int>(match.
size() - 1);
137 if (pushed.
get(i, -1) != match.
get(i, -1))
150 const std::string &directive = opt.
ref(0);
151 if (directive.length() >= 1)
153 switch (directive[0])
156 if (directive ==
"block-ipv6")
162 if (directive ==
"client-nat")
168 if (directive ==
"dhcp-option"
169 || directive ==
"dhcp-renew"
170 || directive ==
"dhcp-pre-release" || directive ==
"dhcp-release")
176 if (directive ==
"ip-win32")
182 if (directive ==
"route"
183 || directive ==
"route-ipv6"
184 || directive ==
"route-metric"
185 || directive ==
"redirect-gateway"
186 || directive ==
"redirect-private"
187 || directive ==
"register-dns"
188 || directive ==
"route-delay"
189 || directive ==
"route-method")
195 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)
bool starts_with(const STRING &str, const std::string &prefix)
static int parse_priority(const std::string &prio_str)