# Generated by Django 2.1.7 on 2019-04-15 13:44

import catcher.models
import datetime
from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
from django.utils.timezone import utc
import jsonfield.fields
import uuid


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('auth', '0009_alter_user_last_name_max_length'),
    ]

    operations = [
        migrations.CreateModel(
            name='Client',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('password', models.CharField(max_length=128, verbose_name='password')),
                ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
                ('apikey', models.UUIDField(default=uuid.uuid4, unique=True)),
                ('name', models.CharField(max_length=100)),
                ('email', models.EmailField(max_length=100)),
                ('agent', models.EmailField(max_length=200, null=True)),
                ('source', models.GenericIPAddressField(default=None, null=True)),
                ('created_time', models.DateTimeField(auto_now=True)),
                ('update_time', models.DateTimeField(auto_now=True)),
                ('is_staff', models.BooleanField(default=False)),
                ('is_superuser', models.BooleanField(default=False)),
                ('is_client', models.BooleanField(default=True)),
                ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
                ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
            ],
            options={
                'db_table': 'clientuser',
            },
            managers=[
                ('objects', catcher.models.ClientUserManager()),
            ],
        ),
        migrations.CreateModel(
            name='Blacklist',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('ip', models.GenericIPAddressField()),
            ],
            options={
                'db_table': 'blacklist',
            },
        ),
        migrations.CreateModel(
            name='Callback',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('sourceip', models.GenericIPAddressField()),
                ('sourceport', models.IntegerField(default=0)),
                ('serverip', models.GenericIPAddressField()),
                ('serverport', models.IntegerField()),
                ('protocol', models.CharField(default='tcp', max_length=3)),
                ('timestamp', models.DateTimeField(auto_now_add=True)),
                ('datasize', models.IntegerField()),
                ('datahex', models.TextField(null=True)),
                ('data', models.BinaryField()),
            ],
            options={
                'db_table': 'callback',
            },
        ),
        migrations.CreateModel(
            name='Fingerprint',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=50)),
                ('probe', models.CharField(max_length=100)),
            ],
            options={
                'db_table': 'fingerprints',
            },
        ),
        migrations.CreateModel(
            name='Handler',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=100)),
                ('description', models.TextField()),
                ('filename', models.CharField(max_length=200)),
                ('default_config', jsonfield.fields.JSONField(null=True)),
            ],
            options={
                'db_table': 'handlers',
            },
        ),
        migrations.CreateModel(
            name='Port',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('number', models.IntegerField(validators=[django.core.validators.MaxValueValidator(65535), django.core.validators.MinValueValidator(1)])),
                ('protocol', models.CharField(max_length=3)),
                ('ssl', models.IntegerField()),
                ('created_time', models.DateTimeField(auto_now_add=True)),
                ('pid', models.IntegerField(null=True)),
                ('config', jsonfield.fields.JSONField(null=True)),
                ('handler', models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='catcher.Handler')),
            ],
            options={
                'db_table': 'ports',
            },
        ),
        migrations.CreateModel(
            name='Secret',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=150)),
                ('value', models.TextField()),
                ('callback', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='secrets', to='catcher.Callback')),
            ],
            options={
                'db_table': 'secrets',
            },
        ),
        migrations.CreateModel(
            name='Token',
            fields=[
                ('id', models.AutoField(primary_key=True, serialize=False)),
                ('token', models.CharField(default=catcher.models._gen_token_hash, max_length=33, unique=True)),
                ('created_time', models.DateTimeField(auto_now_add=True)),
                ('expire_time', models.DateTimeField(default=datetime.datetime(2019, 5, 15, 13, 44, 43, 73983, tzinfo=utc))),
                ('callback', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='tokencallback', to='catcher.Callback')),
                ('client', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'token',
            },
        ),
        migrations.AddField(
            model_name='callback',
            name='fingerprint',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='catcher.Fingerprint'),
        ),
        migrations.AlterUniqueTogether(
            name='port',
            unique_together={('number', 'protocol')},
        ),
    ]
