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

Function TSPluginInit

plugins/traffic_dump/traffic_dump.cc:74–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72} // namespace traffic_dump
73
74void
75TSPluginInit(int argc, char const *argv[])
76{
77 Dbg(traffic_dump::dbg_ctl, "initializing plugin");
78 TSPluginRegistrationInfo info;
79
80 info.plugin_name = "traffic_dump";
81 info.vendor_name = "Apache Software Foundation";
82 info.support_email = "dev@trafficserver.apache.org";
83
84 if (TS_SUCCESS != TSPluginRegister(&info)) {
85 TSError("[%s] Unable to initialize plugin (disabled). Failed to register plugin.", traffic_dump::debug_tag);
86 return;
87 }
88
89 bool dump_body = false;
90 bool sensitive_fields_were_specified = false;
91 traffic_dump::sensitive_fields_t user_specified_fields;
92 swoc::file::path log_dir{traffic_dump::SessionData::default_log_directory};
93 int64_t sample_pool_size = traffic_dump::SessionData::default_sample_pool_size;
94 int64_t max_disk_usage = traffic_dump::SessionData::default_max_disk_usage;
95 bool enforce_disk_limit = traffic_dump::SessionData::default_enforce_disk_limit;
96 std::string sni_filter;
97 std::string client_ip_filter;
98
99 /// Commandline options
100 static const struct option longopts[] = {
101 {"dump_body", no_argument, nullptr, 'b'},
102 {"logdir", required_argument, nullptr, 'l'},
103 {"sample", required_argument, nullptr, 's'},
104 {"limit", required_argument, nullptr, 'm'},
105 {"sensitive-fields", required_argument, nullptr, 'f'},
106 {"sni-filter", required_argument, nullptr, 'n'},
107 {"client_ipv4", required_argument, nullptr, '4'},
108 {"client_ipv6", required_argument, nullptr, '6'},
109 {nullptr, no_argument, nullptr, 0 }
110 };
111 int opt = 0;
112 while (opt >= 0) {
113 opt = getopt_long(argc, const_cast<char *const *>(argv), "bf:l:s:m:n:4:6", longopts, nullptr);
114 switch (opt) {
115 case 'b': {
116 dump_body = true;
117 break;
118 }
119 case 'f': {
120 // --sensitive-fields takes a comma-separated list of HTTP fields that
121 // are sensitive. The field values for these fields will be replaced
122 // with generic traffic_dump generated data.
123 //
124 // If this option is not used, then the default values in
125 // default_sensitive_fields is used. If this option is used, then it
126 // replaced the default sensitive fields with the user-supplied list of
127 // sensitive fields.
128 sensitive_fields_were_specified = true;
129 swoc::TextView input_filter_fields{std::string_view{optarg}};
130 swoc::TextView filter_field;
131 while (!(filter_field = input_filter_fields.take_prefix_at(',')).empty()) {

Callers

nothing calls this directly

Calls 13

TSPluginRegisterFunction · 0.85
stringClass · 0.85
pathClass · 0.85
TSInstallDirGetFunction · 0.85
TSContCreateFunction · 0.85
TSLifecycleHookAddFunction · 0.85
take_prefix_atMethod · 0.80
emplaceMethod · 0.80
is_absoluteMethod · 0.80
TSErrorFunction · 0.50
initFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected