-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade transmission option and add alpn to inbound configs (#51)
* Add httpupgrade and other network to inbound config * Fix json error * Add alpn to subscription URL * Improve default values in config.py
- Loading branch information
Showing
11 changed files
with
157 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/migration/alembic/versions/a00786a4da47_add_alpn_and_other_networks_to_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
"""Add alpn and other networks to InboundConfig | ||
Revision ID: a00786a4da47 | ||
Revises: c78517599f01 | ||
Create Date: 2024-11-27 20:50:20.606559 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "a00786a4da47" | ||
down_revision = "c78517599f01" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
# Describing of enum | ||
enum_name = "inboundnetwork" | ||
temp_enum_name = f"temp_{enum_name}" | ||
old_values = ("tcp", "ws", "grpc") | ||
new_values = ("kcp", "http", "httpupgrade", "splithttp", *old_values) | ||
|
||
old_type = sa.Enum(*old_values, name=enum_name) | ||
new_type = sa.Enum(*new_values, name=enum_name) | ||
temp_type = sa.Enum(*new_values, name=temp_enum_name) | ||
|
||
# Describing of table | ||
table_name = "inbound_config" | ||
column_name = "network" | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column( | ||
"inbound_config", sa.Column("alpn", sa.String(length=400), nullable=True) | ||
) | ||
|
||
# temp type to use instead of old one | ||
temp_type.create(op.get_bind(), checkfirst=False) | ||
op.execute("ALTER TABLE inbound_config ALTER COLUMN network DROP DEFAULT") | ||
|
||
# changing of column type from old enum to new one. | ||
# SQLite will create temp table for this | ||
with op.batch_alter_table(table_name) as batch_op: | ||
batch_op.alter_column( | ||
column_name, | ||
existing_type=old_type, | ||
type_=temp_type, | ||
existing_nullable=False, | ||
postgresql_using=f"{column_name}::text::{temp_enum_name}", | ||
) | ||
|
||
# remove old enum, create new enum | ||
old_type.drop(op.get_bind(), checkfirst=False) | ||
new_type.create(op.get_bind(), checkfirst=False) | ||
|
||
# changing of column type from temp enum to new one. | ||
# SQLite will create temp table for this | ||
with op.batch_alter_table(table_name) as batch_op: | ||
batch_op.alter_column( | ||
column_name, | ||
existing_type=temp_type, | ||
type_=new_type, | ||
existing_nullable=False, | ||
postgresql_using=f"{column_name}::text::{enum_name}", | ||
) | ||
|
||
# remove temp enum | ||
temp_type.drop(op.get_bind(), checkfirst=False) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column("inbound_config", "alpn") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,7 @@ def sub( | |
else None | ||
), | ||
remark=remark, | ||
alpns=inbound_config.alpns, | ||
) | ||
rows.append(link) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters