void INKPluginInit(int argc, const char *argv[]) { INKPluginRegistrationInfo info; info.plugin_name = "output-header"; info.vendor_name = "MyCompany"; info.support_email = "*****@*****.**"; if (!INKPluginRegister(INK_SDK_VERSION_5_2, &info)) { INKError("[PluginInit] Plugin registration failed.\n"); goto error; } if (!check_ts_version()) { INKError("[PluginInit] Plugin requires Traffic Server 5.2.0 or later\n"); goto error; } INKHttpHookAdd(INK_HTTP_OS_DNS_HOOK, INKContCreate(hdr_plugin, NULL)); error: INKError("[PluginInit] Plugin not initialized"); }
void INKPluginInit(int argc, const char *argv[]) { INKPluginRegistrationInfo info; info.plugin_name = "cluster-RPC"; info.vendor_name = "MyCompany"; info.support_email = "*****@*****.**"; if (!INKPluginRegister(INK_SDK_VERSION_2_0, &info)) { INKError("Plugin registration failed. \n"); } if (!check_ts_version()) { INKError("Plugin requires Traffic Server 3.5.2 or later\n"); return; } clusterRPC_init(); }
void INKPluginInit(int argc, const char *argv[]) { INKPluginRegistrationInfo info; info.plugin_name = "replace-header"; info.vendor_name = "MyCompany"; info.support_email = "*****@*****.**"; if (!INKPluginRegister(INK_SDK_VERSION_5_2, &info)) { INKError("Plugin registration failed. \n"); } if (!check_ts_version()) { INKError("Plugin requires Traffic Server 5.2.0 or later\n"); return; } INKHttpHookAdd(INK_HTTP_READ_RESPONSE_HDR_HOOK, INKContCreate(replace_header_plugin, NULL)); }
void INKPluginInit(int argc, const char *argv[]) { INKMLoc field_loc; const char *p; int i, retval; INKPluginRegistrationInfo info; info.plugin_name = "add-header"; info.vendor_name = "MyCompany"; info.support_email = "*****@*****.**"; if (!INKPluginRegister(INK_SDK_VERSION_5_2, &info)) { INKError("[PluginInit] Plugin registration failed.\n"); goto error; } if (!check_ts_version()) { INKError("[PluginInit] Plugin requires Traffic Server 5.2.0 or later\n"); goto error; } if (argc < 2) { INKError("[PluginInit] Usage: %s \"name1: value1\" \"name2: value2\" ...>\n", argv[0]); goto error; } hdr_bufp = INKMBufferCreate(); if (hdr_bufp == INK_ERROR_PTR) { INKError("[PluginInit] Can not create mbuffer"); goto error; } hdr_loc = INKMimeHdrCreate(hdr_bufp); if (hdr_loc == INK_ERROR_PTR) { INKError("[PluginInit] Can not create mime header"); goto error; } for (i = 1; i < argc; i++) { field_loc = INKMimeHdrFieldCreate(hdr_bufp, hdr_loc); if (field_loc == INK_ERROR_PTR) { INKError("[PluginInit] Error while creating field"); goto error; } retval = INKMimeHdrFieldAppend(hdr_bufp, hdr_loc, field_loc); if (retval == INK_ERROR) { INKError("[PluginInit] Error while adding field"); goto error; } p = strchr(argv[i], ':'); if (p) { retval = INKMimeHdrFieldNameSet(hdr_bufp, hdr_loc, field_loc, argv[i], p - argv[i]); if (retval == INK_ERROR) { INKError("[PluginInit] Error while naming field"); goto error; } p += 1; while (isspace(*p)) { p += 1; } retval = INKMimeHdrFieldValueInsert(hdr_bufp, hdr_loc, field_loc, p, strlen(p), -1); if (retval == INK_ERROR) { INKError("[PluginInit] Error while inserting field value"); goto error; } } else { retval = INKMimeHdrFieldNameSet(hdr_bufp, hdr_loc, field_loc, argv[i], strlen(argv[i])); if (retval == INK_ERROR) { INKError("[PluginInit] Error while inserting field value"); goto error; } } } /* Create a continuation with a mutex as there is a shared global structure containing the headers to add */ retval = INKHttpHookAdd(INK_HTTP_READ_REQUEST_HDR_HOOK, INKContCreate(add_header_plugin, INKMutexCreate())); if (retval == INK_ERROR) { INKError("[PluginInit] Error while registering to hook"); goto error; } goto done; error: INKError("[PluginInit] Plugin not initialized"); done: return; }