@yz-social/kdht 0.1.2 → 0.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yz-social/kdht",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Pure Kademlia base, for testing variations.",
5
5
  "exports": {
6
6
  ".": "./index.js",
package/portals/node.js CHANGED
@@ -28,4 +28,10 @@ export async function setup({baseURL, externalBaseURL = '', verbose, fixedSpacin
28
28
  const bootstrap = joinURL && await contact.ensureRemoteContact(bootstrapName, joinURL);
29
29
  process.send(contact.sname); // Report in to server as available for others to bootstrap through.
30
30
  if (bootstrap) await contact.join(bootstrap);
31
+ process.on('SIGINT', async () => {
32
+ console.log(process.title, 'Shutdown for Ctrl+C');
33
+ await contact.disconnect();
34
+ process.exit(0);
35
+ });
36
+ return contact;
31
37
  }
package/spec/bots.js CHANGED
@@ -62,6 +62,12 @@ let bootstrapName = await contact.fetchBootstrap(argv.baseURL);
62
62
  let bootstrapContact = await contact.ensureRemoteContact(bootstrapName, argv.baseURL);
63
63
  await contact.join(bootstrapContact);
64
64
 
65
+ process.on('SIGINT', async () => {
66
+ console.log(process.title, 'Shutdown for Ctrl+C');
67
+ await contact.disconnect();
68
+ process.exit(0);
69
+ });
70
+
65
71
  while (argv.thrash) {
66
72
  await Node.delay(contact.host.fuzzyInterval(Node.refreshTimeIntervalMS));
67
73
  const old = contact;
package/spec/portal.js CHANGED
@@ -115,5 +115,5 @@ if (cluster.isPrimary) { // Parent process with portal webserver through which c
115
115
  } else { // A portal node through which client's can connect.
116
116
  const portalNode = await import('../portals/node.js');
117
117
  const {baseURL, externalBaseURL, fixedSpacing, variableSpacing, verbose} = argv;
118
- portalNode.setup({baseURL, externalBaseURL, fixedSpacing, variableSpacing, verbose});
118
+ await portalNode.setup({baseURL, externalBaseURL, fixedSpacing, variableSpacing, verbose});
119
119
  }
@@ -209,7 +209,7 @@ export class WebContact extends Contact { // Our wrapper for the means of contac
209
209
  // If we find that in our inFlight tags, then the message is a response.
210
210
  if (dataString === '"bye"') { // Special messsage that the other side is disconnecting, so we can clean up early.
211
211
  this.webrtc.close();
212
- this.host.xlog('removing disconnected contact');
212
+ this.host.xlog('removing disconnected contact', this.sname);
213
213
  await this.host.removeContact(this); // TODO: Make sure we're not invoking this in maxTransports cases.
214
214
  return;
215
215
  }