First commit

This commit is contained in:
2026-07-20 11:05:07 +02:00
commit b592ab669f
159 changed files with 10294 additions and 0 deletions
@@ -0,0 +1,34 @@
# Generated by Django 6.0.7 on 2026-07-14 16:15
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='BanEvent',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('node', models.CharField(max_length=64)),
('action', models.CharField(max_length=32)),
('jail_name', models.CharField(max_length=64)),
('ip_address', models.GenericIPAddressField()),
('port', models.PositiveIntegerField(blank=True, null=True)),
('protocol', models.CharField(blank=True, max_length=16)),
('bantime', models.IntegerField(blank=True, null=True)),
('reason', models.CharField(blank=True, max_length=255)),
('event_time', models.DateTimeField(blank=True, null=True)),
('received_at', models.DateTimeField(auto_now_add=True)),
('raw_payload', models.JSONField(blank=True, default=dict)),
],
options={
'ordering': ['-received_at'],
},
),
]
@@ -0,0 +1,43 @@
# Generated by Django 6.0.7 on 2026-07-14 21:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('banevents', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='banevent',
name='city',
field=models.CharField(blank=True, max_length=128),
),
migrations.AddField(
model_name='banevent',
name='country',
field=models.CharField(blank=True, max_length=64),
),
migrations.AddField(
model_name='banevent',
name='country_code',
field=models.CharField(blank=True, max_length=2),
),
migrations.AddField(
model_name='banevent',
name='geolocated_at',
field=models.DateTimeField(blank=True, null=True),
),
migrations.AddField(
model_name='banevent',
name='latitude',
field=models.FloatField(blank=True, null=True),
),
migrations.AddField(
model_name='banevent',
name='longitude',
field=models.FloatField(blank=True, null=True),
),
]
@@ -0,0 +1,18 @@
# Generated by Django 6.0.7 on 2026-07-15 08:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('banevents', '0002_banevent_city_banevent_country_banevent_country_code_and_more'),
]
operations = [
migrations.AlterField(
model_name='banevent',
name='port',
field=models.CharField(blank=True, default='', max_length=64),
),
]
@@ -0,0 +1,51 @@
# Generated by Django 6.0.7 on 2026-07-17 16:04
from django.db import migrations, models
def backfill_node_registry(apps, schema_editor):
"""Sans ça, NodeRegistry reste vide au déploiement jusqu'à ce que
chaque noeud republie un événement le filtre par noeud du dashboard
(masqué s'il n'y a qu'une seule valeur) disparaîtrait pour les noeuds
déjà connus dans BanEvent, régression par rapport à l'ancien
_distinct_nodes() qui interrogeait BanEvent directement."""
BanEvent = apps.get_model('banevents', 'BanEvent')
NodeRegistry = apps.get_model('banevents', 'NodeRegistry')
for node_id in BanEvent.objects.order_by().values_list('node', flat=True).distinct():
if node_id:
NodeRegistry.objects.get_or_create(node_id=node_id)
class Migration(migrations.Migration):
dependencies = [
('banevents', '0003_alter_banevent_port'),
]
operations = [
migrations.CreateModel(
name='NodeRegistry',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('node_id', models.CharField(max_length=64, unique=True)),
('alias', models.CharField(blank=True, max_length=100)),
('country', models.CharField(blank=True, max_length=100)),
('first_seen', models.DateTimeField(auto_now_add=True)),
('last_seen', models.DateTimeField(auto_now=True)),
],
options={
'ordering': ['node_id'],
},
),
migrations.AlterField(
model_name='banevent',
name='country',
field=models.CharField(blank=True, db_index=True, max_length=64),
),
migrations.AlterField(
model_name='banevent',
name='jail_name',
field=models.CharField(db_index=True, max_length=64),
),
migrations.RunPython(backfill_node_registry, migrations.RunPython.noop),
]
@@ -0,0 +1,18 @@
# Generated by Django 6.0.7 on 2026-07-18 06:41
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('banevents', '0004_noderegistry_alter_banevent_country_and_more'),
]
operations = [
migrations.AddField(
model_name='noderegistry',
name='dashboard_url',
field=models.URLField(blank=True, max_length=255),
),
]
@@ -0,0 +1,27 @@
# Generated by Django 6.0.7 on 2026-07-18 10:55
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('banevents', '0005_noderegistry_dashboard_url'),
]
operations = [
migrations.CreateModel(
name='JoinToken',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('node_name', models.CharField(max_length=64)),
('token_hash', models.CharField(max_length=64, unique=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('expires_at', models.DateTimeField()),
('used_at', models.DateTimeField(blank=True, null=True)),
],
options={
'ordering': ['-created_at'],
},
),
]
@@ -0,0 +1,28 @@
# Generated by Django 6.0.7 on 2026-07-18 17:21
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('banevents', '0006_jointoken'),
]
operations = [
migrations.CreateModel(
name='EnrollmentRequest',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('email', models.EmailField(max_length=254)),
('node_name', models.CharField(max_length=64)),
('message', models.TextField(blank=True)),
('status', models.CharField(choices=[('pending', 'En attente'), ('approved', 'Approuvée'), ('rejected', 'Rejetée')], default='pending', max_length=16)),
('created_at', models.DateTimeField(auto_now_add=True)),
('processed_at', models.DateTimeField(blank=True, null=True)),
],
options={
'ordering': ['-created_at'],
},
),
]
@@ -0,0 +1,18 @@
# Generated by Django 6.0.7 on 2026-07-20 07:03
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('banevents', '0007_enrollmentrequest'),
]
operations = [
migrations.AddField(
model_name='enrollmentrequest',
name='country',
field=models.CharField(blank=True, max_length=100),
),
]