MCPcopy Create free account
hub / github.com/OpenVPN/openvpn3-linux / string_export

Method string_export

src/common/core-extensions.hpp:283–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281
282
283 std::string string_export()
284 {
285 std::stringstream cfgstr;
286
287 // These options will be prefixed with "setenv opt"
288 std::vector<std::string> rewrite_as_metaopts = {
289 "AUTOLOGIN",
290 "FRIENDLY_NAME",
291 "PROFILE",
292 "USERNAME"};
293
294 // Iterate all the std::vector<Option> objects
295 // OptionListJSON inherits OptionList which again inherits
296 // std::vector<Option>, which is why we access the std::vector
297 // via *this.
298 for (const auto &element : *this)
299 {
300 std::string optname = element.ref(0);
301
302 // FIXME: Access Server hack
303 bool as_skip = false;
304 for (const auto &chk : ignore_as_metaopts)
305 {
306 if (optname.find(chk) == 0)
307 {
308 as_skip = true;
309 break;
310 }
311 }
312 if (as_skip)
313 {
314 continue;
315 }
316
317 bool setenv_rewrite = false;
318 for (const auto &chk : rewrite_as_metaopts)
319 {
320 if (optname.find(chk) == 0)
321 {
322 setenv_rewrite = true;
323 break;
324 }
325 }
326
327 // Inlined files needs special treatment, as they span
328 // multiple lines. Just retrieve the raw data directly here.
329 if (optparser_inline_file(optname) && element.size() > 1)
330 {
331 cfgstr << optparser_mkline(optname, element.ref(1)) << std::endl;
332 }
333 else if (setenv_rewrite)
334 {
335 cfgstr << "setenv opt " << element.escape(false) << std::endl;
336 }
337 else
338 {
339 // For everything else, we use the Option::escape() method
340 // to render the output we need for the string export of the

Callers 4

method_fetchMethod · 0.80
cmd_pm_optlist_testFunction · 0.80
TEST_FFunction · 0.80
mainFunction · 0.80

Calls 4

optparser_inline_fileFunction · 0.85
optparser_mklineFunction · 0.85
sizeMethod · 0.80
strMethod · 0.45

Tested by 3

cmd_pm_optlist_testFunction · 0.64
TEST_FFunction · 0.64
mainFunction · 0.64