librats 0.5.4 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/lib/index.d.ts +210 -35
  2. package/native-src/CMakeLists.txt +148 -15
  3. package/native-src/LICENSE +1 -1
  4. package/native-src/src/bittorrent.cpp +11 -3679
  5. package/native-src/src/bittorrent.h +62 -719
  6. package/native-src/src/bt_bitfield.cpp +372 -0
  7. package/native-src/src/bt_bitfield.h +316 -0
  8. package/native-src/src/bt_choker.cpp +228 -0
  9. package/native-src/src/bt_choker.h +147 -0
  10. package/native-src/src/bt_client.cpp +1034 -0
  11. package/native-src/src/bt_client.h +443 -0
  12. package/native-src/src/bt_create_torrent.cpp +677 -0
  13. package/native-src/src/bt_create_torrent.h +473 -0
  14. package/native-src/src/bt_extension.cpp +469 -0
  15. package/native-src/src/bt_extension.h +309 -0
  16. package/native-src/src/bt_file_storage.cpp +261 -0
  17. package/native-src/src/bt_file_storage.h +298 -0
  18. package/native-src/src/bt_handshake.cpp +134 -0
  19. package/native-src/src/bt_handshake.h +157 -0
  20. package/native-src/src/bt_messages.cpp +364 -0
  21. package/native-src/src/bt_messages.h +324 -0
  22. package/native-src/src/bt_network.cpp +894 -0
  23. package/native-src/src/bt_network.h +397 -0
  24. package/native-src/src/bt_peer_connection.cpp +731 -0
  25. package/native-src/src/bt_peer_connection.h +586 -0
  26. package/native-src/src/bt_piece_picker.cpp +786 -0
  27. package/native-src/src/bt_piece_picker.h +473 -0
  28. package/native-src/src/bt_resume_data.cpp +410 -0
  29. package/native-src/src/bt_resume_data.h +249 -0
  30. package/native-src/src/bt_torrent.cpp +2109 -0
  31. package/native-src/src/bt_torrent.h +640 -0
  32. package/native-src/src/bt_torrent_info.cpp +659 -0
  33. package/native-src/src/bt_torrent_info.h +418 -0
  34. package/native-src/src/bt_types.h +354 -0
  35. package/native-src/src/chained_send_buffer.cpp +75 -0
  36. package/native-src/src/chained_send_buffer.h +137 -0
  37. package/native-src/src/crc32.cpp +97 -0
  38. package/native-src/src/crc32.h +129 -0
  39. package/native-src/src/crypto/blake2_endian.h +57 -0
  40. package/native-src/src/crypto/blake2b.c +202 -0
  41. package/native-src/src/crypto/blake2b.h +53 -0
  42. package/native-src/src/crypto/blake2s.c +266 -0
  43. package/native-src/src/crypto/blake2s.h +68 -0
  44. package/native-src/src/crypto/chacha.c +312 -0
  45. package/native-src/src/crypto/chacha.h +66 -0
  46. package/native-src/src/crypto/chachapoly.c +214 -0
  47. package/native-src/src/crypto/chachapoly.h +101 -0
  48. package/native-src/src/crypto/curve25519.c +863 -0
  49. package/native-src/src/crypto/curve25519.h +68 -0
  50. package/native-src/src/crypto/hkdf.c +266 -0
  51. package/native-src/src/crypto/hkdf.h +141 -0
  52. package/native-src/src/crypto/poly1305.c +566 -0
  53. package/native-src/src/crypto/poly1305.h +36 -0
  54. package/native-src/src/crypto/sha256.c +189 -0
  55. package/native-src/src/crypto/sha256.h +54 -0
  56. package/native-src/src/crypto/sha512.c +206 -0
  57. package/native-src/src/crypto/sha512.h +54 -0
  58. package/native-src/src/dht.cpp +454 -52
  59. package/native-src/src/dht.h +67 -4
  60. package/native-src/src/disk_io.cpp +632 -0
  61. package/native-src/src/disk_io.h +315 -0
  62. package/native-src/src/fs.cpp +29 -5
  63. package/native-src/src/gossipsub.cpp +5 -3
  64. package/native-src/src/ice.cpp +654 -1147
  65. package/native-src/src/ice.h +492 -261
  66. package/native-src/src/krpc.cpp +1 -1
  67. package/native-src/src/librats.cpp +469 -521
  68. package/native-src/src/librats.h +672 -315
  69. package/native-src/src/librats_bittorrent.cpp +390 -18
  70. package/native-src/src/librats_c.cpp +341 -120
  71. package/native-src/src/librats_c.h +106 -26
  72. package/native-src/src/librats_encryption.cpp +365 -65
  73. package/native-src/src/librats_ice.cpp +146 -452
  74. package/native-src/src/librats_persistence.cpp +2 -21
  75. package/native-src/src/librats_reconnection.cpp +229 -0
  76. package/native-src/src/librats_storage.cpp +189 -0
  77. package/native-src/src/network_utils.cpp +5 -5
  78. package/native-src/src/noise.cpp +628 -808
  79. package/native-src/src/noise.h +334 -154
  80. package/native-src/src/receive_buffer.cpp +82 -0
  81. package/native-src/src/receive_buffer.h +127 -0
  82. package/native-src/src/socket.cpp +87 -85
  83. package/native-src/src/socket.h +7 -0
  84. package/native-src/src/storage.cpp +1468 -0
  85. package/native-src/src/storage.h +541 -0
  86. package/native-src/src/stun.cpp +992 -352
  87. package/native-src/src/stun.h +450 -311
  88. package/native-src/src/tracker.cpp +161 -8
  89. package/native-src/src/tracker.h +51 -0
  90. package/native-src/src/turn.cpp +764 -0
  91. package/native-src/src/turn.h +460 -0
  92. package/package.json +1 -1
  93. package/scripts/prepare-package.js +2 -2
  94. package/src/librats_node.cpp +275 -92
  95. package/native-src/src/encrypted_socket.cpp +0 -817
  96. package/native-src/src/encrypted_socket.h +0 -239
  97. package/native-src/src/librats_nat.cpp +0 -571
