1010#include <bpf/bpf.h>
1111
1212// 导入生成的骨架头文件
13- #include "ssl_sniff .skel.h"
13+ #include "claude_trace .skel.h"
1414#include "common.h"
1515
1616// 终端颜色定义
@@ -337,26 +337,6 @@ static int handle_event(void *ctx, void *data, size_t data_sz) {
337337 return 0 ;
338338}
339339
340- // 查找 OpenSSL 库路径
341- static char * find_openssl_lib () {
342- static char * paths [] = {
343- "/usr/lib/x86_64-linux-gnu/libssl.so.3" ,
344- "/usr/lib/x86_64-linux-gnu/libssl.so.1.1" ,
345- "/usr/lib/libssl.so.3" ,
346- "/usr/lib/libssl.so.1.1" ,
347- "/lib/x86_64-linux-gnu/libssl.so.3" ,
348- "/usr/local/lib/libssl.so" ,
349- NULL
350- };
351-
352- for (int i = 0 ; paths [i ]; i ++ ) {
353- if (access (paths [i ], F_OK ) == 0 ) {
354- return paths [i ];
355- }
356- }
357- return NULL ;
358- }
359-
360340// 查找 Node.js 二进制文件
361341static char * find_node_binary () {
362342 static char * paths [] = {
@@ -375,7 +355,7 @@ static char* find_node_binary() {
375355}
376356
377357// 附加 uprobe 到指定库的辅助函数
378- static int attach_ssl_probes (struct ssl_sniff_bpf * skel , const char * lib_path , const char * lib_name ) {
358+ static int attach_ssl_probes (struct claude_trace_bpf * skel , const char * lib_path , const char * lib_name ) {
379359 LIBBPF_OPTS (bpf_uprobe_opts , uprobe_opts );
380360
381361 printf ("📌 Attaching to %s: %s\n" , lib_name , lib_path );
@@ -441,7 +421,7 @@ static int attach_ssl_probes(struct ssl_sniff_bpf *skel, const char *lib_path, c
441421}
442422
443423int main (int argc , char * * argv ) {
444- struct ssl_sniff_bpf * skel ;
424+ struct claude_trace_bpf * skel ;
445425 struct ring_buffer * rb = NULL ;
446426 int err ;
447427
@@ -475,7 +455,7 @@ int main(int argc, char **argv) {
475455 }
476456
477457 // 打开并加载 BPF 程序
478- skel = ssl_sniff_bpf__open_and_load ();
458+ skel = claude_trace_bpf__open_and_load ();
479459 if (!skel ) {
480460 fprintf (stderr , "❌ Failed to open and load BPF skeleton\n" );
481461 return 1 ;
@@ -501,24 +481,12 @@ int main(int argc, char **argv) {
501481 }
502482 }
503483
504- // 尝试附加到系统 OpenSSL 库 (通用监控)
505- char * openssl_path = find_openssl_lib ();
506- if (openssl_path ) {
507- printf ("\n" );
508- if (attach_ssl_probes (skel , openssl_path , "OpenSSL" ) == 0 ) {
509- attached_count ++ ;
510- }
511- }
512-
513484 if (attached_count == 0 ) {
514485 fprintf (stderr , "\n❌ Failed to attach to any SSL library!\n" );
515486 fprintf (stderr , "💡 Make sure you're running as root: sudo %s\n" , argv [0 ]);
516487 if (!node_path ) {
517488 fprintf (stderr , "💡 Node.js not found at expected paths\n" );
518489 }
519- if (!openssl_path ) {
520- fprintf (stderr , "💡 OpenSSL library not found\n" );
521- }
522490 goto cleanup ;
523491 }
524492
@@ -556,6 +524,6 @@ int main(int argc, char **argv) {
556524
557525cleanup :
558526 ring_buffer__free (rb );
559- ssl_sniff_bpf__destroy (skel );
527+ claude_trace_bpf__destroy (skel );
560528 return 0 ;
561529}
0 commit comments