venus-pit 1.1.4 → 1.1.6

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": "venus-pit",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "Express.js-based tarpit",
5
5
  "main": "dist/venus.bundle.js",
6
6
  "type": "module",
@@ -14,7 +14,7 @@
14
14
  "devbuild": "npm run build && cp dist/venus.bundle.js testing/venus.js"
15
15
  },
16
16
  "author": "Shrey Yadav",
17
- "license": "AGPL-3.0-only",
17
+ "license": "MPL-2.0",
18
18
  "dependencies": {
19
19
  "express": "^5.1.0"
20
20
  },
@@ -1,5 +1,5 @@
1
1
  function markov(corpus, max) {
2
- const words = corpus.split(" ");
2
+ const words = corpus.split(/\s+/);
3
3
  const transitions = {};
4
4
 
5
5
 
@@ -41,8 +41,8 @@ function pit(app, instanceRoot, req) {
41
41
  // reasonable server response time, should waste cpu cycles
42
42
  setTimeout(() => {res.send(tar(pit(app, instanceRoot, req)))}, rand());
43
43
 
44
- // prevent memory leak by cleaning up old routes
45
- selfDestruct(newRoute)
44
+ // prevent memory leak by cleaning up old routes : add delay on garbage collection
45
+ setTimeout(() => {selfDestruct(newRoute)}, rand()*rand())
46
46
  })
47
47
  };
48
48
 
@@ -1,7 +1,8 @@
1
- import { words } from "./words.js"
1
+ import corpora from "../corpora.js"
2
2
  import crypto from 'crypto'
3
3
 
4
- let wordList = words.split(" "); // more efficient to just compute once
4
+ // remove all non a-z, lowercase, split into tokens
5
+ let wordList = corpora.replace(/[^a-zA-Z ]/g, "").toLowerCase().split(/\s+/); // more efficient to just compute once
5
6
  function randomWord() {
6
7
  const index = crypto.randomInt(0, wordList.length);
7
8
  return wordList[index];
package/src/venus.js CHANGED
@@ -5,6 +5,7 @@ import { tar } from "./lib/tarpit/tar.js"
5
5
  function venus(app, root="UNSET") {
6
6
  const instanceRoot = new venusRoot(root);
7
7
  console.log('path: ' + instanceRoot.path)
8
+ app.set('trust proxy', true) // fix ip detection
8
9
  app.get(instanceRoot.path, (req, res) => {
9
10
  let firsturl = pit(app, instanceRoot, req) // this will start the recursive hell known as a tarpit
10
11
  res.send(tar(firsturl))