package/lib/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * LibRats Node.js Bindings - TypeScript Definitions
3
3
  *
4
4
  * High-performance peer-to-peer networking library with support for DHT, GossipSub,
5
- * file transfer, NAT traversal, and more.
5
+ * file transfer, and more.
6
6
  */
7
7
 
8
8
  /**
@@ -15,22 +15,6 @@ export interface VersionInfo {
15
15
  build: number;
16
16
  }
17
17
 
18
- /**
19
- * Connection strategy options for connecting to peers
20
- */
21
- export enum ConnectionStrategy {
22
- /** Direct connection only, no NAT traversal */
23
- DIRECT_ONLY = 0,
24
- /** STUN-assisted connection */
25
- STUN_ASSISTED = 1,
26
- /** Full ICE negotiation with STUN and connection checks */
27
- ICE_FULL = 2,
28
- /** TURN relay connection */
29
- TURN_RELAY = 3,
30
- /** Automatic strategy selection based on network conditions */
31
- AUTO_ADAPTIVE = 4
32
- }
33
-
34
18
  /**
35
19
  * Error codes returned by various operations
36
20
  */
@@ -53,6 +37,39 @@ export enum ErrorCodes {
53
37
  JSON_PARSE = -7
54
38
  }
55
39
 
40
+ /**
41
+ * ICE connection states
42
+ */
43
+ export enum IceConnectionState {
44
+ NEW = 0,
45
+ GATHERING = 1,
46
+ CHECKING = 2,
47
+ CONNECTED = 3,
48
+ COMPLETED = 4,
49
+ FAILED = 5,
50
+ DISCONNECTED = 6,
51
+ CLOSED = 7
52
+ }
53
+
54
+ /**
55
+ * ICE gathering states
56
+ */
57
+ export enum IceGatheringState {
58
+ NEW = 0,
59
+ GATHERING = 1,
60
+ COMPLETE = 2
61
+ }
62
+
63
+ /**
64
+ * ICE candidate types
65
+ */
66
+ export enum IceCandidateType {
67
+ HOST = 0,
68
+ SRFLX = 1,
69
+ PRFLX = 2,
70
+ RELAY = 3
71
+ }
72
+
56
73
  /**
57
74
  * Main RatsClient class for peer-to-peer networking
58
75
  */
