nyaa/nyaa
Nicolas F a38e5d5b53 Implement range bans (#478)
* Implement range bans

People connecting from banned IP ranges are unable to upload
torrents anonymously, and need to manually have their accounts
activated.

This adds a new table "rangebans", and a command line utility,
"rangeban.py", which can be used to add, list and remove rangebans
from the command line.

As an example:

./rangeban.py ban 192.168.0.0/24

This would rangeban anything in this /24.

The temporary_tor column allows automated scripts to clean out and
re-add ever-changing sets of ranges to be banned without affecting
the other ranges.

This has only been tested for IPv4.

* Revise Rangebans

Add an id column, and change "temporary_tor" to "temp". Also
index masked_cidr and mask.

* rangebans: fix enabled and the binary op

kill me

* Add enabling/disabling bans to rangeban.py

* rangebans: fail earlier on garbage arguments

* rangebans: fix linter errors

* rangeban.py: don't shadow builtin keyword 'id'

* rangebans: change temporary ban logic, column

The 'temp' column is now a nullable time column. If the field is
null, the ban is understood to be permanent. If there is a time
in there, it's understood to be the creation time of the ban.

This allows scripts to e.g. delete all temporary bans older than
a certain amount of time.

Also, rename the '_cidr_string' column to 'cidr_string', because
reasons.

* rangeban.py: use ip_address to parse CIDR subnet

* rangebans: fixes to the mask calculation and query

Both were not bugs per-se, but just technically not needed/correct.

* De-meme apparently
2018-06-29 20:15:04 -07:00
..
static comments: fix editing for users with a CAPTCHA (#502) 2018-06-16 16:57:14 -07:00
templates Implement range bans (#478) 2018-06-29 20:15:04 -07:00
views Implement range bans (#478) 2018-06-29 20:15:04 -07:00
__init__.py Use Flask-Assets to minify self-hosted JS files (#468) 2018-04-04 16:02:05 +02:00
api_handler.py Move bencoded info dicts from mysql torrent_info table to info_dict directory. DB change! 2018-02-02 20:39:02 +01:00
backend.py Implement range bans (#478) 2018-06-29 20:15:04 -07:00
bencode.py bencode: fix nontermination on empty or malformed input 2017-07-24 20:53:48 -06:00
email.py [Config change] Password reset by email (#381) 2017-10-08 04:34:40 +03:00
extensions.py Refactor into an app factory [2 of 2] (#322) 2017-08-01 21:02:08 +03:00
forms.py Implement range bans (#478) 2018-06-29 20:15:04 -07:00
models.py Implement range bans (#478) 2018-06-29 20:15:04 -07:00
search.py [ES] Improve search term preprocessing to include literal groups (#477) 2018-04-15 09:53:36 +03:00
template_utils.py Fix keyError from pop (#407) 2017-11-06 23:52:25 +02:00
torrents.py Fix flat PR (#446) 2018-02-04 13:56:29 +01:00
utils.py Redo nuke functionality (#459) 2018-03-25 16:24:44 -07:00