readthedocs-fr / bin-server

Un outil pour héberger des snippets de code et les partager via une URL.
https://bin.readthedocs.fr
MIT License
14 stars 15 forks source link

add: usage bypass ip list #92

Closed AntoineJT closed 3 years ago

AntoineJT commented 3 years ago

This commit adds a view count whitelist: a txt file containing IP addresses which may not decrement remaining views counter.

When using the bin, it is annoying to burn views because of the discord preview system (see #91).

That's why I implemented a list of whitelisted IP addresses, containing only Discord bot IPs for the moment. Because it may contain more IPs in the future, I implemented a basic txt parser, allowing to add comments starting with #.

I also added a unit test with it, because I don't want it to be broken.

Please note that this list is not official and is subject to changes. It is therefore not fully reliable, but this is largely better than matching on the user-agent, which is something not reliable at all.

Maybe we can combine both technique: like logging the user-agents containing Discordbot/2.0;, and counting views on whitelisted IPs that do not contain this in their user-agent. That's an idea for later, but for now, I don't think this is useful and therefore, we can make use of this new system, for other things later maybe.

AntoineJT commented 3 years ago

Je garde le test unitaire, il ne vérifie pas l'ouverture du fichier mais que le "parser" ignore bien les commentaires dans l'output. Avant de squash merge cette PR, il faudra bien entendu détailler cette nouvelle fonctionnalité dans le README

AntoineJT commented 3 years ago

Tâches restantes à faire avant de merge