valeriansaliou / node-fast-ratelimit

:umbrella: Fast and efficient in-memory rate-limit for Node, used to alleviate most common DOS attacks.
https://www.npmjs.com/package/fast-ratelimit
MIT License
108 stars 19 forks source link

Release 2.1.2 #2

Closed peterkuiper closed 7 years ago

valeriansaliou commented 7 years ago

Hi! Can you explain a bit more the purpose of moving this dep. / is this a spin-off / whats better off in it?

peterkuiper commented 7 years ago

I was a bit too quick in creating a PR, sorry for that. The maintainer of node-hashtable doesn't seem to be active anymore so we published a new version of it which actually compiles under MacOS. We currently depend on your module so this was the easiest for us to get things going.

valeriansaliou commented 7 years ago

Cool; will review this asap! 👍 Feel free to re-open when good to go.

peterkuiper commented 7 years ago

For the time being we published your module with the modified 'hashtable' module:

https://github.com/anchorchat/node-fast-ratelimit

As you can see here, the PR by @fabrice102 is open since december 2016.

valeriansaliou commented 7 years ago

On my end fast-ratelimit builds on MacOS w/o any issue - as MacOS is my dev. environment (latest Sierra).

peterkuiper commented 7 years ago

A few of us are on 10.11, and it does not compile under node v8 (works with v6):

v6:

➜  fast-ratelimit nvm use v6
Now using node v6.10.3 (npm v3.10.10)
➜  fast-ratelimit npm i fast-ratelimit

> hashtable@2.0.2 install /Users/pkuiper/fast-ratelimit/node_modules/hashtable
> node-gyp configure build

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
  CXX(target) Release/obj.target/native/src/hashtable.o
  SOLINK_MODULE(target) Release/native.node
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9
/Users/pkuiper/fast-ratelimit
└─┬ fast-ratelimit@2.1.0
  ├── es6-promise-polyfill@1.2.0
  └─┬ hashtable@2.0.2
    └── nan@2.6.2

npm WARN enoent ENOENT: no such file or directory, open '/Users/pkuiper/fast-ratelimit/package.json'
npm WARN fast-ratelimit No description
npm WARN fast-ratelimit No repository field.
npm WARN fast-ratelimit No README data
npm WARN fast-ratelimit No license field.

v8:

➜  fast-ratelimit nvm use v8
Now using node v8.1.0 (npm v5.0.3)
➜  fast-ratelimit npm i fast-ratelimit

> hashtable@2.0.2 install /Users/pkuiper/fast-ratelimit/node_modules/hashtable
> node-gyp configure build

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
  CXX(target) Release/obj.target/native/src/hashtable.o
In file included from ../src/hashtable.cpp:1:
../src/hashtable.h:7:10: fatal error: 'tr1/unordered_map' file not found
#include <tr1/unordered_map>
         ^
1 error generated.
make: *** [Release/obj.target/native/src/hashtable.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/pkuiper/.nvm/versions/node/v8.1.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
gyp ERR! System Darwin 15.6.0
gyp ERR! command "/Users/pkuiper/.nvm/versions/node/v8.1.0/bin/node" "/Users/pkuiper/.nvm/versions/node/v8.1.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /Users/pkuiper/fast-ratelimit/node_modules/hashtable
gyp ERR! node -v v8.1.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open '/Users/pkuiper/fast-ratelimit/package.json'
npm WARN fast-ratelimit No description
npm WARN fast-ratelimit No repository field.
npm WARN fast-ratelimit No README data
npm WARN fast-ratelimit No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hashtable@2.0.2 install: `node-gyp configure build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hashtable@2.0.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/pkuiper/.npm/_logs/2017-06-14T15_39_21_173Z-debug.log
valeriansaliou commented 7 years ago

Hi!

Just tested your fix, didn't work on Node v6 which we're using at @crisp-im (the reason why node-fast-ratelimit was created).

I found another way, check out the fix-over-your-fix commit here: https://github.com/valeriansaliou/node-hashtable/commit/d823048eade57fa81dbe91285ed6f202fae0a20f then https://github.com/valeriansaliou/node-hashtable/commit/48a17996c7c5c08a62084bc792dbcef97456ab4f

I published a spin-off of node-hashtable on my own scope; I bumped node-fast-ratelimit to v2.1.7 with the fix. Let me know if that works now on Node v8 as I had no opportunity to test my fix on v8 — it compiles fine on v6.

peterkuiper commented 7 years ago

@valeriansaliou your fix looks much cleaner :) seems to work now under v8 too. BTW you have a small mistake in your README:

How to install?

Include rate-limit in your package.json dependencies.

Alternatively, you can run npm install rate-limit --save.

Note: ensure you have a C++11 compiler available. This allows for node-gyp to build the hashtable dependency that fast-ratelimit depends on.

it says rate-limit instead of fast-ratelimit...

valeriansaliou commented 7 years ago

Cool. Thanks fixed it 👍

Thanks for all!

peterkuiper commented 7 years ago

Thank you too 👍