MCPcopy Create free account
hub / github.com/apache/trafficserver / TSPluginInit

Function TSPluginInit

plugins/header_rewrite/header_rewrite.cc:390–458  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// Initialize the InkAPI plugin for the global hooks we support.

Source from the content-addressed store, hash-verified

388// Initialize the InkAPI plugin for the global hooks we support.
389//
390void
391TSPluginInit(int argc, const char *argv[])
392{
393 TSPluginRegistrationInfo info;
394
395 info.plugin_name = (char *)PLUGIN_NAME;
396 info.vendor_name = (char *)"Apache Software Foundation";
397 info.support_email = (char *)"dev@trafficserver.apache.org";
398
399 if (TS_SUCCESS != TSPluginRegister(&info)) {
400 TSError("[%s] plugin registration failed", PLUGIN_NAME);
401 return;
402 }
403
404 std::string geoDBpath;
405 while (true) {
406 int opt = getopt_long(argc, const_cast<char *const *>(argv), "m:", longopt, nullptr);
407
408 switch (opt) {
409 case 'm': {
410 geoDBpath = optarg;
411 } break;
412 }
413 if (opt == -1) {
414 break;
415 }
416 }
417
418 if (!geoDBpath.empty() && geoDBpath.find('/') != 0) {
419 geoDBpath = std::string(TSConfigDirGet()) + '/' + geoDBpath;
420 }
421
422 Dbg(pi_dbg_ctl, "Global geo db %s", geoDBpath.c_str());
423
424 std::call_once(initHRWLibs, [&geoDBpath]() { initHRWLibraries(geoDBpath); });
425
426 // Parse the global config file(s). All rules are just appended
427 // to the "global" Rules configuration.
428 RulesConfig *conf = new RulesConfig;
429 bool got_config = false;
430
431 for (int i = optind; i < argc; ++i) {
432 // Parse the config file(s). Note that multiple config files are
433 // just appended to the configurations.
434 Dbg(pi_dbg_ctl, "Loading global configuration file %s", argv[i]);
435 if (conf->parse_config(argv[i], TS_HTTP_READ_RESPONSE_HDR_HOOK)) {
436 Dbg(pi_dbg_ctl, "Successfully loaded global config file %s", argv[i]);
437 got_config = true;
438 } else {
439 TSError("[%s] failed to parse configuration file %s", PLUGIN_NAME, argv[i]);
440 }
441 }
442
443 if (got_config) {
444 TSCont contp = TSContCreate(cont_rewrite_headers, nullptr);
445 TSContDataSet(contp, conf);
446
447 for (int i = TS_HTTP_READ_REQUEST_HDR_HOOK; i < TS_HTTP_LAST_HOOK; ++i) {

Callers

nothing calls this directly

Calls 14

TSPluginRegisterFunction · 0.85
stringClass · 0.85
TSConfigDirGetFunction · 0.85
initHRWLibrariesFunction · 0.85
TSContCreateFunction · 0.85
TSContDataSetFunction · 0.85
TSHttpHookNameLookupFunction · 0.85
TSHttpHookAddFunction · 0.85
ruleMethod · 0.80
TSErrorFunction · 0.70
emptyMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected