Commit Graph

61 Commits

Author SHA1 Message Date
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
Kcchouette b999f8d39f Fix availiable → available (#491) 2018-05-14 02:36:26 -07:00
Nicolas F bb9a62f71b user page: add manual activation button for mods (#472)
* user page: add manual activation button for mods

Moderators can press this button on inactive users to manually
activate their accounts.

Furthermore, the admin form code has been refactored a bit, reducing
some code duplication.
2018-05-10 18:57:59 -07:00
Nicolas F 60ce4ec3f1 Implement comment locking (#439)
* Implement comment locking

This adds a new flags to torrents, which is only editable by
moderators and admins. If checked, it does not allow unprivileged
users to post, edit or delete comments on that torrent.

* Rename "locked" to "comment_locked".

* Shorter button and additional words on alt text

* Admin log: Change comment locking message

dude I love bikeshedding xd

* Bikeshedding over admin log messages

* >&
Also some bikeshedding
2018-03-25 17:03:49 -07:00
Nicolas F c405f49eb6 Redo nuke functionality (#459)
This started out as a simple rebase, but then I rebased the wrong
branches and it all got confusing, so here it is as a new dank
commit.

We now have an @admin_only decorator, and we ask for confirmation
before we nuke. We can also see the nuke button when users are
banned, and nuking is a separate endpoint with a separate form.

Additionally, it now uses the new tracker API.
2018-03-25 16:24:44 -07:00
nyaadev 8de2663fc2 Remove deprecated torrent delete code. 2018-02-16 19:58:31 +01:00
Nicolas F 0285c12264 commenting: show CAPTCHA to new accounts (#443)
Basically re-use the upload CAPTCHA code to also do this for
comments.
2018-02-01 10:50:00 -08:00
Anna-Maria Meriniemi 7f9dc622b1 Email blacklist (#419) 2017-11-22 17:19:47 -08:00
TheAMM 630c69727d Torrent validation: explicitly mention missing announce-key 2017-11-13 23:01:58 +02:00
TheAMM 0b094a7229 Decode HTML entities in comments, make blockquotes smaller
Flask escapes < > etc, and the markdown parser does not consider
&gt; as > aka blockquote. Fixed by decoding HTML source before
rendering markdown.
2017-11-10 02:12:08 +02:00
Shane 72c997173c [Schema+config change] Comment editing (#396)
* Comment editing
* Optional time limit for comment editing
2017-11-05 16:26:30 +02:00
Nicolas F 4019343d50 Implement torrent nuking ability for mods (#377)
* Implement torrent nuking ability for mods

This deletes all torrents of a specific user.
A current caveat is that it will delete both sukebei and nyaa torrents,
but will only leave a log entry in the current flavour's log.

Also did some bootstrap untangling on the user view page.

* Per-flavour logging

Hopefully this works. Maybe.

* Tracker API: chunk into 100-element sublists

* isort

* Restrict nuking to superadmins

Also do a lint.sh.
2017-10-16 18:17:12 -07:00
Anna-Maria Meriniemi de1fd2f1bc [Config change] Upload ratelimit for non-trusted uploaders (#384)
* Implement upload ratelimit for non-trusted uploaders

Users may upload X torrents in Y minutes after which they
will have to wait Z minutes between uploads.

* Show torrent period count when ratelimited

* Only ratelimit new accounts
2017-10-09 18:41:18 -07:00
Anna-Maria Meriniemi 9e87e810af [Config change] Password reset by email (#381)
* Password reset by email

Adds endpoint, templates, email templates, forms

* Timeout password reset request in six hours
2017-10-08 04:34:40 +03:00
Anna-Maria Meriniemi 1e5f61ddf7 [Config change] Require recaptcha of new uploaders (#376)
* Reorganize config.example.py, add ACCOUNT_RECAPTCHA_AGE

* Require new accounts to pass recaptcha on upload

Based on ACCOUNT_RECAPTCHA_AGE in config.
2017-10-04 16:05:35 -07:00
A nyaa developer f8a314df4f Better bans (#341)
* better bans

* put jinja2 template into correct file
2017-08-25 18:53:35 -04:00
nyaadev d5b8a3a2ae Increase maximum comment size from 255 to 1024.
DB change: Change comment text field from VARCHAR(255) to mysql.TEXT
2017-08-14 19:08:36 +02:00
A nyaa developer e728ca1818 Expose soft delete to users and allow reuploading of deleted torrents. (#331)
Add banning torrents for moderators which disallows reuploading.
New delete UI.
2017-08-05 15:41:59 -04:00
Kfir Hadas 87dd95f1e0 Refactor into an app factory [2 of 2] (#322)
* Replace all `from nyaa import app` imports with `app = flask.current_app` (or `from flask import current_app as app` where possible)
* Add a separate config object for top-level and class statements as `nyaa.extensions.config`
Required because those codes don't have app context at the time of evaluation/execution.
* Remove `routes.py` file and register all blueprints in `nyaa/__init__.py`
* Refactor `nyaa/__init__.py` into an app factory
* Update tools
* Update tests (temporary, will be replaced)
2017-08-01 21:02:08 +03:00
TheAMM 1dae331156 Completely handle qBittorrent webseeds
Fixes #319

Zero webseeds: empty bytestring
One webseed: bytestring
More than one: a list of bytestrings (as the spec asks for!)
2017-07-30 11:49:13 +03:00
TheAMM 987103b213 Handle qButtorrent empty url-list/webseeds
url-list is supposed to be omitted in case of no webseeds,
but qB will instead use an empty bytestring '' as the value.
This commit makes the validation more lenient regarding url-list.
2017-07-30 11:36:38 +03:00
Anna-Maria Meriniemi 1bc36c5a17 [Schema change] Add webseed support (BEP-19) (#317)
Store webseeds in Trackers table with is_webseed flag
Adjusts torrent creation accordingly
2017-07-30 00:00:39 +03:00
Kfir Hadas b992467dad Apply isort & flake8 (#312)
* Update isort settings
* Apply import sorting (isort) on all files in nyaa/
* Fixed Flake8 errors in nyaa/ (see PR for list)
* Add isort to lint.sh and requirements.txt
2017-07-28 20:01:19 +03:00
mreweilk dd8cb4757e Admin Log 2.0 (#283)
* Admin log added

* Add admin log to top bar

* Fixed some admin log bugs

* Remove comment_id column because comments die when they are killed

* Fix tabs in admin log template

* Fixed sort of admin logs to be created_time desc

* Fix navbar wrapping to a new line

when 992px <= width <= 1200px

* Put reports and admin log in "Admin" dropdown

Applied ./lint.sh fixes

Fixed long lines

* Updated log to be text instead of id based to account for future deletions

* Small fix in log message formatting
2017-07-04 23:13:59 -05:00
TheAMM 081eb16246 Make username regex to stop the validation chain
with a decorator to replace ValidationError with StopValidation
2017-06-19 16:05:42 +03:00
TheAMM 505b4e18bd Move to markdown-it, render markdown in DOMContentLoaded
No more separate <script>s for comments
Adds a link to a GFM cheatsheet on markdown form
Spaces to tabs on "markdownEditors" DOMContentLoaded
2017-06-01 06:28:38 -05:00
nyaazi bea63315cd Merge branch 'master' into reports 2017-05-29 16:20:48 +03:00
TheAMM d89f74893b Remove username validator from login form to allow logging in with email
Since our previous regex was broken, the validator passed practically everything.
2017-05-26 23:28:28 +03:00
nyaazi 9e656ff7f6 Line too long 2017-05-26 15:29:49 +03:00
nyaazi 5332ba1a49 Merge branch 'master' into reports 2017-05-26 15:25:02 +03:00
TheAMM b6ecad898d Fix username validator
Tehee, oops!
2017-05-26 01:47:05 +03:00
nyaadev b7144f80f9 Make comments great again. 2017-05-22 23:38:06 +02:00
nyaadev fee55c1792 comments can be added+removed. gravatar for user avatar 2017-05-22 23:20:49 +02:00
Sn0wCrack fe6abf33c1 Added ability for users to leave anonymous comments 2017-05-22 23:19:36 +02:00
Sn0wCrack 6d608ab2f4 Added comments 2017-05-22 23:19:23 +02:00
katnyaa 159d5a5d9e Fix lint errors 2017-05-22 15:12:17 +01:00
TheAMM a1c024a342 Re-enable CSRF token for upload & fix API CSRF handling 2017-05-22 16:29:14 +03:00
aldacron c2438f3913 nyaadev is an idiot and broke apiv2 2017-05-21 22:10:05 -07:00
nyaadev a4c7dd7912 Add ReCaptcha to upload page if user is not logged in.
Bring back CSRF to upload form (Use the upload API)
2017-05-21 19:29:21 +02:00
nyaadev 9af778217b DB CHANGE: Add uploader ip address to torrent column and show on torrent view page for superadmins.
Added migration script!: remove sukebei_ lines if your local db does not have those.
Show users ip address on user page for superadmins.
Rename Admin to Moderator internally.
Moderators can now change user level to trusted.
Superadmins can make users moderator.
Improve changing user level.
2017-05-21 19:12:15 +02:00
nyaazi 92a6074fa2 Merge branch 'master' into reports 2017-05-21 18:48:45 +03:00
TheAMM b9d88e8960 Restructure upload.html and edit.html as well as route logic
Rename variables and reformats user/admin logic
Add an is_trusted field to upload and edit forms

Restructure fields on upload and edit pages
Add simple styling for checkboxes
Add titles (mouseover) for checkboxes with crude explanations
Show Anonymous checkbox during upload and check & disable it for guests
Show Trusted checkbox for users at or above Trusted level
Adjust description field rendering to show field label above it

Add title (mouseover) for edit icon on torrent page
Show uploader for admins on anonymous torrents
Show uploader for admins when editing others' torrents
2017-05-20 22:00:45 +03:00
nyaazi ec0f8000d7 Usage of WTForms for report action 2017-05-20 14:23:29 +03:00
nyaazi 354736720b Implemented report action
Actions: Close report, Hide torrent, Delete torrent
2017-05-20 13:33:58 +03:00
TheAMM 4b4a7b9830 Support BitComet empty directories (ew)
This will allow most (if not all) torrents that have been rejected by 'Malformed torrent metadata (path part is empty)'

Adjusts _validate_bytes to disable empty check
Adds the empty check to file tree parsing
2017-05-20 10:12:32 +03:00
nyaazi 98fbe6efb1 Adding report table, route and view. 2017-05-19 20:03:47 +03:00
nyaadev 2a1f8fab87 pep8 2017-05-19 14:36:33 +02:00
A nyaa developer d936fcf09d Merge pull request #59 from jprandomdev/deprecated_forms
replaced deprecated Classes by their newer versions
2017-05-18 15:20:40 +02:00
tipuch 6765929c7d - replaced deprecated fields by their newer counterparts. 2017-05-17 22:23:36 -04:00
martstern 931b2b0b83 added user class display and editing 2017-05-17 06:02:15 -04:00