@@ -84,15 +101,6 @@ export class RatsClient {
84
101
  */
85
102
  connect(host: string, port: number): boolean;
86
103
 
87
- /**
88
- * Connect to a peer with a specific connection strategy
89
- * @param host - IP address or hostname of the peer
90
- * @param port - Port number of the peer
91
- * @param strategy - Connection strategy to use
92
- * @returns true if connection initiated successfully
93
- */
94
- connectWithStrategy(host: string, port: number, strategy: ConnectionStrategy): boolean;
95
-
96
104
  /**
97
105
  * Disconnect from a peer
98
106
  * @param peerId - ID of the peer to disconnect from
@@ -101,6 +109,12 @@ export class RatsClient {
101
109
 
102
110
  // ============ Information ============
103
111
 
112
+ /**
113
+ * Get the port the client is listening on
114
+ * @returns Listen port number
115
+ */
116
+ getListenPort(): number;
117
+
104
118
  /**
105
119
  * Get the number of connected peers
106
120
  * @returns Number of connected peers
@@ -276,6 +290,13 @@ export class RatsClient {
276
290
  */
277
291
  resumeFileTransfer(transferId: string): boolean;
278
292
 
293
+ /**
294
+ * Get file transfer progress information as JSON string
295
+ * @param transferId - ID of the transfer to query
296
+ * @returns JSON string with progress info, or null if not found
297
+ */
298
+ getFileTransferProgress(transferId: string): string | null;
299
+
279
300
  // ============ GossipSub ============
280
301
 
281
302
  /**
@@ -340,6 +361,12 @@ export class RatsClient {
340
361
  */
341
362
  getTopicPeers(topic: string): string[];
342
363
 
364
+ /**
365
+ * Get GossipSub statistics as JSON string
366
+ * @returns JSON string with statistics, or null if unavailable
367
+ */
368
+ getGossipsubStatistics(): string | null;
369
+
343
370
  // ============ DHT ============
344
371
 
345
372
  /**
@@ -395,6 +422,20 @@ export class RatsClient {
395
422
  */
396
423
  isMdnsRunning(): boolean;
397
424
 
425
+ /**
426
+ * Query for mDNS services
427
+ * @returns true if query sent successfully
428
+ */
429
+ queryMdnsServices(): boolean;
430
+
431
+ // ============ Address Blocking ============
432
+
433
+ /**
434
+ * Add an IP address to the ignore list
435
+ * @param ipAddress - IP address to ignore
436
+ */
437
+ addIgnoredAddress(ipAddress: string): void;
438
+
398
439
  // ============ Encryption ============
399
440
 
400
441
  /**
@@ -411,23 +452,157 @@ export class RatsClient {
411
452
  isEncryptionEnabled(): boolean;
412
453
 
413
454
  /**
414
- * Generate a new encryption key
415
- * @returns Hex-encoded encryption key, or null if failed
455
+ * Initialize encryption system
456
+ * @param enable - Whether to enable encryption
457
+ * @returns true if initialized successfully
416
458
  */
417
- generateEncryptionKey(): string | null;
459
+ initializeEncryption(enable: boolean): boolean;
418
460
 
419
461
  /**
420
- * Set the encryption key
421
- * @param keyHex - Hex-encoded encryption key
462
+ * Check if a specific peer connection is encrypted
463
+ * @param peerId - Peer ID to check
464
+ * @returns true if peer connection is encrypted
465
+ */
466
+ isPeerEncrypted(peerId: string): boolean;
467
+
468
+ /**
469
+ * Set custom Noise Protocol static keypair
470
+ * @param privateKeyHex - 32-byte private key as 64-char hex string
422
471
  * @returns true if set successfully
423
472
  */
424
- setEncryptionKey(keyHex: string): boolean;
473
+ setNoiseStaticKeypair(privateKeyHex: string): boolean;
474
+
475
+ /**
476
+ * Get our Noise Protocol static public key
477
+ * @returns 64-char hex string, or null if not available
478
+ */
479
+ getNoiseStaticPublicKey(): string | null;
480
+
481
+ /**
482
+ * Get remote peer's Noise static public key
483
+ * @param peerId - Peer ID to query
484
+ * @returns 64-char hex string, or null if not available
485
+ */
486
+ getPeerNoisePublicKey(peerId: string): string | null;
487
+
488
+ /**
489
+ * Get handshake hash for channel binding
490
+ * @param peerId - Peer ID to query
491
+ * @returns 64-char hex string, or null if not available
492
+ */
493
+ getPeerHandshakeHash(peerId: string): string | null;
494
+
495
+ // ============ ICE (NAT Traversal) ============
496
+
497
+ /**
498
+ * Check if ICE is available
499
+ * @returns true if ICE is available
500
+ */
501
+ isIceAvailable(): boolean;
502
+
503
+ /**
504
+ * Add a STUN server for NAT traversal
505
+ * @param host - STUN server hostname or IP
506
+ * @param port - STUN server port (default: 3478)
507
+ */
508
+ addStunServer(host: string, port?: number): void;
509
+
510
+ /**
511
+ * Add a TURN server for relay-based NAT traversal
512
+ * @param host - TURN server hostname or IP
513
+ * @param port - TURN server port
514
+ * @param username - TURN username
515
+ * @param password - TURN password
516
+ */
517
+ addTurnServer(host: string, port: number, username: string, password: string): void;
518
+
519
+ /**
520
+ * Clear all ICE (STUN/TURN) servers
521
+ */
522
+ clearIceServers(): void;
523
+
524
+ /**
525
+ * Start gathering ICE candidates
526
+ * @returns true if gathering started successfully
527
+ */
528
+ gatherIceCandidates(): boolean;
529
+
530
+ /**
531
+ * Get local ICE candidates as JSON string
532
+ * @returns JSON string of candidates, or null if unavailable
533
+ */
534
+ getIceCandidates(): string | null;
535
+
536
+ /**
537
+ * Check if ICE candidate gathering is complete
538
+ * @returns true if gathering is complete
539
+ */
540
+ isIceGatheringComplete(): boolean;
541
+
542
+ /**
543
+ * Get public address discovered via STUN
544
+ * @returns Address string (ip:port), or null if not discovered
545
+ */
546
+ getPublicAddress(): string | null;
547
+
548
+ /**
549
+ * Perform a simple STUN binding request to discover public address
550
+ * @param stunServer - STUN server hostname (default: "stun.l.google.com")
551
+ * @param port - STUN server port (default: 19302)
552
+ * @param timeoutMs - Timeout in milliseconds (default: 5000)
553
+ * @returns Address string (ip:port), or null on failure
554
+ */
555
+ discoverPublicAddress(stunServer?: string, port?: number, timeoutMs?: number): string | null;
556
+
557
+ /**
558
+ * Add a remote ICE candidate from SDP
559
+ * @param candidateSdp - SDP candidate string
560
+ */
561
+ addRemoteIceCandidate(candidateSdp: string): void;
562
+
563
+ /**
564
+ * Signal end of remote ICE candidates (trickle ICE complete)
565
+ */
566
+ endOfRemoteIceCandidates(): void;
567
+
568
+ /**
569
+ * Start ICE connectivity checks
570
+ */
571
+ startIceChecks(): void;
572
+
573
+ /**
574
+ * Get current ICE connection state
575
+ * @returns ICE connection state value
576
+ */
577
+ getIceConnectionState(): number;
578
+
579
+ /**
580
+ * Get ICE gathering state
581
+ * @returns ICE gathering state value
582
+ */
583
+ getIceGatheringState(): number;
584
+
585
+ /**
586
+ * Check if ICE is connected
587
+ * @returns true if ICE connection is established
588
+ */
589
+ isIceConnected(): boolean;
590
+
591
+ /**
592
+ * Get the selected ICE candidate pair as JSON string
593
+ * @returns JSON string of selected pair, or null if unavailable
594
+ */
595
+ getIceSelectedPair(): string | null;
596
+
597
+ /**
598
+ * Close ICE manager and release resources
599
+ */
600
+ closeIce(): void;
425
601
 
426
602
  /**
427
- * Get the current encryption key
428
- * @returns Hex-encoded encryption key, or null if not set
603
+ * Restart ICE (re-gather candidates and restart checks)
429
604
  */
430
- getEncryptionKey(): string | null;
605
+ restartIce(): void;
431
606
 
432
607
  // ============ Configuration Persistence ============
433
608
 
@@ -77,11 +77,13 @@ endif()
77
77
  option(RATS_BUILD_EXAMPLES "Build examples" ON)
78
78
  option(RATS_BUILD_TESTS "Build unit tests" ON)
79
79
  option(RATS_ENABLE_ASAN "Enable AddressSanitizer" OFF)
80
+ option(RATS_ENABLE_TSAN "Enable ThreadSanitizer" OFF)
80
81
  option(RATS_BINDINGS "Enable bindings" ON)
81
82
  option(RATS_CROSSCOMPILING "Force cross-compilation flags" OFF)
82
83
  option(RATS_SHARED_LIBRARY "Build as shared library" OFF)
83
84
  option(RATS_STATIC_LIBRARY "Build as static library" ON)
84
85
  option(RATS_SEARCH_FEATURES "Features related to rats-search project (like bittorrent)" OFF)
86
+ option(RATS_STORAGE "Enable distributed storage module" OFF)
85
87
 
86
88
  # Validate library type options
87
89
  if(RATS_SHARED_LIBRARY AND RATS_STATIC_LIBRARY)
@@ -127,31 +129,22 @@ set(LIBRARY_SOURCES
127
129
  src/krpc.cpp
128
130
  src/krpc.h
129
131
  src/librats.cpp
132
+ src/librats_reconnection.cpp
130
133
  src/librats_logging.cpp
134
+ src/librats_encryption.cpp
131
135
  src/librats_file_transfer.cpp
132
136
  src/librats_gossipsub.cpp
133
- src/librats_nat.cpp
134
- src/librats_ice.cpp
135
137
  src/librats_mdns.cpp
136
138
  src/librats_persistence.cpp
137
- src/librats_encryption.cpp
138
139
  src/librats.h
139
140
  src/sha1.cpp
140
141
  src/sha1.h
141
142
  src/os.cpp
142
143
  src/os.h
143
- src/stun.cpp
144
- src/stun.h
145
- src/ice.cpp
146
- src/ice.h
147
144
  src/fs.cpp
148
145
  src/fs.h
149
146
  src/logger.h
150
147
  src/logger.cpp
151
- src/noise.cpp
152
- src/noise.h
153
- src/encrypted_socket.cpp
154
- src/encrypted_socket.h
155
148
  src/mdns.cpp
156
149
  src/mdns.h
157
150
  src/threadmanager.cpp
@@ -163,6 +156,46 @@ set(LIBRARY_SOURCES
163
156
  src/version.cpp
164
157
  src/rats_export.h
165
158
  ${PROJECT_BINARY_DIR}/src/version.h
159
+
160
+ # Buffer utilities for bittorrent and file transfer
161
+ src/receive_buffer.h
162
+ src/receive_buffer.cpp
163
+ src/chained_send_buffer.h
164
+ src/chained_send_buffer.cpp
165
+
166
+ # Cypto algorithms including Noise Protocol needed
167
+ src/crypto/curve25519.c
168
+ src/crypto/curve25519.h
169
+ src/crypto/chacha.c
170
+ src/crypto/chacha.h
171
+ src/crypto/poly1305.c
172
+ src/crypto/poly1305.h
173
+ src/crypto/chachapoly.c
174
+ src/crypto/chachapoly.h
175
+ src/crypto/sha256.c
176
+ src/crypto/sha256.h
177
+ src/crypto/sha512.c
178
+ src/crypto/sha512.h
179
+ src/crypto/hkdf.c
180
+ src/crypto/hkdf.h
181
+ src/crypto/blake2s.c
182
+ src/crypto/blake2s.h
183
+ src/crypto/blake2b.c
184
+ src/crypto/blake2b.h
185
+ src/crypto/blake2_endian.h
186
+
187
+ # Noise Protocol implementation
188
+ src/noise.cpp
189
+ src/noise.h
190
+
191
+ # NAT traversal (STUN/TURN/ICE)
192
+ src/stun.cpp
193
+ src/stun.h
194
+ src/turn.cpp
195
+ src/turn.h
196
+ src/ice.cpp
197
+ src/ice.h
198
+ src/librats_ice.cpp
166
199
  )
167
200
 
168
201
  # Add BitTorrent sources if RATS_SEARCH_FEATURES is enabled
@@ -171,8 +204,50 @@ if(RATS_SEARCH_FEATURES)
171
204
  src/librats_bittorrent.cpp
172
205
  src/bittorrent.cpp
173
206
  src/bittorrent.h
207
+ src/bt_types.h
208
+ src/bt_bitfield.h
209
+ src/bt_bitfield.cpp
210
+ src/bt_file_storage.h
211
+ src/bt_file_storage.cpp
212
+ src/bt_torrent_info.h
213
+ src/bt_torrent_info.cpp
214
+ src/bt_piece_picker.h
215
+ src/bt_piece_picker.cpp
216
+ src/bt_messages.h
217
+ src/bt_messages.cpp
218
+ src/bt_handshake.h
219
+ src/bt_handshake.cpp
220
+ src/bt_peer_connection.h
221
+ src/bt_peer_connection.cpp
222
+ src/bt_extension.h
223
+ src/bt_extension.cpp
224
+ src/bt_choker.h
225
+ src/bt_choker.cpp
226
+ src/bt_torrent.h
227
+ src/bt_torrent.cpp
228
+ src/bt_client.h
229
+ src/bt_client.cpp
230
+ src/bt_network.h
231
+ src/bt_network.cpp
232
+ src/disk_io.cpp
233
+ src/disk_io.h
174
234
  src/tracker.cpp
175
235
  src/tracker.h
236
+ src/bt_create_torrent.h
237
+ src/bt_create_torrent.cpp
238
+ src/bt_resume_data.h
239
+ src/bt_resume_data.cpp
240
+ )
241
+ endif()
242
+
243
+ # Add Storage sources if RATS_STORAGE is enabled
244
+ if(RATS_STORAGE)
245
+ list(APPEND LIBRARY_SOURCES
246
+ src/crc32.cpp
247
+ src/crc32.h
248
+ src/storage.cpp
249
+ src/storage.h
250
+ src/librats_storage.cpp
176
251
  )
177
252
  endif()
178
253
 
@@ -200,6 +275,7 @@ set_target_properties(rats PROPERTIES POSITION_INDEPENDENT_CODE ON)
200
275
 
201
276
  # Include directories
202
277
  target_include_directories(rats PUBLIC ${PROJECT_BINARY_DIR}/src src)
278
+ target_include_directories(rats PUBLIC ${PROJECT_SOURCE_DIR}/src/crypto)
203
279
 
204
280
  # Find and link threading support
205
281
  find_package(Threads REQUIRED)
@@ -235,6 +311,11 @@ if(RATS_SEARCH_FEATURES)
235
311
  target_compile_definitions(rats PUBLIC RATS_SEARCH_FEATURES)
236
312
  endif(RATS_SEARCH_FEATURES)
237
313
 
314
+ if(RATS_STORAGE)
315
+ message(STATUS "Enable distributed storage module")
316
+ target_compile_definitions(rats PUBLIC RATS_STORAGE)
317
+ endif(RATS_STORAGE)
318
+
238
319
  # Create the main executable
239
320
  if(RATS_BUILD_EXAMPLES)
240
321
  add_executable(rats-client src/main.cpp)
@@ -258,6 +339,11 @@ set_target_properties(rats PROPERTIES
258
339
  RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
259
340
  )
260
341
 
342
+ # Sanitizer configuration - ASAN and TSAN are mutually exclusive
343
+ if(RATS_ENABLE_ASAN AND RATS_ENABLE_TSAN)
344
+ message(FATAL_ERROR "AddressSanitizer and ThreadSanitizer cannot be enabled simultaneously")
345
+ endif()
346
+
261
347
  # AddressSanitizer configuration
262
348
  if(RATS_ENABLE_ASAN)
263
349
  if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
@@ -278,6 +364,21 @@ if(RATS_ENABLE_ASAN)
278
364
  endif()
279
365
  endif()
280
366
 
367
+ # ThreadSanitizer configuration
368
+ if(RATS_ENABLE_TSAN)
369
+ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
370
+ set(TSAN_FLAGS "-fsanitize=thread -fno-omit-frame-pointer -g")
371
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TSAN_FLAGS}")
372
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TSAN_FLAGS}")
373
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${TSAN_FLAGS}")
374
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${TSAN_FLAGS}")
375
+
376
+ message(STATUS "ThreadSanitizer enabled (GCC/Clang)")
377
+ else()
378
+ message(WARNING "ThreadSanitizer is only supported by GCC/Clang compilers")
379
+ endif()
380
+ endif()
381
+
281
382
  if(RATS_BUILD_TESTS)
