librats 1.0.2 → 2.2.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.
- package/README.md +145 -331
- package/binding.gyp +16 -3
- package/lib/index.d.ts +288 -696
- package/lib/index.js +407 -44
- package/native-src/3rdparty/android/ifaddrs-android.c +1 -0
- package/native-src/3rdparty/android/ifaddrs-android.h +1 -0
- package/native-src/CMakeLists.txt +404 -179
- package/native-src/LICENSE +1 -1
- package/native-src/src/librats/bindings/rats.cpp +762 -0
- package/native-src/src/librats/bindings/rats.h +380 -0
- package/native-src/src/librats/bittorrent/bencode.cpp +437 -0
- package/native-src/src/librats/bittorrent/bencode.h +176 -0
- package/native-src/src/librats/bittorrent/bitfield.cpp +97 -0
- package/native-src/src/librats/bittorrent/bitfield.h +76 -0
- package/native-src/src/librats/bittorrent/byte_io.h +58 -0
- package/native-src/src/librats/bittorrent/choker.cpp +25 -0
- package/native-src/src/librats/bittorrent/choker.h +46 -0
- package/native-src/src/librats/bittorrent/client.cpp +413 -0
- package/native-src/src/librats/bittorrent/client.h +227 -0
- package/native-src/src/librats/bittorrent/disk_io.cpp +209 -0
- package/native-src/src/librats/bittorrent/disk_io.h +150 -0
- package/native-src/src/librats/bittorrent/extensions.cpp +191 -0
- package/native-src/src/librats/bittorrent/extensions.h +94 -0
- package/native-src/src/librats/bittorrent/file_storage.cpp +77 -0
- package/native-src/src/librats/bittorrent/file_storage.h +79 -0
- package/native-src/src/librats/bittorrent/log.h +42 -0
- package/native-src/src/librats/bittorrent/magnet_uri.cpp +98 -0
- package/native-src/src/librats/bittorrent/magnet_uri.h +35 -0
- package/native-src/src/librats/bittorrent/peer_connection.cpp +502 -0
- package/native-src/src/librats/bittorrent/peer_connection.h +194 -0
- package/native-src/src/librats/bittorrent/peer_list.cpp +68 -0
- package/native-src/src/librats/bittorrent/peer_list.h +75 -0
- package/native-src/src/librats/bittorrent/piece_picker.cpp +352 -0
- package/native-src/src/librats/bittorrent/piece_picker.h +201 -0
- package/native-src/src/librats/bittorrent/reactor.cpp +97 -0
- package/native-src/src/librats/bittorrent/reactor.h +89 -0
- package/native-src/src/librats/bittorrent/resume_data.cpp +72 -0
- package/native-src/src/librats/bittorrent/resume_data.h +41 -0
- package/native-src/src/librats/bittorrent/store_buffer.cpp +48 -0
- package/native-src/src/librats/bittorrent/store_buffer.h +47 -0
- package/native-src/src/librats/bittorrent/torrent.cpp +870 -0
- package/native-src/src/librats/bittorrent/torrent.h +260 -0
- package/native-src/src/librats/bittorrent/torrent_creator.cpp +129 -0
- package/native-src/src/librats/bittorrent/torrent_creator.h +58 -0
- package/native-src/src/librats/bittorrent/torrent_info.cpp +314 -0
- package/native-src/src/librats/bittorrent/torrent_info.h +118 -0
- package/native-src/src/librats/bittorrent/tracker.cpp +374 -0
- package/native-src/src/librats/bittorrent/tracker.h +108 -0
- package/native-src/src/librats/bittorrent/types.cpp +206 -0
- package/native-src/src/librats/bittorrent/types.h +86 -0
- package/native-src/src/librats/core/address.cpp +35 -0
- package/native-src/src/librats/core/address.h +78 -0
- package/native-src/src/librats/core/bytes.h +69 -0
- package/native-src/src/librats/core/chained_send_buffer.cpp +172 -0
- package/native-src/src/librats/core/chained_send_buffer.h +183 -0
- package/native-src/src/librats/core/endpoint_parse.cpp +41 -0
- package/native-src/src/librats/core/endpoint_parse.h +31 -0
- package/native-src/src/librats/core/event_bus.h +70 -0
- package/native-src/src/librats/core/host_endpoint.h +56 -0
- package/native-src/src/{io_poller.cpp → librats/core/io_poller.cpp} +520 -65
- package/native-src/src/{io_poller.h → librats/core/io_poller.h} +12 -6
- package/native-src/src/librats/core/ip_address.cpp +120 -0
- package/native-src/src/librats/core/ip_address.h +109 -0
- package/native-src/src/librats/core/mpsc_queue.h +47 -0
- package/native-src/src/librats/core/notifier.h +74 -0
- package/native-src/src/librats/core/receive_buffer.cpp +219 -0
- package/native-src/src/librats/core/receive_buffer.h +171 -0
- package/native-src/src/librats/core/service_registry.h +58 -0
- package/native-src/src/{socket.cpp → librats/core/socket.cpp} +625 -118
- package/native-src/src/librats/core/socket.h +496 -0
- package/native-src/src/librats/core/timer_queue.h +105 -0
- package/native-src/src/librats/core/types.cpp +43 -0
- package/native-src/src/librats/core/types.h +103 -0
- package/native-src/src/librats/core/wakeup_pipe.h +83 -0
- package/native-src/src/{crypto → librats/crypto}/blake2_endian.h +21 -23
- package/native-src/src/{crypto → librats/crypto}/blake2b.c +34 -33
- package/native-src/src/{crypto → librats/crypto}/blake2b.h +7 -6
- package/native-src/src/{crypto → librats/crypto}/blake2s.c +55 -54
- package/native-src/src/{crypto → librats/crypto}/blake2s.h +13 -12
- package/native-src/src/{crypto → librats/crypto}/chacha.c +22 -21
- package/native-src/src/{crypto → librats/crypto}/chacha.h +14 -13
- package/native-src/src/{crypto → librats/crypto}/chachapoly.c +56 -56
- package/native-src/src/{crypto → librats/crypto}/chachapoly.h +24 -17
- package/native-src/src/{crc32.cpp → librats/crypto/crc32.cpp} +1 -1
- package/native-src/src/{crc32.h → librats/crypto/crc32.h} +3 -1
- package/native-src/src/{crypto → librats/crypto}/curve25519.c +6 -4
- package/native-src/src/{crypto → librats/crypto}/curve25519.h +6 -3
- package/native-src/src/librats/crypto/hkdf.c +266 -0
- package/native-src/src/{crypto → librats/crypto}/hkdf.h +19 -19
- package/native-src/src/{noise.cpp → librats/crypto/noise.cpp} +84 -73
- package/native-src/src/{noise.h → librats/crypto/noise.h} +18 -8
- package/native-src/src/{crypto → librats/crypto}/poly1305.c +47 -46
- package/native-src/src/librats/crypto/poly1305.h +37 -0
- package/native-src/src/{sha1.cpp → librats/crypto/sha1.cpp} +33 -1
- package/native-src/src/{sha1.h → librats/crypto/sha1.h} +14 -6
- package/native-src/src/{crypto → librats/crypto}/sha256.c +15 -14
- package/native-src/src/{crypto → librats/crypto}/sha256.h +8 -7
- package/native-src/src/{crypto → librats/crypto}/sha512.c +15 -14
- package/native-src/src/{crypto → librats/crypto}/sha512.h +8 -7
- package/native-src/src/librats/dht/announce.cpp +37 -0
- package/native-src/src/librats/dht/announce.h +41 -0
- package/native-src/src/librats/dht/bep42.cpp +109 -0
- package/native-src/src/librats/dht/bep42.h +48 -0
- package/native-src/src/librats/dht/dht.cpp +501 -0
- package/native-src/src/librats/dht/dht.h +119 -0
- package/native-src/src/librats/dht/dht_runner.cpp +103 -0
- package/native-src/src/librats/dht/dht_runner.h +71 -0
- package/native-src/src/librats/dht/dos_blocker.cpp +42 -0
- package/native-src/src/librats/dht/dos_blocker.h +47 -0
- package/native-src/src/librats/dht/find_peers.cpp +52 -0
- package/native-src/src/librats/dht/find_peers.h +73 -0
- package/native-src/src/librats/dht/id.h +167 -0
- package/native-src/src/{krpc.cpp → librats/dht/krpc.cpp} +32 -81
- package/native-src/src/{krpc.h → librats/dht/krpc.h} +19 -23
- package/native-src/src/librats/dht/log.h +38 -0
- package/native-src/src/librats/dht/node.cpp +473 -0
- package/native-src/src/librats/dht/node.h +164 -0
- package/native-src/src/librats/dht/node_entry.h +81 -0
- package/native-src/src/librats/dht/observer.h +72 -0
- package/native-src/src/librats/dht/persistence.cpp +90 -0
- package/native-src/src/librats/dht/persistence.h +32 -0
- package/native-src/src/librats/dht/routing_table.cpp +559 -0
- package/native-src/src/librats/dht/routing_table.h +185 -0
- package/native-src/src/librats/dht/rpc_manager.cpp +127 -0
- package/native-src/src/librats/dht/rpc_manager.h +77 -0
- package/native-src/src/librats/dht/storage.cpp +92 -0
- package/native-src/src/librats/dht/storage.h +74 -0
- package/native-src/src/librats/dht/transport.h +27 -0
- package/native-src/src/librats/dht/traversal.cpp +326 -0
- package/native-src/src/librats/dht/traversal.h +120 -0
- package/native-src/src/librats/dht/udp_transport.cpp +49 -0
- package/native-src/src/librats/dht/udp_transport.h +51 -0
- package/native-src/src/librats/mdns/log.h +22 -0
- package/native-src/src/{mdns.cpp → librats/mdns/mdns.cpp} +75 -40
- package/native-src/src/{mdns.h → librats/mdns/mdns.h} +9 -8
- package/native-src/src/{natpmp.cpp → librats/nat/natpmp.cpp} +12 -9
- package/native-src/src/{natpmp.h → librats/nat/natpmp.h} +3 -3
- package/native-src/src/{port_mapping.h → librats/nat/port_mapping.h} +3 -2
- package/native-src/src/{stun.cpp → librats/nat/stun.cpp} +4 -4
- package/native-src/src/{stun.h → librats/nat/stun.h} +1 -1
- package/native-src/src/{upnp.cpp → librats/nat/upnp.cpp} +6 -6
- package/native-src/src/{upnp.h → librats/nat/upnp.h} +2 -2
- package/native-src/src/librats/node/circuit_service.h +84 -0
- package/native-src/src/librats/node/config.h +110 -0
- package/native-src/src/librats/node/dial_service.h +54 -0
- package/native-src/src/librats/node/dialer.cpp +264 -0
- package/native-src/src/librats/node/dialer.h +188 -0
- package/native-src/src/librats/node/host_events.h +26 -0
- package/native-src/src/librats/node/identify.cpp +130 -0
- package/native-src/src/librats/node/identify.h +71 -0
- package/native-src/src/librats/node/nat_status.cpp +103 -0
- package/native-src/src/librats/node/nat_status.h +118 -0
- package/native-src/src/librats/node/node.cpp +865 -0
- package/native-src/src/librats/node/node.h +344 -0
- package/native-src/src/librats/node/node_context.h +33 -0
- package/native-src/src/librats/node/peer_network.h +91 -0
- package/native-src/src/librats/peer/peer.h +49 -0
- package/native-src/src/librats/peer/peer_book.cpp +181 -0
- package/native-src/src/librats/peer/peer_book.h +88 -0
- package/native-src/src/librats/peer/peer_id.cpp +72 -0
- package/native-src/src/librats/peer/peer_id.h +62 -0
- package/native-src/src/librats/peer/peer_info.h +37 -0
- package/native-src/src/librats/peer/peer_table.cpp +170 -0
- package/native-src/src/librats/peer/peer_table.h +148 -0
- package/native-src/src/librats/security/handshaker.h +66 -0
- package/native-src/src/librats/security/identity.h +43 -0
- package/native-src/src/librats/security/noise_security.cpp +122 -0
- package/native-src/src/librats/security/noise_security.h +37 -0
- package/native-src/src/librats/security/plaintext_security.h +106 -0
- package/native-src/src/librats/security/session.h +37 -0
- package/native-src/src/{storage.cpp → librats/storage/storage.cpp} +369 -522
- package/native-src/src/{storage.h → librats/storage/storage.h} +135 -299
- package/native-src/src/librats/subsystems/bittorrent.cpp +211 -0
- package/native-src/src/librats/subsystems/bittorrent.h +136 -0
- package/native-src/src/librats/subsystems/dht_discovery.cpp +202 -0
- package/native-src/src/librats/subsystems/dht_discovery.h +123 -0
- package/native-src/src/librats/subsystems/dht_service.h +36 -0
- package/native-src/src/librats/subsystems/file_transfer.cpp +972 -0
- package/native-src/src/librats/subsystems/file_transfer.h +367 -0
- package/native-src/src/librats/subsystems/hole_punch.cpp +605 -0
- package/native-src/src/librats/subsystems/hole_punch.h +290 -0
- package/native-src/src/librats/subsystems/hole_punch_service.h +38 -0
- package/native-src/src/librats/subsystems/mdns_discovery.cpp +66 -0
- package/native-src/src/librats/subsystems/mdns_discovery.h +55 -0
- package/native-src/src/librats/subsystems/message_json.cpp +112 -0
- package/native-src/src/librats/subsystems/message_json.h +88 -0
- package/native-src/src/librats/subsystems/peer_exchange.cpp +241 -0
- package/native-src/src/librats/subsystems/peer_exchange.h +136 -0
- package/native-src/src/librats/subsystems/ping_service.cpp +98 -0
- package/native-src/src/librats/subsystems/ping_service.h +66 -0
- package/native-src/src/librats/subsystems/port_mapping_service.cpp +192 -0
- package/native-src/src/librats/subsystems/port_mapping_service.h +84 -0
- package/native-src/src/librats/subsystems/pubsub.cpp +567 -0
- package/native-src/src/librats/subsystems/pubsub.h +175 -0
- package/native-src/src/librats/subsystems/reconnection.cpp +239 -0
- package/native-src/src/librats/subsystems/reconnection.h +126 -0
- package/native-src/src/librats/subsystems/relay.cpp +1142 -0
- package/native-src/src/librats/subsystems/relay.h +211 -0
- package/native-src/src/librats/subsystems/relay_service.h +46 -0
- package/native-src/src/librats/transport/connection.cpp +343 -0
- package/native-src/src/librats/transport/connection.h +283 -0
- package/native-src/src/librats/transport/link.h +96 -0
- package/native-src/src/librats/transport/reactor.cpp +588 -0
- package/native-src/src/librats/transport/reactor.h +262 -0
- package/native-src/src/librats/transport/reactor_pool.h +81 -0
- package/native-src/src/librats/transport/relay_link.cpp +208 -0
- package/native-src/src/librats/transport/relay_link.h +303 -0
- package/native-src/src/librats/transport/tcp_link.cpp +49 -0
- package/native-src/src/librats/transport/tcp_link.h +43 -0
- package/native-src/src/librats/transport/udp_mux.cpp +617 -0
- package/native-src/src/librats/transport/udp_mux.h +363 -0
- package/native-src/src/librats/transport/udp_packet.cpp +121 -0
- package/native-src/src/librats/transport/udp_packet.h +190 -0
- package/native-src/src/librats/transport/udp_stream.cpp +1194 -0
- package/native-src/src/librats/transport/udp_stream.h +614 -0
- package/native-src/src/librats/util/features.h.in +51 -0
- package/native-src/src/{fs.cpp → librats/util/fs.cpp} +51 -3
- package/native-src/src/librats/util/fs.h +136 -0
- package/native-src/src/librats/util/json.cpp +1002 -0
- package/native-src/src/librats/util/json.h +444 -0
- package/native-src/src/{logger.cpp → librats/util/logger.cpp} +1 -1
- package/native-src/src/{logger.h → librats/util/logger.h} +43 -31
- package/native-src/src/{network_monitor.cpp → librats/util/network_monitor.cpp} +12 -4
- package/native-src/src/{network_monitor.h → librats/util/network_monitor.h} +2 -1
- package/native-src/src/{network_utils.cpp → librats/util/network_utils.cpp} +38 -23
- package/native-src/src/{network_utils.h → librats/util/network_utils.h} +15 -8
- package/native-src/src/{os.cpp → librats/util/os.cpp} +48 -18
- package/native-src/src/librats/util/rats_export.h +69 -0
- package/native-src/src/{version.cpp → librats/util/version.cpp} +2 -2
- package/native-src/src/{version.h.in → librats/util/version.h.in} +1 -1
- package/native-src/src/librats/wire/frame.cpp +76 -0
- package/native-src/src/librats/wire/frame.h +111 -0
- package/native-src/src/librats/wire/message_router.cpp +45 -0
- package/native-src/src/librats/wire/message_router.h +47 -0
- package/package.json +5 -4
- package/scripts/build-librats.js +1 -0
- package/scripts/postinstall.js +3 -3
- package/scripts/prepare-package.js +4 -4
- package/scripts/verify-installation.js +63 -105
- package/src/librats_node.cpp +1067 -1323
- package/native-src/src/bencode.cpp +0 -485
- package/native-src/src/bencode.h +0 -145
- package/native-src/src/bittorrent.cpp +0 -14
- package/native-src/src/bittorrent.h +0 -74
- package/native-src/src/bt_bitfield.cpp +0 -372
- package/native-src/src/bt_bitfield.h +0 -316
- package/native-src/src/bt_choker.cpp +0 -228
- package/native-src/src/bt_choker.h +0 -147
- package/native-src/src/bt_client.cpp +0 -1047
- package/native-src/src/bt_client.h +0 -445
- package/native-src/src/bt_create_torrent.cpp +0 -677
- package/native-src/src/bt_create_torrent.h +0 -473
- package/native-src/src/bt_extension.cpp +0 -469
- package/native-src/src/bt_extension.h +0 -309
- package/native-src/src/bt_file_storage.cpp +0 -261
- package/native-src/src/bt_file_storage.h +0 -298
- package/native-src/src/bt_handshake.cpp +0 -134
- package/native-src/src/bt_handshake.h +0 -157
- package/native-src/src/bt_messages.cpp +0 -364
- package/native-src/src/bt_messages.h +0 -324
- package/native-src/src/bt_network.cpp +0 -1007
- package/native-src/src/bt_network.h +0 -417
- package/native-src/src/bt_peer_connection.cpp +0 -742
- package/native-src/src/bt_peer_connection.h +0 -592
- package/native-src/src/bt_piece_picker.cpp +0 -786
- package/native-src/src/bt_piece_picker.h +0 -473
- package/native-src/src/bt_resume_data.cpp +0 -410
- package/native-src/src/bt_resume_data.h +0 -249
- package/native-src/src/bt_torrent.cpp +0 -2120
- package/native-src/src/bt_torrent.h +0 -641
- package/native-src/src/bt_torrent_info.cpp +0 -659
- package/native-src/src/bt_torrent_info.h +0 -418
- package/native-src/src/bt_types.h +0 -621
- package/native-src/src/chained_send_buffer.cpp +0 -75
- package/native-src/src/chained_send_buffer.h +0 -137
- package/native-src/src/crypto/hkdf.c +0 -266
- package/native-src/src/crypto/poly1305.h +0 -36
- package/native-src/src/dht.cpp +0 -3311
- package/native-src/src/dht.h +0 -717
- package/native-src/src/disk_io.cpp +0 -632
- package/native-src/src/disk_io.h +0 -315
- package/native-src/src/file_transfer.cpp +0 -1415
- package/native-src/src/file_transfer.h +0 -286
- package/native-src/src/fs.h +0 -108
- package/native-src/src/gossipsub.cpp +0 -1139
- package/native-src/src/gossipsub.h +0 -403
- package/native-src/src/ice.cpp +0 -893
- package/native-src/src/ice.h +0 -559
- package/native-src/src/json.hpp +0 -25526
- package/native-src/src/librats.cpp +0 -2378
- package/native-src/src/librats.h +0 -2324
- package/native-src/src/librats_bittorrent.cpp +0 -601
- package/native-src/src/librats_c.cpp +0 -1557
- package/native-src/src/librats_c.h +0 -323
- package/native-src/src/librats_discovery.cpp +0 -402
- package/native-src/src/librats_encryption.cpp +0 -275
- package/native-src/src/librats_file_transfer.cpp +0 -144
- package/native-src/src/librats_gossipsub.cpp +0 -289
- package/native-src/src/librats_ice.cpp +0 -213
- package/native-src/src/librats_log_macros.h +0 -36
- package/native-src/src/librats_logging.cpp +0 -173
- package/native-src/src/librats_mdns.cpp +0 -166
- package/native-src/src/librats_persistence.cpp +0 -796
- package/native-src/src/librats_portmap.cpp +0 -419
- package/native-src/src/librats_reconnection.cpp +0 -218
- package/native-src/src/librats_statistic.cpp +0 -105
- package/native-src/src/librats_storage.cpp +0 -189
- package/native-src/src/rats_export.h +0 -17
- package/native-src/src/receive_buffer.cpp +0 -82
- package/native-src/src/receive_buffer.h +0 -127
- package/native-src/src/socket.h +0 -228
- package/native-src/src/threadmanager.cpp +0 -105
- package/native-src/src/threadmanager.h +0 -53
- package/native-src/src/tracker.cpp +0 -1264
- package/native-src/src/tracker.h +0 -319
- package/native-src/src/turn.cpp +0 -762
- package/native-src/src/turn.h +0 -460
- package/native-src/src/wakeup_pipe.h +0 -60
- /package/native-src/src/{os.h → librats/util/os.h} +0 -0
|
@@ -84,7 +84,8 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
|
|
84
84
|
endif()
|
|
85
85
|
|
|
86
86
|
# Options
|
|
87
|
-
option(
|
|
87
|
+
option(RATS_BUILD_CLIENT "Build the rats-client reference application" ON)
|
|
88
|
+
option(RATS_BUILD_EXAMPLES "Build the examples/ programs" OFF)
|
|
88
89
|
option(RATS_BUILD_TESTS "Build unit tests" ON)
|
|
89
90
|
option(RATS_ENABLE_ASAN "Enable AddressSanitizer" OFF)
|
|
90
91
|
option(RATS_ENABLE_TSAN "Enable ThreadSanitizer" OFF)
|
|
@@ -112,8 +113,25 @@ endif()
|
|
|
112
113
|
|
|
113
114
|
# Configure version.h from template
|
|
114
115
|
configure_file(
|
|
115
|
-
${PROJECT_SOURCE_DIR}/src/version.h.in
|
|
116
|
-
${PROJECT_BINARY_DIR}/src/version.h
|
|
116
|
+
${PROJECT_SOURCE_DIR}/src/librats/util/version.h.in
|
|
117
|
+
${PROJECT_BINARY_DIR}/src/librats/util/version.h
|
|
118
|
+
@ONLY
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
# Configure features.h from template — records how this build was configured, so
|
|
122
|
+
# the installed headers describe themselves instead of relying on the consumer's
|
|
123
|
+
# build system to repeat the flags. Must come after the RATS_SEARCH_FEATURES /
|
|
124
|
+
# RATS_STORAGE options and the shared/static resolution above.
|
|
125
|
+
#
|
|
126
|
+
# `#cmakedefine RATS_IMPORT_DLL` reads a variable of that name: a consumer of the
|
|
127
|
+
# shared build needs __declspec(dllimport) on the public classes, a consumer of
|
|
128
|
+
# the static build must NOT have it (it would look for __imp_ symbols that are not
|
|
129
|
+
# there). The library's own sources get RATS_EXPORT_DLL PRIVATE, which
|
|
130
|
+
# rats_export.h tests first, so dllexport still wins while compiling librats.
|
|
131
|
+
set(RATS_IMPORT_DLL ${RATS_SHARED_LIBRARY})
|
|
132
|
+
configure_file(
|
|
133
|
+
${PROJECT_SOURCE_DIR}/src/librats/util/features.h.in
|
|
134
|
+
${PROJECT_BINARY_DIR}/src/librats/util/features.h
|
|
117
135
|
@ONLY
|
|
118
136
|
)
|
|
119
137
|
|
|
@@ -126,161 +144,277 @@ if(WIN32)
|
|
|
126
144
|
)
|
|
127
145
|
endif()
|
|
128
146
|
|
|
129
|
-
# Define library sources
|
|
147
|
+
# Define library sources, grouped by subsystem (mirrors the src/librats/ layout)
|
|
130
148
|
set(LIBRARY_SOURCES
|
|
131
|
-
|
|
132
|
-
src/socket.h
|
|
133
|
-
src/
|
|
134
|
-
src/
|
|
135
|
-
src/
|
|
136
|
-
src/
|
|
137
|
-
src/
|
|
138
|
-
src/
|
|
139
|
-
src/
|
|
140
|
-
src/
|
|
141
|
-
src/
|
|
142
|
-
src/
|
|
143
|
-
src/librats.
|
|
144
|
-
src/
|
|
145
|
-
src/
|
|
146
|
-
src/
|
|
147
|
-
src/
|
|
148
|
-
src/
|
|
149
|
-
src/
|
|
150
|
-
src/
|
|
151
|
-
src/
|
|
152
|
-
src/
|
|
153
|
-
src/librats.h
|
|
154
|
-
src/
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
src/
|
|
158
|
-
src/
|
|
159
|
-
src/
|
|
160
|
-
src/
|
|
161
|
-
src/
|
|
162
|
-
src/
|
|
163
|
-
src/
|
|
164
|
-
src/
|
|
165
|
-
src/
|
|
166
|
-
src/
|
|
167
|
-
src/
|
|
168
|
-
src/
|
|
169
|
-
src/
|
|
170
|
-
src/
|
|
171
|
-
src/
|
|
172
|
-
${PROJECT_BINARY_DIR}/src/
|
|
173
|
-
|
|
174
|
-
#
|
|
175
|
-
src/
|
|
176
|
-
src/
|
|
177
|
-
src/
|
|
178
|
-
src/
|
|
179
|
-
|
|
180
|
-
#
|
|
181
|
-
|
|
182
|
-
src/
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
src/
|
|
186
|
-
src/
|
|
187
|
-
src/
|
|
188
|
-
src/
|
|
189
|
-
src/
|
|
190
|
-
src/
|
|
191
|
-
src/
|
|
192
|
-
src/
|
|
193
|
-
src/
|
|
194
|
-
src/
|
|
195
|
-
src/
|
|
196
|
-
src/
|
|
197
|
-
src/
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
src/
|
|
201
|
-
src/
|
|
202
|
-
src/
|
|
203
|
-
src/
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
src/
|
|
207
|
-
src/
|
|
208
|
-
|
|
209
|
-
#
|
|
210
|
-
src/
|
|
211
|
-
src/
|
|
212
|
-
src/
|
|
213
|
-
src/
|
|
214
|
-
src/
|
|
215
|
-
src/
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
src/
|
|
220
|
-
src/
|
|
221
|
-
src/
|
|
222
|
-
src/
|
|
223
|
-
src/
|
|
224
|
-
src/
|
|
149
|
+
# core/ — sockets, async I/O buffers, platform I/O multiplexing, reactor primitives
|
|
150
|
+
src/librats/core/socket.h
|
|
151
|
+
src/librats/core/socket.cpp
|
|
152
|
+
src/librats/core/receive_buffer.h
|
|
153
|
+
src/librats/core/receive_buffer.cpp
|
|
154
|
+
src/librats/core/chained_send_buffer.h
|
|
155
|
+
src/librats/core/chained_send_buffer.cpp
|
|
156
|
+
src/librats/core/io_poller.h
|
|
157
|
+
src/librats/core/io_poller.cpp
|
|
158
|
+
src/librats/core/bytes.h
|
|
159
|
+
src/librats/core/address.h
|
|
160
|
+
src/librats/core/address.cpp
|
|
161
|
+
src/librats/core/ip_address.h
|
|
162
|
+
src/librats/core/ip_address.cpp
|
|
163
|
+
src/librats/core/host_endpoint.h
|
|
164
|
+
src/librats/core/endpoint_parse.h
|
|
165
|
+
src/librats/core/endpoint_parse.cpp
|
|
166
|
+
src/librats/core/types.h
|
|
167
|
+
src/librats/core/types.cpp
|
|
168
|
+
src/librats/core/mpsc_queue.h
|
|
169
|
+
src/librats/core/timer_queue.h
|
|
170
|
+
src/librats/core/notifier.h
|
|
171
|
+
src/librats/core/event_bus.h
|
|
172
|
+
src/librats/core/service_registry.h
|
|
173
|
+
|
|
174
|
+
# util/ — networking helpers, OS/filesystem, logging, version
|
|
175
|
+
src/librats/util/network_utils.h
|
|
176
|
+
src/librats/util/network_utils.cpp
|
|
177
|
+
src/librats/util/network_monitor.h
|
|
178
|
+
src/librats/util/network_monitor.cpp
|
|
179
|
+
src/librats/util/os.h
|
|
180
|
+
src/librats/util/os.cpp
|
|
181
|
+
src/librats/util/fs.h
|
|
182
|
+
src/librats/util/fs.cpp
|
|
183
|
+
src/librats/util/logger.h
|
|
184
|
+
src/librats/util/logger.cpp
|
|
185
|
+
src/librats/util/json.h
|
|
186
|
+
src/librats/util/json.cpp
|
|
187
|
+
src/librats/util/version.cpp
|
|
188
|
+
src/librats/util/rats_export.h
|
|
189
|
+
${PROJECT_BINARY_DIR}/src/librats/util/version.h
|
|
190
|
+
${PROJECT_BINARY_DIR}/src/librats/util/features.h
|
|
191
|
+
|
|
192
|
+
# wire/ — length-prefixed frame format + type-routed dispatch
|
|
193
|
+
src/librats/wire/frame.h
|
|
194
|
+
src/librats/wire/frame.cpp
|
|
195
|
+
src/librats/wire/message_router.h
|
|
196
|
+
src/librats/wire/message_router.cpp
|
|
197
|
+
|
|
198
|
+
# transport/ — shared-nothing reactor, per-connection state machine,
|
|
199
|
+
# interchangeable TCP / reliable-UDP links
|
|
200
|
+
src/librats/transport/link.h
|
|
201
|
+
src/librats/transport/tcp_link.h
|
|
202
|
+
src/librats/transport/tcp_link.cpp
|
|
203
|
+
src/librats/transport/udp_packet.h
|
|
204
|
+
src/librats/transport/udp_packet.cpp
|
|
205
|
+
src/librats/transport/udp_stream.h
|
|
206
|
+
src/librats/transport/udp_stream.cpp
|
|
207
|
+
src/librats/transport/udp_mux.h
|
|
208
|
+
src/librats/transport/udp_mux.cpp
|
|
209
|
+
src/librats/transport/relay_link.h
|
|
210
|
+
src/librats/transport/relay_link.cpp
|
|
211
|
+
src/librats/transport/connection.h
|
|
212
|
+
src/librats/transport/connection.cpp
|
|
213
|
+
src/librats/transport/reactor.h
|
|
214
|
+
src/librats/transport/reactor.cpp
|
|
215
|
+
src/librats/transport/reactor_pool.h
|
|
216
|
+
|
|
217
|
+
# peer/ — self-certifying peer ids, routing/connection tables
|
|
218
|
+
src/librats/peer/peer_id.h
|
|
219
|
+
src/librats/peer/peer_id.cpp
|
|
220
|
+
src/librats/peer/peer_info.h
|
|
221
|
+
src/librats/peer/peer.h
|
|
222
|
+
src/librats/peer/peer_table.h
|
|
223
|
+
src/librats/peer/peer_table.cpp
|
|
224
|
+
src/librats/peer/peer_book.h
|
|
225
|
+
src/librats/peer/peer_book.cpp
|
|
226
|
+
|
|
227
|
+
# security/ — Noise XX / plaintext over a self-certifying identity
|
|
228
|
+
src/librats/security/session.h
|
|
229
|
+
src/librats/security/identity.h
|
|
230
|
+
src/librats/security/handshaker.h
|
|
231
|
+
src/librats/security/noise_security.h
|
|
232
|
+
src/librats/security/noise_security.cpp
|
|
233
|
+
src/librats/security/plaintext_security.h
|
|
234
|
+
|
|
235
|
+
# node/ — node facade, peer-network contract, identify handshake
|
|
236
|
+
src/librats/node/config.h
|
|
237
|
+
src/librats/node/host_events.h
|
|
238
|
+
src/librats/node/node_context.h
|
|
239
|
+
src/librats/node/peer_network.h
|
|
240
|
+
src/librats/node/node.h
|
|
241
|
+
src/librats/node/node.cpp
|
|
242
|
+
src/librats/node/identify.h
|
|
243
|
+
src/librats/node/identify.cpp
|
|
244
|
+
src/librats/node/dialer.h
|
|
245
|
+
src/librats/node/dialer.cpp
|
|
246
|
+
src/librats/node/dial_service.h
|
|
247
|
+
src/librats/node/circuit_service.h
|
|
248
|
+
src/librats/node/nat_status.h
|
|
249
|
+
src/librats/node/nat_status.cpp
|
|
250
|
+
|
|
251
|
+
# subsystems/ — opt-in plugins attached to a Node
|
|
252
|
+
src/librats/subsystems/ping_service.h
|
|
253
|
+
src/librats/subsystems/ping_service.cpp
|
|
254
|
+
src/librats/subsystems/pubsub.h
|
|
255
|
+
src/librats/subsystems/pubsub.cpp
|
|
256
|
+
src/librats/subsystems/message_json.h
|
|
257
|
+
src/librats/subsystems/message_json.cpp
|
|
258
|
+
src/librats/subsystems/file_transfer.h
|
|
259
|
+
src/librats/subsystems/file_transfer.cpp
|
|
260
|
+
src/librats/subsystems/dht_service.h
|
|
261
|
+
src/librats/subsystems/dht_discovery.h
|
|
262
|
+
src/librats/subsystems/dht_discovery.cpp
|
|
263
|
+
src/librats/subsystems/mdns_discovery.h
|
|
264
|
+
src/librats/subsystems/mdns_discovery.cpp
|
|
265
|
+
src/librats/subsystems/reconnection.h
|
|
266
|
+
src/librats/subsystems/reconnection.cpp
|
|
267
|
+
src/librats/subsystems/peer_exchange.h
|
|
268
|
+
src/librats/subsystems/peer_exchange.cpp
|
|
269
|
+
src/librats/subsystems/port_mapping_service.h
|
|
270
|
+
src/librats/subsystems/port_mapping_service.cpp
|
|
271
|
+
src/librats/subsystems/hole_punch.h
|
|
272
|
+
src/librats/subsystems/hole_punch.cpp
|
|
273
|
+
src/librats/subsystems/hole_punch_service.h
|
|
274
|
+
src/librats/subsystems/relay.h
|
|
275
|
+
src/librats/subsystems/relay.cpp
|
|
276
|
+
src/librats/subsystems/relay_service.h
|
|
277
|
+
|
|
278
|
+
# dht/ — Kademlia DHT + KRPC (bencode is shared with bittorrent, always built)
|
|
279
|
+
src/librats/dht/dht.h
|
|
280
|
+
src/librats/dht/dht.cpp
|
|
281
|
+
src/librats/dht/krpc.h
|
|
282
|
+
src/librats/dht/krpc.cpp
|
|
283
|
+
# dht/ modular layer (rewrite in progress) — leaf types
|
|
284
|
+
src/librats/dht/id.h
|
|
285
|
+
src/librats/dht/log.h
|
|
286
|
+
src/librats/dht/node_entry.h
|
|
287
|
+
src/librats/dht/bep42.h
|
|
288
|
+
src/librats/dht/bep42.cpp
|
|
289
|
+
src/librats/dht/routing_table.h
|
|
290
|
+
src/librats/dht/routing_table.cpp
|
|
291
|
+
src/librats/dht/transport.h
|
|
292
|
+
src/librats/dht/observer.h
|
|
293
|
+
src/librats/dht/rpc_manager.h
|
|
294
|
+
src/librats/dht/rpc_manager.cpp
|
|
295
|
+
src/librats/dht/traversal.h
|
|
296
|
+
src/librats/dht/traversal.cpp
|
|
297
|
+
src/librats/dht/find_peers.h
|
|
298
|
+
src/librats/dht/find_peers.cpp
|
|
299
|
+
src/librats/dht/announce.h
|
|
300
|
+
src/librats/dht/announce.cpp
|
|
301
|
+
src/librats/dht/storage.h
|
|
302
|
+
src/librats/dht/storage.cpp
|
|
303
|
+
src/librats/dht/dos_blocker.h
|
|
304
|
+
src/librats/dht/dos_blocker.cpp
|
|
305
|
+
src/librats/dht/node.h
|
|
306
|
+
src/librats/dht/node.cpp
|
|
307
|
+
src/librats/dht/udp_transport.h
|
|
308
|
+
src/librats/dht/udp_transport.cpp
|
|
309
|
+
src/librats/dht/dht_runner.h
|
|
310
|
+
src/librats/dht/dht_runner.cpp
|
|
311
|
+
src/librats/dht/persistence.h
|
|
312
|
+
src/librats/dht/persistence.cpp
|
|
313
|
+
src/librats/bittorrent/bencode.h
|
|
314
|
+
src/librats/bittorrent/bencode.cpp
|
|
315
|
+
|
|
316
|
+
# mdns/ — local-network service discovery
|
|
317
|
+
src/librats/mdns/mdns.h
|
|
318
|
+
src/librats/mdns/log.h
|
|
319
|
+
src/librats/mdns/mdns.cpp
|
|
320
|
+
|
|
321
|
+
# crypto/ — hashes, ciphers, KDFs
|
|
322
|
+
src/librats/crypto/sha1.h
|
|
323
|
+
src/librats/crypto/sha1.cpp
|
|
324
|
+
src/librats/crypto/crc32.h
|
|
325
|
+
src/librats/crypto/crc32.cpp
|
|
326
|
+
src/librats/crypto/curve25519.c
|
|
327
|
+
src/librats/crypto/curve25519.h
|
|
328
|
+
src/librats/crypto/chacha.c
|
|
329
|
+
src/librats/crypto/chacha.h
|
|
330
|
+
src/librats/crypto/poly1305.c
|
|
331
|
+
src/librats/crypto/poly1305.h
|
|
332
|
+
src/librats/crypto/chachapoly.c
|
|
333
|
+
src/librats/crypto/chachapoly.h
|
|
334
|
+
src/librats/crypto/sha256.c
|
|
335
|
+
src/librats/crypto/sha256.h
|
|
336
|
+
src/librats/crypto/sha512.c
|
|
337
|
+
src/librats/crypto/sha512.h
|
|
338
|
+
src/librats/crypto/hkdf.c
|
|
339
|
+
src/librats/crypto/hkdf.h
|
|
340
|
+
src/librats/crypto/blake2s.c
|
|
341
|
+
src/librats/crypto/blake2s.h
|
|
342
|
+
src/librats/crypto/blake2b.c
|
|
343
|
+
src/librats/crypto/blake2b.h
|
|
344
|
+
src/librats/crypto/blake2_endian.h
|
|
345
|
+
|
|
346
|
+
# crypto/ — Noise Protocol framework (Noise_XX transport encryption)
|
|
347
|
+
src/librats/crypto/noise.cpp
|
|
348
|
+
src/librats/crypto/noise.h
|
|
349
|
+
|
|
350
|
+
# nat/ — STUN public-IP discovery + UPnP IGD / NAT-PMP port forwarding
|
|
351
|
+
src/librats/nat/stun.h
|
|
352
|
+
src/librats/nat/stun.cpp
|
|
353
|
+
src/librats/nat/port_mapping.h
|
|
354
|
+
src/librats/nat/upnp.h
|
|
355
|
+
src/librats/nat/upnp.cpp
|
|
356
|
+
src/librats/nat/natpmp.h
|
|
357
|
+
src/librats/nat/natpmp.cpp
|
|
225
358
|
)
|
|
226
359
|
|
|
227
360
|
# Add BitTorrent sources if RATS_SEARCH_FEATURES is enabled
|
|
228
361
|
if(RATS_SEARCH_FEATURES)
|
|
229
362
|
list(APPEND LIBRARY_SOURCES
|
|
230
|
-
src/
|
|
231
|
-
src/bittorrent.cpp
|
|
232
|
-
src/bittorrent.h
|
|
233
|
-
src/
|
|
234
|
-
src/
|
|
235
|
-
src/
|
|
236
|
-
src/
|
|
237
|
-
src/
|
|
238
|
-
src/
|
|
239
|
-
src/
|
|
240
|
-
src/
|
|
241
|
-
src/
|
|
242
|
-
src/
|
|
243
|
-
src/
|
|
244
|
-
src/
|
|
245
|
-
src/
|
|
246
|
-
src/
|
|
247
|
-
src/
|
|
248
|
-
src/
|
|
249
|
-
src/
|
|
250
|
-
src/
|
|
251
|
-
src/
|
|
252
|
-
src/
|
|
253
|
-
src/
|
|
254
|
-
src/
|
|
255
|
-
src/
|
|
256
|
-
src/
|
|
257
|
-
src/
|
|
258
|
-
src/
|
|
259
|
-
src/
|
|
260
|
-
src/
|
|
261
|
-
src/tracker.h
|
|
262
|
-
src/
|
|
263
|
-
src/
|
|
264
|
-
src/
|
|
265
|
-
src/
|
|
363
|
+
src/librats/bittorrent/types.h
|
|
364
|
+
src/librats/bittorrent/types.cpp
|
|
365
|
+
src/librats/bittorrent/byte_io.h
|
|
366
|
+
src/librats/bittorrent/bitfield.h
|
|
367
|
+
src/librats/bittorrent/bitfield.cpp
|
|
368
|
+
src/librats/bittorrent/file_storage.h
|
|
369
|
+
src/librats/bittorrent/file_storage.cpp
|
|
370
|
+
src/librats/bittorrent/magnet_uri.h
|
|
371
|
+
src/librats/bittorrent/magnet_uri.cpp
|
|
372
|
+
src/librats/bittorrent/torrent_info.h
|
|
373
|
+
src/librats/bittorrent/torrent_info.cpp
|
|
374
|
+
src/librats/bittorrent/store_buffer.h
|
|
375
|
+
src/librats/bittorrent/store_buffer.cpp
|
|
376
|
+
src/librats/bittorrent/disk_io.h
|
|
377
|
+
src/librats/bittorrent/disk_io.cpp
|
|
378
|
+
src/librats/bittorrent/piece_picker.h
|
|
379
|
+
src/librats/bittorrent/piece_picker.cpp
|
|
380
|
+
src/librats/bittorrent/reactor.h
|
|
381
|
+
src/librats/bittorrent/reactor.cpp
|
|
382
|
+
src/librats/bittorrent/peer_connection.h
|
|
383
|
+
src/librats/bittorrent/peer_connection.cpp
|
|
384
|
+
src/librats/bittorrent/choker.h
|
|
385
|
+
src/librats/bittorrent/choker.cpp
|
|
386
|
+
src/librats/bittorrent/torrent.h
|
|
387
|
+
src/librats/bittorrent/torrent.cpp
|
|
388
|
+
src/librats/bittorrent/client.h
|
|
389
|
+
src/librats/bittorrent/client.cpp
|
|
390
|
+
src/librats/bittorrent/extensions.h
|
|
391
|
+
src/librats/bittorrent/extensions.cpp
|
|
392
|
+
src/librats/bittorrent/peer_list.h
|
|
393
|
+
src/librats/bittorrent/peer_list.cpp
|
|
394
|
+
src/librats/bittorrent/tracker.h
|
|
395
|
+
src/librats/bittorrent/tracker.cpp
|
|
396
|
+
src/librats/bittorrent/resume_data.h
|
|
397
|
+
src/librats/bittorrent/resume_data.cpp
|
|
398
|
+
src/librats/bittorrent/torrent_creator.h
|
|
399
|
+
src/librats/bittorrent/torrent_creator.cpp
|
|
400
|
+
src/librats/subsystems/bittorrent.h
|
|
401
|
+
src/librats/subsystems/bittorrent.cpp
|
|
266
402
|
)
|
|
267
403
|
endif()
|
|
268
404
|
|
|
269
405
|
# Add Storage sources if RATS_STORAGE is enabled
|
|
406
|
+
# StorageManager is a Node subsystem (reaches the mesh via PeerNetwork).
|
|
270
407
|
if(RATS_STORAGE)
|
|
271
408
|
list(APPEND LIBRARY_SOURCES
|
|
272
|
-
src/
|
|
273
|
-
src/
|
|
274
|
-
src/storage.cpp
|
|
275
|
-
src/storage.h
|
|
276
|
-
src/librats_storage.cpp
|
|
409
|
+
src/librats/storage/storage.cpp
|
|
410
|
+
src/librats/storage/storage.h
|
|
277
411
|
)
|
|
278
412
|
endif()
|
|
279
413
|
|
|
280
414
|
if(RATS_BINDINGS)
|
|
281
|
-
list(APPEND LIBRARY_SOURCES
|
|
282
|
-
src/
|
|
283
|
-
src/
|
|
415
|
+
list(APPEND LIBRARY_SOURCES
|
|
416
|
+
src/librats/bindings/rats.h
|
|
417
|
+
src/librats/bindings/rats.cpp
|
|
284
418
|
)
|
|
285
419
|
endif()
|
|
286
420
|
|
|
@@ -291,7 +425,18 @@ if(RATS_SHARED_LIBRARY)
|
|
|
291
425
|
VERSION ${VERSION_STRING}
|
|
292
426
|
SOVERSION ${VERSION_MAJOR}
|
|
293
427
|
)
|
|
294
|
-
|
|
428
|
+
# PRIVATE: dllexport while compiling the library itself.
|
|
429
|
+
# INTERFACE: dllimport for anyone linking the shared library. This rides the
|
|
430
|
+
# exported target (install(EXPORT) writes it into ratsTargets.cmake), which
|
|
431
|
+
# covers find_package and vcpkg. It is belt-and-braces: the generated
|
|
432
|
+
# librats/util/features.h defines RATS_IMPORT_DLL too, which is what reaches
|
|
433
|
+
# consumers that never read the CMake target (vcpkg's MSBuild integration, a
|
|
434
|
+
# hand-rolled -I build). Both derive from RATS_SHARED_LIBRARY and the header
|
|
435
|
+
# guards with #ifndef, so they cannot disagree or redefine.
|
|
436
|
+
target_compile_definitions(rats
|
|
437
|
+
PRIVATE RATS_EXPORT_DLL
|
|
438
|
+
INTERFACE RATS_IMPORT_DLL
|
|
439
|
+
)
|
|
295
440
|
else()
|
|
296
441
|
add_library(rats STATIC ${LIBRARY_SOURCES})
|
|
297
442
|
endif()
|
|
@@ -306,22 +451,45 @@ include(GNUInstallDirs)
|
|
|
306
451
|
|
|
307
452
|
# Include directories. INSTALL_INTERFACE entries are only consumed via the
|
|
308
453
|
# exported target, so they are safe to declare even when RATS_INSTALL is OFF.
|
|
454
|
+
#
|
|
455
|
+
# The include root is the PARENT of the librats/ directory — src/ in the build
|
|
456
|
+
# tree, <prefix>/include once installed — and every header spells its own path in
|
|
457
|
+
# full, "librats/<subdir>/<name>.h", even for a sibling in the same directory.
|
|
458
|
+
# That is what makes an installed header compile from -I<prefix>/include alone
|
|
459
|
+
# and keeps generic names (core/, node/, util/, …) off the consumer's include
|
|
460
|
+
# path. Do not add src/librats or include/librats as a second root: a header that
|
|
461
|
+
# resolved only through it would build in-tree and break for installed consumers.
|
|
309
462
|
target_include_directories(rats
|
|
310
463
|
PUBLIC
|
|
311
464
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
|
|
312
|
-
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/crypto>
|
|
313
465
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/src>
|
|
314
|
-
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}
|
|
315
|
-
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/librats/crypto>
|
|
466
|
+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
316
467
|
)
|
|
317
468
|
|
|
318
469
|
# Find and link threading support
|
|
319
470
|
find_package(Threads REQUIRED)
|
|
320
471
|
target_link_libraries(rats Threads::Threads)
|
|
321
472
|
|
|
473
|
+
# 64-bit atomics: on 32-bit targets (e.g. ppc, armv7, x86, mips) an 8-byte
|
|
474
|
+
# std::atomic is not lock-free in hardware, so the compiler lowers it to
|
|
475
|
+
# __atomic_*_8 libcalls that live in libatomic. Detect that case and link it,
|
|
476
|
+
# otherwise the link fails with "undefined ___atomic_fetch_add_8" etc.
|
|
477
|
+
include(CheckCXXSourceCompiles)
|
|
478
|
+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
479
|
+
check_cxx_source_compiles("
|
|
480
|
+
#include <atomic>
|
|
481
|
+
#include <cstdint>
|
|
482
|
+
std::atomic<uint64_t> x;
|
|
483
|
+
int main() { x.fetch_add(1); x.store(2); return (int)x.load(); }
|
|
484
|
+
" HAVE_BUILTIN_ATOMIC64)
|
|
485
|
+
unset(CMAKE_REQUIRED_FLAGS)
|
|
486
|
+
if(NOT HAVE_BUILTIN_ATOMIC64)
|
|
487
|
+
target_link_libraries(rats atomic)
|
|
488
|
+
endif()
|
|
489
|
+
|
|
322
490
|
# Link networking libraries
|
|
323
491
|
if(WIN32)
|
|
324
|
-
target_link_libraries(rats ws2_32 iphlpapi bcrypt)
|
|
492
|
+
target_link_libraries(rats ws2_32 iphlpapi bcrypt advapi32)
|
|
325
493
|
endif()
|
|
326
494
|
|
|
327
495
|
if(ANDROID)
|
|
@@ -354,8 +522,8 @@ if(RATS_STORAGE)
|
|
|
354
522
|
target_compile_definitions(rats PUBLIC RATS_STORAGE)
|
|
355
523
|
endif(RATS_STORAGE)
|
|
356
524
|
|
|
357
|
-
# Create the main executable
|
|
358
|
-
if(
|
|
525
|
+
# Create the main executable (the rats-client reference application)
|
|
526
|
+
if(RATS_BUILD_CLIENT)
|
|
359
527
|
add_executable(rats-client src/main.cpp)
|
|
360
528
|
target_link_libraries(rats-client rats)
|
|
361
529
|
|
|
@@ -444,30 +612,36 @@ if(RATS_BUILD_TESTS)
|
|
|
444
612
|
# Create test source list
|
|
445
613
|
set(TEST_SOURCES
|
|
446
614
|
tests/test_socket.cpp
|
|
615
|
+
tests/test_ip_address.cpp
|
|
447
616
|
tests/test_bencode.cpp
|
|
448
617
|
tests/test_sha1.cpp
|
|
449
618
|
tests/test_network_utils.cpp
|
|
450
619
|
tests/test_dht.cpp
|
|
451
|
-
tests/
|
|
620
|
+
tests/test_dht_id.cpp
|
|
621
|
+
tests/test_dht_bootstrap.cpp
|
|
622
|
+
tests/test_dht_bep42.cpp
|
|
623
|
+
tests/test_dht_node_entry.cpp
|
|
624
|
+
tests/test_dht_routing_table.cpp
|
|
625
|
+
tests/test_dht_ip_diversity.cpp
|
|
626
|
+
tests/test_dht_rpc_manager.cpp
|
|
627
|
+
tests/test_dht_traversal.cpp
|
|
628
|
+
tests/test_dht_storage.cpp
|
|
629
|
+
tests/test_dht_node.cpp
|
|
630
|
+
tests/test_dht_persistence_v2.cpp
|
|
631
|
+
tests/test_dht_udp.cpp
|
|
632
|
+
tests/test_dht_shutdown.cpp
|
|
452
633
|
tests/test_os.cpp
|
|
453
634
|
tests/test_fs.cpp
|
|
454
|
-
tests/
|
|
635
|
+
tests/test_json.cpp
|
|
455
636
|
tests/test_main.cpp
|
|
456
|
-
tests/test_message_exchange.cpp
|
|
457
|
-
tests/test_gossipsub.cpp
|
|
458
|
-
tests/test_logging_api_gtest.cpp
|
|
459
|
-
tests/test_file_transfer.cpp
|
|
460
|
-
tests/test_reconnection.cpp
|
|
461
637
|
# Noise Protocol Crypto tests
|
|
462
638
|
tests/test_crypto_curve25519.cpp
|
|
463
639
|
tests/test_crypto_chacha_poly.cpp
|
|
464
640
|
tests/test_crypto_sha2.cpp
|
|
465
641
|
tests/test_crypto_blake2.cpp
|
|
466
642
|
tests/test_noise.cpp
|
|
467
|
-
# NAT traversal tests (STUN
|
|
643
|
+
# NAT traversal tests (STUN)
|
|
468
644
|
tests/test_stun.cpp
|
|
469
|
-
tests/test_turn.cpp
|
|
470
|
-
tests/test_ice.cpp
|
|
471
645
|
# Automatic port forwarding tests (UPnP/NAT-PMP)
|
|
472
646
|
tests/test_portmap.cpp
|
|
473
647
|
# Network change detection tests
|
|
@@ -477,26 +651,66 @@ if(RATS_BUILD_TESTS)
|
|
|
477
651
|
# Buffer utilities for file transfer and bittorrent
|
|
478
652
|
tests/test_receive_buffer.cpp
|
|
479
653
|
tests/test_chained_send_buffer.cpp
|
|
654
|
+
# Wire framing, reactor transport, node + subsystems
|
|
655
|
+
tests/test_frame.cpp
|
|
656
|
+
tests/test_reactor.cpp
|
|
657
|
+
tests/test_transport_udp.cpp
|
|
658
|
+
tests/test_relay_link.cpp
|
|
659
|
+
tests/test_dialer.cpp
|
|
660
|
+
tests/test_peer_table.cpp
|
|
661
|
+
tests/test_handshake.cpp
|
|
662
|
+
tests/test_node.cpp
|
|
663
|
+
tests/test_identify.cpp
|
|
664
|
+
tests/test_persistence.cpp
|
|
665
|
+
tests/test_event_bus.cpp
|
|
666
|
+
tests/test_subsystem.cpp
|
|
667
|
+
tests/test_pubsub.cpp
|
|
668
|
+
tests/test_peer_exchange.cpp
|
|
669
|
+
tests/test_message_json.cpp
|
|
670
|
+
tests/test_filexfer.cpp
|
|
671
|
+
tests/test_dht_discovery.cpp
|
|
672
|
+
tests/test_reconnection.cpp
|
|
673
|
+
tests/test_nat_status.cpp
|
|
674
|
+
tests/test_hole_punch.cpp
|
|
675
|
+
tests/test_relay.cpp
|
|
676
|
+
tests/test_logging.cpp
|
|
480
677
|
)
|
|
481
678
|
|
|
482
679
|
# Add BitTorrent tests if RATS_SEARCH_FEATURES is enabled
|
|
483
680
|
if(RATS_SEARCH_FEATURES)
|
|
484
|
-
list(APPEND TEST_SOURCES
|
|
485
|
-
|
|
486
|
-
tests/
|
|
487
|
-
tests/
|
|
681
|
+
list(APPEND TEST_SOURCES
|
|
682
|
+
# Phase 0 — primitives
|
|
683
|
+
tests/test_bt_types.cpp
|
|
684
|
+
tests/test_bt_byte_io.cpp
|
|
488
685
|
tests/test_bt_bitfield.cpp
|
|
686
|
+
# Phase 1 — metadata
|
|
489
687
|
tests/test_bt_file_storage.cpp
|
|
688
|
+
tests/test_bt_magnet.cpp
|
|
490
689
|
tests/test_bt_torrent_info.cpp
|
|
690
|
+
# Phase 2 — disk I/O
|
|
691
|
+
tests/test_bt_store_buffer.cpp
|
|
692
|
+
tests/test_bt_disk_io.cpp
|
|
693
|
+
# Phase 3 — piece picker
|
|
491
694
|
tests/test_bt_piece_picker.cpp
|
|
492
|
-
|
|
493
|
-
tests/
|
|
695
|
+
# Phase 4 — reactor + peer wire protocol
|
|
696
|
+
tests/test_bt_reactor.cpp
|
|
494
697
|
tests/test_bt_peer_connection.cpp
|
|
495
|
-
|
|
496
|
-
tests/
|
|
497
|
-
tests/
|
|
498
|
-
tests/
|
|
698
|
+
# Phase 5 — torrent + client + choker
|
|
699
|
+
tests/test_bt_choker.cpp
|
|
700
|
+
tests/test_bt_download.cpp
|
|
701
|
+
tests/test_bt_stall_metadata.cpp
|
|
702
|
+
# Phase 6 — extension protocol + metadata exchange + discovery
|
|
703
|
+
tests/test_bt_extensions.cpp
|
|
704
|
+
tests/test_bt_magnet_fetch.cpp
|
|
705
|
+
tests/test_bt_peer_list.cpp
|
|
706
|
+
tests/test_bt_pex.cpp
|
|
707
|
+
tests/test_bt_tracker.cpp
|
|
708
|
+
# Phase 7 — fast resume + torrent creation
|
|
499
709
|
tests/test_bt_resume_data.cpp
|
|
710
|
+
tests/test_bt_pause_resume.cpp
|
|
711
|
+
tests/test_bt_torrent_creator.cpp
|
|
712
|
+
# Phase 8 — node subsystem integration
|
|
713
|
+
tests/test_bt_subsystem.cpp
|
|
500
714
|
)
|
|
501
715
|
endif()
|
|
502
716
|
|
|
@@ -509,14 +723,15 @@ if(RATS_BUILD_TESTS)
|
|
|
509
723
|
endif()
|
|
510
724
|
|
|
511
725
|
if(RATS_BINDINGS)
|
|
512
|
-
list(APPEND TEST_SOURCES
|
|
513
|
-
tests/
|
|
726
|
+
list(APPEND TEST_SOURCES
|
|
727
|
+
tests/test_node_capi.cpp
|
|
514
728
|
)
|
|
515
729
|
endif()
|
|
516
730
|
|
|
517
731
|
# Add mDNS tests only on non-macOS platforms
|
|
518
732
|
if(NOT APPLE)
|
|
519
733
|
list(APPEND TEST_SOURCES tests/test_mdns.cpp)
|
|
734
|
+
list(APPEND TEST_SOURCES tests/test_mdns_discovery.cpp)
|
|
520
735
|
endif()
|
|
521
736
|
|
|
522
737
|
# Create test executable
|
|
@@ -546,7 +761,7 @@ if(RATS_BUILD_TESTS)
|
|
|
546
761
|
)
|
|
547
762
|
endif()
|
|
548
763
|
|
|
549
|
-
# Examples (
|
|
764
|
+
# Examples (opt-in; the BitTorrent example additionally requires RATS_SEARCH_FEATURES)
|
|
550
765
|
if(RATS_BUILD_EXAMPLES)
|
|
551
766
|
add_subdirectory(examples)
|
|
552
767
|
endif()
|
|
@@ -564,20 +779,30 @@ if(RATS_INSTALL)
|
|
|
564
779
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
565
780
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
566
781
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
567
|
-
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
782
|
+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
568
783
|
)
|
|
569
784
|
|
|
570
|
-
# Headers form a tightly coupled graph (
|
|
571
|
-
# bt_*/storage
|
|
572
|
-
#
|
|
573
|
-
|
|
785
|
+
# Headers form a tightly coupled graph (node.h pulls in transport/core, and
|
|
786
|
+
# with the search/storage features dht/krpc/bencode/bt_*/storage too), so
|
|
787
|
+
# install the whole header tree. The installed layout mirrors src/librats/
|
|
788
|
+
# exactly, which is what keeps "librats/<subdir>/<name>.h" resolving the same
|
|
789
|
+
# in-tree and installed. .cpp / .c / .in files are excluded.
|
|
790
|
+
install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/librats/
|
|
574
791
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/librats
|
|
575
792
|
FILES_MATCHING
|
|
576
793
|
PATTERN "*.h"
|
|
577
794
|
PATTERN "*.hpp"
|
|
578
795
|
)
|
|
579
|
-
|
|
580
|
-
|
|
796
|
+
# Generated headers mirror their in-tree location (src/librats/util/<name>.h):
|
|
797
|
+
# sources include them as "librats/util/<name>.h", so they must land under
|
|
798
|
+
# librats/util/. features.h is what makes the installed tree self-describing —
|
|
799
|
+
# without it a consumer that does not go through the exported CMake target
|
|
800
|
+
# (vcpkg's MSBuild integration, a hand-rolled -I build) reads the headers with
|
|
801
|
+
# RATS_SEARCH_FEATURES unset even when the library was built with it.
|
|
802
|
+
install(FILES
|
|
803
|
+
${PROJECT_BINARY_DIR}/src/librats/util/version.h
|
|
804
|
+
${PROJECT_BINARY_DIR}/src/librats/util/features.h
|
|
805
|
+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/librats/util
|
|
581
806
|
)
|
|
582
807
|
|
|
583
808
|
install(EXPORT ratsTargets
|