-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.js
More file actions
40 lines (34 loc) · 1.14 KB
/
test.js
File metadata and controls
40 lines (34 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const AmuleClient = require('./../AmuleClient');
const AMULE_HOST = process.env.AMULE_HOST || '127.0.0.1';
const AMULE_PORT = process.env.AMULE_PORT || 4712;
const AMULE_PASSWORD = process.env.AMULE_PASSWORD || 'admin';
const DEBUG = true;
const amuleClient = new AmuleClient(AMULE_HOST, AMULE_PORT, AMULE_PASSWORD);
(async function init() {
try {
await amuleClient.connect();
if (DEBUG) console.log('Connected and authenticated successfully to aMule');
} catch (error) {
console.error('Could not connect to aMule:', error);
process.exit(1);
}
try {
const stats = await amuleClient.getStats();
console.dir(stats, { depth: null });
} catch (error) {
console.error('Error executing aMule commands:', error);
}
try {
const sharedFiles = await amuleClient.getSharedFiles();
const names = sharedFiles.map(file => file.fileName).sort();
console.dir(names, { depth: null });
} catch (error) {
console.error('Error executing aMule commands:', error);
}
try {
amuleClient.close();
console.log('Disconnected from aMule');
} catch (err) {
console.error('Error disconnecting:', err);
}
})();