282
383
  target_compile_definitions(rats PUBLIC TESTING)
283
384
 
@@ -311,23 +412,55 @@ if(RATS_BUILD_TESTS)
311
412
  tests/test_dht.cpp
312
413
  tests/test_rats_client.cpp
313
414
  tests/test_os.cpp
314
- tests/test_stun.cpp
315
- tests/test_ice.cpp
316
415
  tests/test_fs.cpp
317
416
  tests/test_config_persistence.cpp
318
417
  tests/test_main.cpp
319
418
  tests/test_message_exchange.cpp
320
- tests/test_noise.cpp
321
419
  tests/test_gossipsub.cpp
322
420
  tests/test_logging_api_gtest.cpp
323
421
  tests/test_file_transfer.cpp
422
+ tests/test_reconnection.cpp
423
+ # Noise Protocol Crypto tests
424
+ tests/test_crypto_curve25519.cpp
425
+ tests/test_crypto_chacha_poly.cpp
426
+ tests/test_crypto_sha2.cpp
427
+ tests/test_crypto_blake2.cpp
428
+ tests/test_noise.cpp
429
+ # NAT traversal tests (STUN/TURN/ICE)
430
+ tests/test_stun.cpp
431
+ tests/test_turn.cpp
432
+ tests/test_ice.cpp
433
+ # Buffer utilities for file transfer and bittorrent
434
+ tests/test_receive_buffer.cpp
435
+ tests/test_chained_send_buffer.cpp
324
436
  )
