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

Function TSPluginInit

example/plugins/c-api/ssl_preaccept/ssl_preaccept.cc:104–141  ·  view source on GitHub ↗

Called by ATS as our initialization point

Source from the content-addressed store, hash-verified

102
103// Called by ATS as our initialization point
104void
105TSPluginInit(int argc, const char *argv[])
106{
107 bool success = false;
108 TSCont cb_pa = nullptr; // pre-accept callback continuation
109
110 TSPluginRegistrationInfo info;
111 info.plugin_name = PLUGIN_NAME;
112 info.vendor_name = "Apache Software Foundation";
113 info.support_email = "dev@trafficserver.apache.org";
114
115 if (argc < 2) {
116 TSError(PCP "Usage: ssl_preaccept.so <ip or network>");
117 return;
118 }
119
120 IpRange ipRange;
121 Parse_Addr_String(std::string_view(argv[1]), ipRange);
122 ClientBlindTunnelIp.push_back(ipRange);
123
124 if (TS_SUCCESS != TSPluginRegister(&info)) {
125 TSError(PCP "registration failed");
126 } else if (TSTrafficServerVersionGetMajor() < 2) {
127 TSError(PCP "requires Traffic Server 2.0 or later");
128 } else if (nullptr == (cb_pa = TSContCreate(&CB_Pre_Accept, TSMutexCreate()))) {
129 TSError(PCP "Failed to pre-accept callback");
130 } else {
131 TSHttpHookAdd(TS_VCONN_START_HOOK, cb_pa);
132 success = true;
133 }
134
135 if (!success) {
136 TSError(PCP "not initialized");
137 }
138 Dbg(dbg_ctl, "Plugin %s", success ? "online" : "offline");
139
140 return;
141}

Callers

nothing calls this directly

Calls 8

Parse_Addr_StringFunction · 0.85
TSPluginRegisterFunction · 0.85
TSContCreateFunction · 0.85
TSMutexCreateFunction · 0.85
TSHttpHookAddFunction · 0.85
TSErrorFunction · 0.50
push_backMethod · 0.45

Tested by

no test coverage detected