////////////////////////////////////////////////////////////////////// Setup global hooks
| 561 | /////////////////////////////////////////////////////////////////////////// |
| 562 | // Setup global hooks |
| 563 | void |
| 564 | TSPluginInit(int argc, const char *argv[]) |
| 565 | { |
| 566 | TSPluginRegistrationInfo info; |
| 567 | |
| 568 | info.plugin_name = (char *)PLUGIN_NAME; |
| 569 | info.vendor_name = (char *)"Apache Software Foundation"; |
| 570 | info.support_email = (char *)"dev@trafficserver.apache.org"; |
| 571 | |
| 572 | if (TS_SUCCESS != TSPluginRegister(&info)) { |
| 573 | TSError("[%s] Plugin registration failed", PLUGIN_NAME); |
| 574 | } |
| 575 | |
| 576 | TSCont cont = TSContCreate(cont_handle_response, nullptr); |
| 577 | |
| 578 | gConfig = new BgFetchConfig(cont); |
| 579 | |
| 580 | if (gConfig->parseOptions(argc, argv)) { |
| 581 | // Create the global log file. Note that calling this multiple times currently has no |
| 582 | // effect, only one log file is ever created. The BgFetchState is a singleton. |
| 583 | if (!gConfig->logFile().empty()) { |
| 584 | BgFetchState::getInstance().createLog(gConfig->logFile()); |
| 585 | } |
| 586 | Dbg(Bg_dbg_ctl, "Initialized"); |
| 587 | TSHttpHookAdd(TS_HTTP_READ_RESPONSE_HDR_HOOK, cont); |
| 588 | } else { |
| 589 | // ToDo: Hmmm, no way to fail a global plugin here? |
| 590 | Dbg(Bg_dbg_ctl, "Failed to initialize as global plugin"); |
| 591 | } |
| 592 | } |
| 593 | |
| 594 | /////////////////////////////////////////////////////////////////////////// |
| 595 | // Setup Remap mode |
nothing calls this directly
no test coverage detected