%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/imunify360/venv/lib/python3.8/site-packages/defence360agent/migrations/
Upload File :
Create Path :
Current File : //opt/imunify360/venv/lib/python3.8/site-packages/defence360agent/migrations/074_ip_as_int.py

"""
This program is free software: you can redistribute it and/or modify it under 
the terms of the GNU General Public License as published by 
the Free Software Foundation, either version 3 of the License, 
or (at your option) any later version.


This program is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
See the GNU General Public License for more details.


You should have received a copy of the GNU General Public License
 along with this program.  If not, see <https://www.gnu.org/licenses/>.

Copyright © 2019 Cloud Linux Software Inc.

This software is also available under ImunifyAV commercial license,
see <https://www.imunify360.com/legal/eula>
"""
import logging
from time import time

import peewee as pw
import ipaddress

from tempfile import TemporaryFile

logger = logging.getLogger(__name__)


def migrate(migrator, database, fake=False, **kwargs):
    """Write your migrations here."""

    Country = migrator.orm['country']

    class IPListNew(pw.Model):
        # available list names

        ip = pw.CharField(null=False)
        listname = pw.CharField(null=False,
                                constraints=[
                                    pw.Check("listname in "
                                             "('WHITE','BLACK','GRAY')")])
        expiration = pw.IntegerField(default=0,  # 0 - never
                                     null=True)  # null - the same :(
        imported_from = pw.CharField(null=True)
        ctime = pw.IntegerField(null=True,  # those
                                default=lambda: int(time()))  # are OK
        deep = pw.IntegerField(null=True)
        comment = pw.CharField(null=True)
        country = pw.ForeignKeyField(Country, null=True)
        no_captcha = pw.BooleanField(null=False, default=False)
        full_access = pw.BooleanField(null=True)
        auto_whitelisted = pw.BooleanField(null=True, default=False)

        network_address = pw.IntegerField(null=False)
        netmask = pw.IntegerField(null=False)
        version = pw.IntegerField(null=False)

        class Meta:
            db_table = 'iplist_new'
            primary_key = pw.CompositeKey('network_address',
                                          'netmask',
                                          'version')

    migrator.create_model(IPListNew)


def rollback(migrator, database, fake=False, **kwargs):
    """Write your rollback migrations here."""
    pass

Zerion Mini Shell 1.0