Add IP bans

Users can be banned by IP address now, either by singular IP or in an IP
range. If they are banned and attempt to post, they will be met with a
"you are banned until X date" screen.

There are a few loose threads with this, and IP bans may be obsolete if
I decide to go the accounts-required-for-posting route. But I think this
is a good start for 4chan style posting.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-06-20 15:26:35 -07:00
parent b4df8b9756
commit 28ccd7d73b
7 changed files with 190 additions and 30 deletions

View File

@@ -0,0 +1,81 @@
{% extends "board/base.html" %}
{% block title %}
{% if bans %}
{% with title="Banned" %}
{{ block.super }}
{% endwith %}
{% else %}
{% with title="Not banned" %}
{{ block.super }}
{% endwith %}
{% endif %}
{% endblock title %}
{% block extrastyle %}
{{block.super}}
<style>
.blankcolumn {
float: left;
width: 20%;
}
.bancolumn {
float: left;
width: 60%;
}
</style>
{% endblock extrastyle %}
{% block content %}
<div class="row">
<div class="blankcolumn">&nbsp;</div>
<div class="bancolumn">
{% if bans %}
<div class="row">
<h2>You are banned.</h2>
</div>
<div class="row">
<p>
You have been banned, and you are not allowed to post until your
bans have expired.
</p>
<p>
<strong>Your IP address:</strong> {{ip}}
</p>
</div>
<hr />
{% for ban in bans %}
<div class="row">
<p>
<strong>Board:</strong>
{% if ban.board %}
/{{ ban.board.url }}/ - {{ ban.board.name }}
{% else %}
All boards
{% endif %}
</p>
<p>
<strong>Ban reason:</strong>
</p>
<p>{{ban.ban_reason}}</p>
<p><strong>
{% if ban.expires %}
This ban will expire on {{ban.expires|date:"M dS"}} at {{ban.expires|date:"P e"}}
{% else %}
This ban will not expire.
{% endif %}
</strong></p>
</div>
<hr />
{% endfor %}
{% else %}
<div class="row">
<h2>You are not banned.</h2>
</div>
<div class="row">
<p>You have no bans recorded for your IP address.</p>
</div>
{% endif %}
</div>
<div class="blankcolumn">&nbsp;</div>
{% endblock %}

View File

@@ -7,9 +7,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>{% block title %}{% if title %}{{title}}{% else %}Index{% endif %}{% endblock %}</title>
<link rel="stylesheet" href="{% static 'board/style.css' %}">
{% block extrastyle %}{% endblock %}
<script src="{% static 'board/jquery.js' %}"></script>
<script src="{% static 'board/winbox.bundle.js' %}"></script>
<script src="{% static 'board/post.js' %}"></script>
{% block extrajs %}{% endblock %}
</head>
<body>
<main>