michalmuskala / plug_attack

A plug building toolkit for blocking and throttling abusive requests
419 stars 20 forks source link

Fix reference to "request_ip" in ReadMe #1

Closed tdcain89 closed 7 years ago

tdcain89 commented 7 years ago

Hey @michalmuskala , really appreciate this library. Quick fix to the readme here.

Also, might make an issue later... still trying to figure out if I'm doing something wrong.

This is the error I'm experiencing currently:

** (ArgumentError) argument error
        (stdlib) :ets.update_counter(MyApp.PlugAttack.Storage, {:throttle, {127, 0, 0, 1}, 12327780}, 1, {{:throttle, {127, 0, 0, 1}, 12327780}, 0, 1479333720000})
        (plug_attack) lib/storage/ets.ex:27: PlugAttack.Storage.Ets.increment/4
        (plug_attack) lib/rule.ex:80: PlugAttack.Rule.do_throttle/2

^ Where MyApp is the application running PlugAttack. Let me know if anything jumps out at you.

Thanks!

michalmuskala commented 7 years ago

Thank you! ❤️

The error suggest that the ets table is not started. Have you started the storage process? https://github.com/michalmuskala/plug_attack/blob/master/lib/storage/ets.ex#L3-L15

tdcain89 commented 7 years ago

@michalmuskala Yes, from what I can tell the ets table is started. I see it in the list returned when running :ets.all and running something like this returns 1 as expected

iex(10)> :ets.update_counter(MyApp.PlugAttack.Storage, "a", 1, {"a", 0})
1

For reference I'm on erlang 18.3 and elixir 1.3.4

michalmuskala commented 7 years ago

I'm a bit lost here. Could you check that the worker for PlugAttack is started before the endpoint?