Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block request coming from hostname? #18

Closed
hnqlv opened this issue Apr 1, 2016 · 3 comments
Closed

Block request coming from hostname? #18

hnqlv opened this issue Apr 1, 2016 · 3 comments
Labels
question A question related to the library

Comments

@hnqlv
Copy link

hnqlv commented Apr 1, 2016

First of all, really good project @nfriedly 馃檶

I just released this project heymoji.cool. The problem I'm facing right now is because you can embed heymoji using iframe I can't just block by IP. Otherwise when I hit the limit I can't "vote" in other sites as well.

Trying to find a way where I can detect the requests coming from X and block it by hostname. So if I hit the fire emoji 100 time on a.com the limit is set, however I still can go to b.com and vote there.

Does it make sense? Do you have any suggestion?

Cheers

@hnqlv hnqlv changed the title Detect request coming from hostname Block request coming from hostname? Apr 1, 2016
@nfriedly
Copy link
Member

nfriedly commented Apr 1, 2016

hey @henriquea I think I follow what you're talking about, it sounds like you're trying to use this for the "business logic" of your app, limiting how many times a user can cast a vote on a given instance of the widget, correct?

That's not really what express-rate-limit is designed for - it's intended to block/slow down abusive end-users. So if a user is abusing your project on a.com by voting a bajillion times, you would probably also want to block that user on b.com, right?

You're welcome to fork the code and adjust it to do your business logic - I think you could just change line 37 to

 var ip = req.ip + '-' + req.query.url;

But that will automatically reset after a while, so it might not be what you actually want.

Or am I misunderstanding you entirely?

@hnqlv
Copy link
Author

hnqlv commented Apr 1, 2016

Thanks for the quick response @nfriedly 馃槑

Yes exactly! It's hard to come up with a limit number. Let's say this gets popular and is in a lot of posts. I might read ~20 articles during the day, if each article has 5 widgets isn't that hard to hit 100 requests.

So if a user is abusing your project on a.com by voting a bajillion times, you would probably also want to block that user on b.com, right?

You made a fair point I agree. I wouldn't mind if reset after a while, I think this is the right behaviour.

Cheers

@hnqlv
Copy link
Author

hnqlv commented Apr 1, 2016

@nfriedly closing this issue now, since we have an alternative. Thanks again!

@hnqlv hnqlv closed this as completed Apr 1, 2016
@gamemaker1 gamemaker1 added the question A question related to the library label Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question related to the library
Projects
None yet
Development

No branches or pull requests

3 participants