HEX
Server: LiteSpeed
System: Linux php-prod-3.spaceapp.ru 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: sarli3128 (1010)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //opt/imunify360/venv/lib64/python3.11/site-packages/defence360agent/migrations/074_ip_as_int.py
import logging
from time import time

import peewee as pw


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, null=True  # 0 - never
        )  # null - the same :(
        imported_from = pw.CharField(null=True)
        ctime = pw.IntegerField(
            null=True, default=lambda: int(time())  # those
        )  # 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