librats 0.3.1 → 0.5.1
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 +405 -405
- package/binding.gyp +96 -95
- package/lib/index.d.ts +522 -522
- package/lib/index.js +82 -82
- package/native-src/3rdparty/android/ifaddrs-android.c +600 -0
- package/native-src/3rdparty/android/ifaddrs-android.h +54 -0
- package/native-src/CMakeLists.txt +360 -0
- package/native-src/LICENSE +21 -0
- package/native-src/src/bencode.cpp +485 -0
- package/native-src/src/bencode.h +145 -0
- package/native-src/src/bittorrent.cpp +3682 -0
- package/native-src/src/bittorrent.h +731 -0
- package/native-src/src/dht.cpp +2342 -0
- package/native-src/src/dht.h +501 -0
- package/native-src/src/encrypted_socket.cpp +817 -0
- package/native-src/src/encrypted_socket.h +239 -0
- package/native-src/src/file_transfer.cpp +1808 -0
- package/native-src/src/file_transfer.h +567 -0
- package/native-src/src/fs.cpp +639 -0
- package/native-src/src/fs.h +108 -0
- package/native-src/src/gossipsub.cpp +1137 -0
- package/native-src/src/gossipsub.h +403 -0
- package/native-src/src/ice.cpp +1386 -0
- package/native-src/src/ice.h +328 -0
- package/native-src/src/json.hpp +25526 -0
- package/native-src/src/krpc.cpp +558 -0
- package/native-src/src/krpc.h +145 -0
- package/native-src/src/librats.cpp +2715 -0
- package/native-src/src/librats.h +1729 -0
- package/native-src/src/librats_bittorrent.cpp +167 -0
- package/native-src/src/librats_c.cpp +1317 -0
- package/native-src/src/librats_c.h +237 -0
- package/native-src/src/librats_encryption.cpp +123 -0
- package/native-src/src/librats_file_transfer.cpp +226 -0
- package/native-src/src/librats_gossipsub.cpp +293 -0
- package/native-src/src/librats_ice.cpp +515 -0
- package/native-src/src/librats_logging.cpp +158 -0
- package/native-src/src/librats_mdns.cpp +171 -0
- package/native-src/src/librats_nat.cpp +571 -0
- package/native-src/src/librats_persistence.cpp +815 -0
- package/native-src/src/logger.h +412 -0
- package/native-src/src/mdns.cpp +1178 -0
- package/native-src/src/mdns.h +253 -0
- package/native-src/src/network_utils.cpp +598 -0
- package/native-src/src/network_utils.h +162 -0
- package/native-src/src/noise.cpp +981 -0
- package/native-src/src/noise.h +227 -0
- package/native-src/src/os.cpp +371 -0
- package/native-src/src/os.h +40 -0
- package/native-src/src/rats_export.h +17 -0
- package/native-src/src/sha1.cpp +163 -0
- package/native-src/src/sha1.h +42 -0
- package/native-src/src/socket.cpp +1376 -0
- package/native-src/src/socket.h +309 -0
- package/native-src/src/stun.cpp +484 -0
- package/native-src/src/stun.h +349 -0
- package/native-src/src/threadmanager.cpp +105 -0
- package/native-src/src/threadmanager.h +53 -0
- package/native-src/src/tracker.cpp +1110 -0
- package/native-src/src/tracker.h +268 -0
- package/native-src/src/version.cpp +24 -0
- package/native-src/src/version.h.in +45 -0
- package/native-src/version.rc.in +31 -0
- package/package.json +62 -68
- package/scripts/build-librats.js +241 -194
- package/scripts/postinstall.js +52 -52
- package/scripts/prepare-package.js +187 -91
- package/scripts/verify-installation.js +119 -119
- package/src/librats_node.cpp +1174 -1174
package/lib/index.js
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LibRats Node.js Bindings
|
|
3
|
-
*
|
|
4
|
-
* High-performance peer-to-peer networking library with support for DHT, GossipSub,
|
|
5
|
-
* file transfer, NAT traversal, and more.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const path = require('path');
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
|
|
11
|
-
// Try to load the native addon from the build directory
|
|
12
|
-
let addon;
|
|
13
|
-
let addonPath;
|
|
14
|
-
|
|
15
|
-
// Possible locations for the built addon
|
|
16
|
-
const possiblePaths = [
|
|
17
|
-
// Standard node-gyp build location
|
|
18
|
-
path.join(__dirname, '..', 'build', 'Release', 'librats.node'),
|
|
19
|
-
path.join(__dirname, '..', 'build', 'Debug', 'librats.node'),
|
|
20
|
-
// Alternative build locations
|
|
21
|
-
path.join(__dirname, '..', 'build', 'librats.node'),
|
|
22
|
-
];
|
|
23
|
-
|
|
24
|
-
// Try each path
|
|
25
|
-
for (const tryPath of possiblePaths) {
|
|
26
|
-
try {
|
|
27
|
-
if (fs.existsSync(tryPath)) {
|
|
28
|
-
addon = require(tryPath);
|
|
29
|
-
addonPath = tryPath;
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
} catch (err) {
|
|
33
|
-
// Continue to next path
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!addon) {
|
|
38
|
-
throw new Error(
|
|
39
|
-
'Could not load librats native addon. ' +
|
|
40
|
-
'Make sure the package is installed correctly and the native library is built. ' +
|
|
41
|
-
'Try running: npm rebuild librats'
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Export all native bindings
|
|
46
|
-
module.exports = {
|
|
47
|
-
// Main class
|
|
48
|
-
RatsClient: addon.RatsClient,
|
|
49
|
-
|
|
50
|
-
// Version functions
|
|
51
|
-
getVersionString: addon.getVersionString,
|
|
52
|
-
getVersion: addon.getVersion,
|
|
53
|
-
getGitDescribe: addon.getGitDescribe,
|
|
54
|
-
getAbi: addon.getAbi,
|
|
55
|
-
|
|
56
|
-
// Constants
|
|
57
|
-
ConnectionStrategy: {
|
|
58
|
-
DIRECT_ONLY: 0,
|
|
59
|
-
STUN_ASSISTED: 1,
|
|
60
|
-
ICE_FULL: 2,
|
|
61
|
-
TURN_RELAY: 3,
|
|
62
|
-
AUTO_ADAPTIVE: 4
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
ErrorCodes: {
|
|
66
|
-
SUCCESS: 0,
|
|
67
|
-
INVALID_HANDLE: -1,
|
|
68
|
-
INVALID_PARAMETER: -2,
|
|
69
|
-
NOT_RUNNING: -3,
|
|
70
|
-
OPERATION_FAILED: -4,
|
|
71
|
-
PEER_NOT_FOUND: -5,
|
|
72
|
-
MEMORY_ALLOCATION: -6,
|
|
73
|
-
JSON_PARSE: -7
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// Log successful load for debugging
|
|
78
|
-
if (process.env.LIBRATS_DEBUG) {
|
|
79
|
-
console.log(`[librats] Loaded native addon from: ${addonPath}`);
|
|
80
|
-
console.log(`[librats] Version: ${addon.getVersionString()}`);
|
|
81
|
-
}
|
|
82
|
-
|
|
1
|
+
/**
|
|
2
|
+
* LibRats Node.js Bindings
|
|
3
|
+
*
|
|
4
|
+
* High-performance peer-to-peer networking library with support for DHT, GossipSub,
|
|
5
|
+
* file transfer, NAT traversal, and more.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
|
|
11
|
+
// Try to load the native addon from the build directory
|
|
12
|
+
let addon;
|
|
13
|
+
let addonPath;
|
|
14
|
+
|
|
15
|
+
// Possible locations for the built addon
|
|
16
|
+
const possiblePaths = [
|
|
17
|
+
// Standard node-gyp build location
|
|
18
|
+
path.join(__dirname, '..', 'build', 'Release', 'librats.node'),
|
|
19
|
+
path.join(__dirname, '..', 'build', 'Debug', 'librats.node'),
|
|
20
|
+
// Alternative build locations
|
|
21
|
+
path.join(__dirname, '..', 'build', 'librats.node'),
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
// Try each path
|
|
25
|
+
for (const tryPath of possiblePaths) {
|
|
26
|
+
try {
|
|
27
|
+
if (fs.existsSync(tryPath)) {
|
|
28
|
+
addon = require(tryPath);
|
|
29
|
+
addonPath = tryPath;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
} catch (err) {
|
|
33
|
+
// Continue to next path
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!addon) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
'Could not load librats native addon. ' +
|
|
40
|
+
'Make sure the package is installed correctly and the native library is built. ' +
|
|
41
|
+
'Try running: npm rebuild librats'
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Export all native bindings
|
|
46
|
+
module.exports = {
|
|
47
|
+
// Main class
|
|
48
|
+
RatsClient: addon.RatsClient,
|
|
49
|
+
|
|
50
|
+
// Version functions
|
|
51
|
+
getVersionString: addon.getVersionString,
|
|
52
|
+
getVersion: addon.getVersion,
|
|
53
|
+
getGitDescribe: addon.getGitDescribe,
|
|
54
|
+
getAbi: addon.getAbi,
|
|
55
|
+
|
|
56
|
+
// Constants
|
|
57
|
+
ConnectionStrategy: {
|
|
58
|
+
DIRECT_ONLY: 0,
|
|
59
|
+
STUN_ASSISTED: 1,
|
|
60
|
+
ICE_FULL: 2,
|
|
61
|
+
TURN_RELAY: 3,
|
|
62
|
+
AUTO_ADAPTIVE: 4
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
ErrorCodes: {
|
|
66
|
+
SUCCESS: 0,
|
|
67
|
+
INVALID_HANDLE: -1,
|
|
68
|
+
INVALID_PARAMETER: -2,
|
|
69
|
+
NOT_RUNNING: -3,
|
|
70
|
+
OPERATION_FAILED: -4,
|
|
71
|
+
PEER_NOT_FOUND: -5,
|
|
72
|
+
MEMORY_ALLOCATION: -6,
|
|
73
|
+
JSON_PARSE: -7
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// Log successful load for debugging
|
|
78
|
+
if (process.env.LIBRATS_DEBUG) {
|
|
79
|
+
console.log(`[librats] Loaded native addon from: ${addonPath}`);
|
|
80
|
+
console.log(`[librats] Version: ${addon.getVersionString()}`);
|
|
81
|
+
}
|
|
82
|
+
|