| 1190 | } |
| 1191 | |
| 1192 | void |
| 1193 | TSPluginInit(int /* argc ATS_UNUSED */, const char *argv[]) |
| 1194 | { |
| 1195 | TSPluginRegistrationInfo info; |
| 1196 | TSCont cont; |
| 1197 | |
| 1198 | info.plugin_name = PLUGIN_NAME; |
| 1199 | info.vendor_name = "Apache Software Foundation"; |
| 1200 | info.support_email = "dev@trafficserver.apache.org"; |
| 1201 | |
| 1202 | if (TSPluginRegister(&info) != TS_SUCCESS) { |
| 1203 | TSError("[%s] Plugin registration failed", PLUGIN_NAME); |
| 1204 | } |
| 1205 | |
| 1206 | server_ip = std::string(argv[1]); |
| 1207 | server_port = std::stoi(argv[2]); |
| 1208 | carp_port = std::stoi(argv[3]); |
| 1209 | debug_enabled = std::stoi(argv[4]); |
| 1210 | |
| 1211 | /* Initialize stats */ |
| 1212 | if (TSStatFindName("plugin." PLUGIN_NAME ".scan_passed", &scan_passed) == TS_ERROR) { |
| 1213 | scan_passed = TSStatCreate("plugin." PLUGIN_NAME ".scan_passed", TS_RECORDDATATYPE_INT, TS_STAT_PERSISTENT, TS_STAT_SYNC_COUNT); |
| 1214 | } |
| 1215 | |
| 1216 | if (TSStatFindName("plugin." PLUGIN_NAME ".scan_failed", &scan_failed) == TS_ERROR) { |
| 1217 | scan_failed = TSStatCreate("plugin." PLUGIN_NAME ".scan_failed", TS_RECORDDATATYPE_INT, TS_STAT_PERSISTENT, TS_STAT_SYNC_COUNT); |
| 1218 | } |
| 1219 | |
| 1220 | if (TSStatFindName("plugin." PLUGIN_NAME ".icap_conn_failed", &icap_conn_failed) == TS_ERROR) { |
| 1221 | icap_conn_failed = |
| 1222 | TSStatCreate("plugin." PLUGIN_NAME ".icap_conn_failed", TS_RECORDDATATYPE_INT, TS_STAT_PERSISTENT, TS_STAT_SYNC_COUNT); |
| 1223 | } |
| 1224 | |
| 1225 | if (TSStatFindName("plugin." PLUGIN_NAME ".total_icap_invalid", &total_icap_invalid) == TS_ERROR) { |
| 1226 | total_icap_invalid = |
| 1227 | TSStatCreate("plugin." PLUGIN_NAME ".total_icap_invalid", TS_RECORDDATATYPE_INT, TS_STAT_PERSISTENT, TS_STAT_SYNC_COUNT); |
| 1228 | } |
| 1229 | |
| 1230 | if (TSStatFindName("plugin." PLUGIN_NAME ".icap_response_err", &icap_response_err) == TS_ERROR) { |
| 1231 | icap_response_err = |
| 1232 | TSStatCreate("plugin." PLUGIN_NAME ".icap_response_err", TS_RECORDDATATYPE_INT, TS_STAT_PERSISTENT, TS_STAT_SYNC_COUNT); |
| 1233 | } |
| 1234 | |
| 1235 | if (TSStatFindName("plugin." PLUGIN_NAME ".icap_write_failed", &icap_write_failed) == TS_ERROR) { |
| 1236 | icap_write_failed = |
| 1237 | TSStatCreate("plugin." PLUGIN_NAME ".icap_write_failed", TS_RECORDDATATYPE_INT, TS_STAT_PERSISTENT, TS_STAT_SYNC_COUNT); |
| 1238 | } |
| 1239 | |
| 1240 | TSStatIntSet(scan_passed, 0); |
| 1241 | TSStatIntSet(scan_failed, 0); |
| 1242 | TSStatIntSet(icap_conn_failed, 0); |
| 1243 | TSStatIntSet(icap_write_failed, 0); |
| 1244 | TSStatIntSet(icap_response_err, 0); |
| 1245 | TSStatIntSet(total_icap_invalid, 0); |
| 1246 | |
| 1247 | cont = TSContCreate(transform_plugin, nullptr); |
| 1248 | TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, cont); |
| 1249 | } |
nothing calls this directly
no test coverage detected