48
49
50
51
52
53
57
58
59
60
61
62
63
64
66 = std::function<
void(
const std::string& stream_name,
frame&& f)>;
69
70
71
72
73
74
75
76
77
79 using daemon_start_fn = std::function<
void(
80 const stream& s, std::function<
void(
frame&&)> on_frame,
85
86
87
88
89
90
91
92
98
99
101
102 using event_sink_fn = std::function<
void(
const event& e)>;
105
106
108
109 using event_batch_sink_fn
110 = std::function<
void(
const std::vector<event>& events)>;
113
114
115
116
117
118
122
123
124
125
126
127
128 void dump(std::ostream& out)
const;
131
132
133
134
135
136
137 void dump_lines(std::ostream& out)
const;
140
141
142
143
144
145
146
147 void dump_stream(std::ostream& out,
bool connections =
false)
const;
150
151
152
153
154
155
156
157 void set_local_stream_detector(local_stream_detector_fn detector);
160
161
162
163
164
165
166
167
168 void refresh_local_streams();
171
172
173
174
175
176
177
178
179
180
181
183 const std::string& path,
const std::string& name = {},
184 const std::string& type = {},
bool loop =
true
188
189
190
191
192
193
194
195
196
197
198
200 const std::string& points,
bool closed =
false,
201 const std::string& name = {}
205
206
207
208
209
210
211
213 set_line(
const std::string& stream_name,
const std::string& line_name);
216
217
218
219
220
221 std::shared_ptr<
const stream> find_stream(
const std::string& name)
const;
224
225
226 std::vector<std::string> stream_names()
const;
229
230
231 std::vector<std::string> line_names()
const;
234
235
236
237
238
239 std::vector<std::string> stream_lines(
const std::string& stream_name)
const;
242
243
244
245
246
247
248
252
253
254
255
256
257
258 void set_daemon_start_hook(daemon_start_fn hook);
261
262
263
264
265
266
267
268
269
270
271
272 void push_frame(
const std::string& stream_name,
frame&& f);
275
276
277
278
279
280
281 void start_daemon(
const std::string& stream_name);
284
285
286
287
288 void set_frame_processor(frame_processor_fn fn);
291
292
293
294
295
296
297
298
299
300 std::vector<event> process_frame(
const std::string& stream_name,
frame&& f);
303
304
305
306
307
308
309 void set_event_sink(event_sink_fn fn);
312
313
314
315
316
317
318 void set_event_batch_sink(event_batch_sink_fn fn);
321
322
323
324
325
326
327 void set_analysis_interval_ms(
int ms);
330
331
332
333
334
335
336
337
338
339
340
341 void start_stream(
const std::string& name);
344
345
346
347
348
349
350
351 void stop_stream(
const std::string& name);
354
355
356
357
358
359 bool is_stream_running(
const std::string& name)
const;
362
363
364
365
366
367
368
369 void enable_fake_events(
int interval_ms = 700);
372
373
374
375
376 void disable_fake_events();
379
380
381
382
383
384
385
386
387
388
389 void set_line_dir(
const std::string& line_name,
tripwire_dir dir);
393
394
395
396
397
398
399 std::vector<std::shared_ptr<stream>> snapshot_streams()
const;
402
403
404
405
406
407
408
409
410
412 frame_processor_fn& fp, event_sink_fn& es, event_batch_sink_fn& bes
416
417
418
419
420 int current_fake_interval_ms()
const;
423
424
425
426
427
428
429
430 void run_fake_events(std::stop_token st);
434
435
436
437
438
439
440
441
442 static bool is_linux_capture_ok(
const stream& s);
446 std::unordered_map<std::string, std::shared_ptr<stream>> streams;
449 std::unordered_map<std::string, line_ptr> lines;
452 size_t stream_idx { 0 };
455 size_t line_idx { 0 };
458 local_stream_detector_fn stream_detector {};
464 daemon_start_fn daemon_start;
467 frame_processor_fn frame_processor;
470 event_sink_fn event_sink;
473 event_batch_sink_fn event_batch_sink;
476 int analysis_interval_ms { 200 };
479
480
482
483 std::unordered_map<std::string, std::chrono::steady_clock::time_point>
487 std::unordered_map<std::string, std::jthread> daemons;
490 std::jthread fake_thread;
493 int fake_interval_ms { 700 };
496 bool fake_enabled {
false };
499 mutable std::mutex mtx;