325
-
437
+
326
438
  # Add BitTorrent tests if RATS_SEARCH_FEATURES is enabled
327
439
  if(RATS_SEARCH_FEATURES)
328
440
  list(APPEND TEST_SOURCES
329
441
  tests/test_bittorrent.cpp
330
442
  tests/test_tracker.cpp
443
+ tests/test_disk_io.cpp
444
+ tests/test_bt_bitfield.cpp
445
+ tests/test_bt_file_storage.cpp
446
+ tests/test_bt_torrent_info.cpp
447
+ tests/test_bt_piece_picker.cpp
448
+ tests/test_bt_messages.cpp
449
+ tests/test_bt_handshake.cpp
450
+ tests/test_bt_peer_connection.cpp
451
+ tests/test_bt_extension.cpp
452
+ tests/test_bt_network.cpp
453
+ tests/test_bt_integration.cpp
454
+ tests/test_bt_create_torrent.cpp
455
+ tests/test_bt_resume_data.cpp
456
+ )
457
+ endif()
458
+
459
+ # Add Storage tests if RATS_STORAGE is enabled
460
+ if(RATS_STORAGE)
461
+ list(APPEND TEST_SOURCES
462
+ tests/test_crc32.cpp
463
+ tests/test_storage.cpp
331
464
  )
332
465
  endif()
333
466
 
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 librats contributors
3
+ Copyright (c) 2026 librats contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal