mirror of
https://github.com/wahyd4/links.git
synced 2026-08-09 05:06:16 +10:00
117 lines
6.6 KiB
Python
117 lines
6.6 KiB
Python
# Generated by Django 5.2.12 on 2026-04-01 03:47
|
||
|
||
import django.db.models.deletion
|
||
import netscan.fields
|
||
from django.db import migrations, models
|
||
|
||
|
||
class Migration(migrations.Migration):
|
||
|
||
initial = True
|
||
|
||
dependencies = [
|
||
]
|
||
|
||
operations = [
|
||
migrations.CreateModel(
|
||
name='IPGeoCache',
|
||
fields=[
|
||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||
('ip', models.GenericIPAddressField(db_index=True, unique=True)),
|
||
('country', models.CharField(blank=True, max_length=100)),
|
||
('country_code', models.CharField(blank=True, max_length=10)),
|
||
('region', models.CharField(blank=True, max_length=100)),
|
||
('city', models.CharField(blank=True, max_length=100)),
|
||
('lat', models.FloatField(blank=True, null=True)),
|
||
('lon', models.FloatField(blank=True, null=True)),
|
||
('isp', models.CharField(blank=True, max_length=300)),
|
||
('is_private', models.BooleanField(default=False)),
|
||
('fetched_at', models.DateTimeField(auto_now=True)),
|
||
],
|
||
),
|
||
migrations.CreateModel(
|
||
name='NginxAlertProfile',
|
||
fields=[
|
||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||
('name', models.CharField(max_length=200)),
|
||
('alert_window_seconds', models.IntegerField(default=60, help_text='Rolling window in seconds for rate analysis')),
|
||
('alert_max_requests', models.IntegerField(default=200, help_text='Max requests per IP per window before triggering a rate alert')),
|
||
('alert_max_error_rate', models.FloatField(default=0.6, help_text='Error rate threshold (0–1) to flag an IP')),
|
||
('alert_min_requests', models.IntegerField(default=15, help_text='Minimum requests before running error-rate check')),
|
||
('telegram_bot_token', netscan.fields.EncryptedCharField(blank=True)),
|
||
('telegram_chat_id', netscan.fields.EncryptedCharField(blank=True)),
|
||
('enabled', models.BooleanField(default=True)),
|
||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||
],
|
||
),
|
||
migrations.CreateModel(
|
||
name='NginxSettings',
|
||
fields=[
|
||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||
('namespace', models.CharField(default='ingress-nginx', max_length=200)),
|
||
('pod_label', models.CharField(default='app.kubernetes.io/name=ingress-nginx', help_text='kubectl -l selector for the ingress-nginx pods', max_length=200)),
|
||
('container', models.CharField(default='controller', max_length=100)),
|
||
('fetch_interval_seconds', models.IntegerField(default=30, help_text='How often to pull new logs (seconds)')),
|
||
('log_file_path', models.CharField(blank=True, help_text='Absolute path to a local nginx log file for testing. Leave empty to use kubectl in production.', max_length=500)),
|
||
('enabled', models.BooleanField(default=True)),
|
||
('last_fetch_at', models.DateTimeField(blank=True, null=True)),
|
||
],
|
||
options={
|
||
'verbose_name': 'Nginx Settings',
|
||
'verbose_name_plural': 'Nginx Settings',
|
||
},
|
||
),
|
||
migrations.CreateModel(
|
||
name='NginxAccessLog',
|
||
fields=[
|
||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||
('timestamp', models.DateTimeField(db_index=True)),
|
||
('remote_addr', models.GenericIPAddressField(db_index=True)),
|
||
('method', models.CharField(max_length=20)),
|
||
('request_uri', models.TextField()),
|
||
('protocol', models.CharField(max_length=20)),
|
||
('status', models.IntegerField(db_index=True)),
|
||
('body_bytes_sent', models.IntegerField()),
|
||
('http_referer', models.TextField(blank=True)),
|
||
('http_user_agent', models.TextField(blank=True)),
|
||
('request_length', models.IntegerField(default=0)),
|
||
('request_time', models.FloatField()),
|
||
('service', models.CharField(blank=True, db_index=True, max_length=200)),
|
||
('upstream_addr', models.CharField(blank=True, max_length=200)),
|
||
('upstream_response_time', models.FloatField(blank=True, null=True)),
|
||
('upstream_status', models.IntegerField(blank=True, null=True)),
|
||
('request_id', models.CharField(blank=True, db_index=True, max_length=100)),
|
||
('country', models.CharField(blank=True, max_length=100)),
|
||
('country_code', models.CharField(blank=True, max_length=10)),
|
||
('region', models.CharField(blank=True, max_length=100)),
|
||
('city', models.CharField(blank=True, max_length=100)),
|
||
],
|
||
options={
|
||
'ordering': ['-timestamp'],
|
||
'indexes': [models.Index(fields=['remote_addr', 'timestamp'], name='nginxmon_ng_remote__1ceb1d_idx')],
|
||
},
|
||
),
|
||
migrations.CreateModel(
|
||
name='ThreatAlert',
|
||
fields=[
|
||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||
('alert_type', models.CharField(choices=[('rate_limit', 'High Request Rate'), ('error_rate', 'High Error Rate')], max_length=50)),
|
||
('remote_addr', models.GenericIPAddressField(db_index=True)),
|
||
('detected_at', models.DateTimeField(auto_now_add=True)),
|
||
('window_start', models.DateTimeField()),
|
||
('window_end', models.DateTimeField()),
|
||
('request_count', models.IntegerField()),
|
||
('error_count', models.IntegerField(default=0)),
|
||
('detail', models.TextField()),
|
||
('notified', models.BooleanField(default=False)),
|
||
('dismissed', models.BooleanField(default=False)),
|
||
('country', models.CharField(blank=True, max_length=100)),
|
||
('city', models.CharField(blank=True, max_length=100)),
|
||
('profile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='alerts', to='nginxmon.nginxalertprofile')),
|
||
],
|
||
options={
|
||
'ordering': ['-detected_at'],
|
||
},
|
||
),
|
||
]
|