@@ -202,137 +202,6 @@ extern "C" fn debug_callback(_data: *mut c_char, len: c_int) {
202202}
203203
204204extern "C" fn socket_trace_callback ( _: * mut c_void , queue_id : c_int , sd : * mut SK_BPF_DATA ) -> c_int {
205- unsafe {
206- let mut proto_tag = String :: from ( "" ) ;
207- if sk_proto_safe ( sd) == SOCK_DATA_OTHER {
208- proto_tag. push_str ( "ORTHER" ) ;
209- } else if sk_proto_safe ( sd) == SOCK_DATA_HTTP1 {
210- proto_tag. push_str ( "HTTP1" ) ;
211- } else if sk_proto_safe ( sd) == SOCK_DATA_HTTP2 {
212- proto_tag. push_str ( "HTTP2" ) ;
213- } else if sk_proto_safe ( sd) == SOCK_DATA_DNS {
214- proto_tag. push_str ( "DNS" ) ;
215- } else if sk_proto_safe ( sd) == SOCK_DATA_MYSQL {
216- proto_tag. push_str ( "MYSQL" ) ;
217- } else if sk_proto_safe ( sd) == SOCK_DATA_POSTGRESQL {
218- proto_tag. push_str ( "POSTGRESQL" ) ;
219- } else if sk_proto_safe ( sd) == SOCK_DATA_REDIS {
220- proto_tag. push_str ( "REDIS" ) ;
221- } else if sk_proto_safe ( sd) == SOCK_DATA_KAFKA {
222- proto_tag. push_str ( "KAFKA" ) ;
223- } else if sk_proto_safe ( sd) == SOCK_DATA_MQTT {
224- proto_tag. push_str ( "MQTT" ) ;
225- } else if sk_proto_safe ( sd) == SOCK_DATA_AMQP {
226- proto_tag. push_str ( "AMQP" ) ;
227- } else if sk_proto_safe ( sd) == SOCK_DATA_NATS {
228- proto_tag. push_str ( "NATS" ) ;
229- } else if sk_proto_safe ( sd) == SOCK_DATA_PULSAR {
230- proto_tag. push_str ( "PULSAR" ) ;
231- } else if sk_proto_safe ( sd) == SOCK_DATA_DUBBO {
232- proto_tag. push_str ( "DUBBO" ) ;
233- } else if sk_proto_safe ( sd) == SOCK_DATA_SOFARPC {
234- proto_tag. push_str ( "SOFARPC" ) ;
235- } else if sk_proto_safe ( sd) == SOCK_DATA_FASTCGI {
236- proto_tag. push_str ( "FASTCGI" ) ;
237- } else if sk_proto_safe ( sd) == SOCK_DATA_BRPC {
238- proto_tag. push_str ( "BRPC" ) ;
239- } else if sk_proto_safe ( sd) == SOCK_DATA_TARS {
240- proto_tag. push_str ( "TARS" ) ;
241- } else if sk_proto_safe ( sd) == SOCK_DATA_SOME_IP {
242- proto_tag. push_str ( "SomeIP" ) ;
243- } else if sk_proto_safe ( sd) == SOCK_DATA_ISO8583 {
244- proto_tag. push_str ( "ISO8583" ) ;
245- } else if sk_proto_safe ( sd) == SOCK_DATA_MONGO {
246- proto_tag. push_str ( "MONGO" ) ;
247- } else if sk_proto_safe ( sd) == SOCK_DATA_TLS {
248- proto_tag. push_str ( "TLS" ) ;
249- } else if sk_proto_safe ( sd) == SOCK_DATA_ORACLE {
250- proto_tag. push_str ( "ORACLE" ) ;
251- } else if sk_proto_safe ( sd) == SOCK_DATA_OPENWIRE {
252- proto_tag. push_str ( "OPENWIRE" ) ;
253- } else if sk_proto_safe ( sd) == SOCK_DATA_ZMTP {
254- proto_tag. push_str ( "ZMTP" ) ;
255- } else if sk_proto_safe ( sd) == SOCK_DATA_WEBSPHEREMQ {
256- proto_tag. push_str ( "WEBSPHEREMQ" ) ;
257- } else {
258- proto_tag. push_str ( "UNSPEC" ) ;
259- }
260-
261- println ! ( "+ --------------------------------- +" ) ;
262- if sk_proto_safe ( sd) == SOCK_DATA_HTTP1 {
263- let data = sk_data_str_safe ( sd) ;
264- println ! ( "{} <{}> BATCHLAST {} DIR {} TYPE {} PID {} THREAD_ID {} COROUTINE_ID {} CONTAINER_ID {} SOURCE {} ROLE {} COMM {} {} LEN {} SYSCALL_LEN {} SOCKET_ID 0x{:x} TRACE_ID 0x{:x} TCP_SEQ {} DATA_SEQ {} TLS {} TimeStamp {}\n {}" ,
265- date_time( ( * sd) . timestamp) ,
266- proto_tag,
267- ( * sd) . batch_last_data,
268- ( * sd) . direction,
269- ( * sd) . msg_type,
270- ( * sd) . process_id,
271- ( * sd) . thread_id,
272- ( * sd) . coroutine_id,
273- sd_container_id_safe( sd) ,
274- ( * sd) . source,
275- ( * sd) . socket_role,
276- process_name_safe( sd) ,
277- flow_info( sd) ,
278- ( * sd) . cap_len,
279- ( * sd) . syscall_len,
280- ( * sd) . socket_id,
281- ( * sd) . syscall_trace_id_call,
282- ( * sd) . tcp_seq,
283- ( * sd) . cap_seq,
284- ( * sd) . is_tls,
285- ( * sd) . timestamp,
286- data) ;
287- } else {
288- let data: Vec < u8 > = sk_data_bytes_safe ( sd) ;
289- println ! ( "{} <{}> BATCHLAST {} DIR {} TYPE {} PID {} THREAD_ID {} COROUTINE_ID {} CONTAINER_ID {} SOURCE {} ROLE {} COMM {} {} LEN {} SYSCALL_LEN {} SOCKET_ID 0x{:x} TRACE_ID 0x{:x} TCP_SEQ {} DATA_SEQ {} TLS {} TimeStamp {}" ,
290- date_time( ( * sd) . timestamp) ,
291- proto_tag,
292- ( * sd) . batch_last_data,
293- ( * sd) . direction,
294- ( * sd) . msg_type,
295- ( * sd) . process_id,
296- ( * sd) . thread_id,
297- ( * sd) . coroutine_id,
298- sd_container_id_safe( sd) ,
299- ( * sd) . source,
300- ( * sd) . socket_role,
301- process_name_safe( sd) ,
302- flow_info( sd) ,
303- ( * sd) . cap_len,
304- ( * sd) . syscall_len,
305- ( * sd) . socket_id,
306- ( * sd) . syscall_trace_id_call,
307- ( * sd) . tcp_seq,
308- ( * sd) . cap_seq,
309- ( * sd) . is_tls,
310- ( * sd) . timestamp) ;
311- if ( * sd) . source == 2 {
312- print_uprobe_http2_info ( ( * sd) . cap_data , ( * sd) . cap_len ) ;
313- } else if ( * sd) . source == 4 {
314- print_io_event_info ( ( * sd) . cap_data , ( * sd) . cap_len ) ;
315- } else if ( * sd) . source == 5 {
316- print_uprobe_grpc_dataframe ( ( * sd) . cap_data , ( * sd) . cap_len ) ;
317- } else if sk_proto_safe ( sd) == SOCK_DATA_OTHER {
318- for x in data. into_iter ( ) {
319- print ! ( "{} " , format!( "{:02x}" , x) ) ;
320- }
321- } else {
322- for x in data. into_iter ( ) {
323- if x < 32 || x > 126 {
324- print ! ( "." ) ;
325- continue ;
326- }
327- let b = x as char ;
328- print ! ( "{0}" , b) ;
329- }
330- }
331- print ! ( "\x1b [0m\n " ) ;
332- }
333-
334- println ! ( "+ --------------------------------- +\n " ) ;
335- }
336205
337206 0
338207}
@@ -416,29 +285,29 @@ fn main() {
416285 }
417286 }
418287 unsafe {
419- enable_ebpf_protocol ( SOCK_DATA_HTTP1 as c_int ) ;
420- enable_ebpf_protocol ( SOCK_DATA_HTTP2 as c_int ) ;
421- enable_ebpf_protocol ( SOCK_DATA_DUBBO as c_int ) ;
422- enable_ebpf_protocol ( SOCK_DATA_SOFARPC as c_int ) ;
423- enable_ebpf_protocol ( SOCK_DATA_FASTCGI as c_int ) ;
424- enable_ebpf_protocol ( SOCK_DATA_BRPC as c_int ) ;
425- enable_ebpf_protocol ( SOCK_DATA_TARS as c_int ) ;
426- enable_ebpf_protocol ( SOCK_DATA_SOME_IP as c_int ) ;
427- enable_ebpf_protocol ( SOCK_DATA_ISO8583 as c_int ) ;
428- enable_ebpf_protocol ( SOCK_DATA_MYSQL as c_int ) ;
429- enable_ebpf_protocol ( SOCK_DATA_POSTGRESQL as c_int ) ;
430- enable_ebpf_protocol ( SOCK_DATA_REDIS as c_int ) ;
431- enable_ebpf_protocol ( SOCK_DATA_KAFKA as c_int ) ;
432- enable_ebpf_protocol ( SOCK_DATA_MQTT as c_int ) ;
433- enable_ebpf_protocol ( SOCK_DATA_AMQP as c_int ) ;
434- enable_ebpf_protocol ( SOCK_DATA_OPENWIRE as c_int ) ;
435- enable_ebpf_protocol ( SOCK_DATA_ZMTP as c_int ) ;
436- enable_ebpf_protocol ( SOCK_DATA_WEBSPHEREMQ as c_int ) ;
437- enable_ebpf_protocol ( SOCK_DATA_NATS as c_int ) ;
438- enable_ebpf_protocol ( SOCK_DATA_PULSAR as c_int ) ;
439- enable_ebpf_protocol ( SOCK_DATA_DNS as c_int ) ;
440- enable_ebpf_protocol ( SOCK_DATA_MONGO as c_int ) ;
441- enable_ebpf_protocol ( SOCK_DATA_TLS as c_int ) ;
288+ // enable_ebpf_protocol(SOCK_DATA_HTTP1 as c_int);
289+ // enable_ebpf_protocol(SOCK_DATA_HTTP2 as c_int);
290+ // enable_ebpf_protocol(SOCK_DATA_DUBBO as c_int);
291+ // enable_ebpf_protocol(SOCK_DATA_SOFARPC as c_int);
292+ // enable_ebpf_protocol(SOCK_DATA_FASTCGI as c_int);
293+ // enable_ebpf_protocol(SOCK_DATA_BRPC as c_int);
294+ // enable_ebpf_protocol(SOCK_DATA_TARS as c_int);
295+ // enable_ebpf_protocol(SOCK_DATA_SOME_IP as c_int);
296+ // enable_ebpf_protocol(SOCK_DATA_ISO8583 as c_int);
297+ // enable_ebpf_protocol(SOCK_DATA_MYSQL as c_int);
298+ // enable_ebpf_protocol(SOCK_DATA_POSTGRESQL as c_int);
299+ // enable_ebpf_protocol(SOCK_DATA_REDIS as c_int);
300+ // enable_ebpf_protocol(SOCK_DATA_KAFKA as c_int);
301+ // enable_ebpf_protocol(SOCK_DATA_MQTT as c_int);
302+ // enable_ebpf_protocol(SOCK_DATA_AMQP as c_int);
303+ // enable_ebpf_protocol(SOCK_DATA_OPENWIRE as c_int);
304+ // enable_ebpf_protocol(SOCK_DATA_ZMTP as c_int);
305+ // enable_ebpf_protocol(SOCK_DATA_WEBSPHEREMQ as c_int);
306+ // enable_ebpf_protocol(SOCK_DATA_NATS as c_int);
307+ // enable_ebpf_protocol(SOCK_DATA_PULSAR as c_int);
308+ // enable_ebpf_protocol(SOCK_DATA_DNS as c_int);
309+ // enable_ebpf_protocol(SOCK_DATA_MONGO as c_int);
310+ // enable_ebpf_protocol(SOCK_DATA_TLS as c_int);
442311
443312 //set_feature_regex(
444313 // FEATURE_UPROBE_OPENSSL,
@@ -449,9 +318,9 @@ fn main() {
449318 // CString::new(".*".as_bytes()).unwrap().as_c_str().as_ptr(),
450319 //);
451320
452- // set_io_event_collect_mode(1 );
321+ set_io_event_collect_mode ( 2 ) ;
453322
454- // set_io_event_minimal_duration(1000000 );
323+ set_io_event_minimal_duration ( 10 ) ;
455324
456325 //// enable go auto traceing,
457326 //set_go_tracing_timeout(120);
@@ -682,11 +551,11 @@ fn main() {
682551 // test data limit max
683552 set_data_limit_max ( 10000 ) ;
684553
685- // let empty_string = CString::new("").expect("CString::new failed");
686- // if datadump_set_config(0, empty_string.as_ptr(), 0, 60 , debug_callback) != 0 {
687- // println!("datadump_set_config() error");
688- // ::std::process::exit(1);
689- // }
554+ let empty_string = CString :: new ( "" ) . expect ( "CString::new failed" ) ;
555+ if datadump_set_config ( 0 , empty_string. as_ptr ( ) , 0 , 600000 , debug_callback) != 0 {
556+ println ! ( "datadump_set_config() error" ) ;
557+ :: std:: process:: exit ( 1 ) ;
558+ }
690559
691560 print ! ( "socket_tracer_start() finish\n " ) ;
692561
0 commit comments