diff --git a/app/db/migrations/versions/2ea33513efc0_noise_for_sqlite.py b/app/db/migrations/versions/2ea33513efc0_noise_for_sqlite.py new file mode 100644 index 000000000..dd847127e --- /dev/null +++ b/app/db/migrations/versions/2ea33513efc0_noise_for_sqlite.py @@ -0,0 +1,32 @@ +"""noise for sqlite + +Revision ID: 2ea33513efc0 +Revises: a9cfd5611a82 +Create Date: 2024-10-11 15:36:32.096594 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '2ea33513efc0' +down_revision = 'a9cfd5611a82' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + bind = op.get_bind() + + if bind.engine.name == 'sqlite': + with op.batch_alter_table('hosts') as batch_op: + batch_op.alter_column('noise_setting', + existing_type=sa.String(length=2000), + nullable=True) + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### diff --git a/app/db/migrations/versions/a9cfd5611a82_add_noise_settings.py b/app/db/migrations/versions/a9cfd5611a82_add_noise_settings.py index 546e042a4..6b787aae9 100644 --- a/app/db/migrations/versions/a9cfd5611a82_add_noise_settings.py +++ b/app/db/migrations/versions/a9cfd5611a82_add_noise_settings.py @@ -18,7 +18,7 @@ def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### - op.add_column('hosts', sa.Column('noise_setting', sa.String(), nullable=True)) + op.add_column('hosts', sa.Column('noise_setting', sa.String(length=2000), nullable=True)) # ### end Alembic commands ### diff --git a/app/db/models.py b/app/db/models.py index 806922625..fff745f5a 100644 --- a/app/db/models.py +++ b/app/db/models.py @@ -214,7 +214,7 @@ class ProxyHost(Base): is_disabled = Column(Boolean, nullable=True, default=False) mux_enable = Column(Boolean, nullable=False, default=False, server_default='0') fragment_setting = Column(String(100), nullable=True) - noise_setting = Column(String(), nullable=True) + noise_setting = Column(String(2000), nullable=True) random_user_agent = Column(Boolean, nullable=False, default=False, server_default='0') diff --git a/app/models/proxy.py b/app/models/proxy.py index 162cc4e58..7eb99a6df 100644 --- a/app/models/proxy.py +++ b/app/models/proxy.py @@ -190,6 +190,10 @@ def validate_noise(cls, v): raise ValueError( "Noise setting must be like this: packet,delay (rand:10-20,100-200)." ) + if len(v) > 2000: + raise ValueError( + "Noise can't be longer that 2000 character" + ) return v