diff --git a/app/db/migrations/versions/20241129_a015ed8ce227_add_shadowtls_protocol.py b/app/db/migrations/versions/20241129_a015ed8ce227_add_shadowtls_protocol.py new file mode 100644 index 0000000..748466a --- /dev/null +++ b/app/db/migrations/versions/20241129_a015ed8ce227_add_shadowtls_protocol.py @@ -0,0 +1,38 @@ +"""add shadowtls protocol + +Revision ID: a015ed8ce227 +Revises: be0032100c07 +Create Date: 2024-11-29 21:41:06.896405 + +""" + +from alembic import op + +# revision identifiers, used by Alembic. +revision = "a015ed8ce227" +down_revision = "be0032100c07" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + bind = op.get_bind() + dialect = bind.dialect.name + + if dialect == "postgresql": + op.execute("ALTER TYPE proxytypes ADD VALUE 'ShadowTLS'") + + elif dialect in ("mariadb", "mysql"): + op.execute( + "ALTER TABLE inbounds MODIFY protocol ENUM('VMess', 'VLESS', 'Trojan', 'Shadowsocks', 'Shadowsocks2022', 'Hysteria2', 'WireGuard', 'TUIC', 'ShadowTLS')" + ) + + +def downgrade() -> None: + bind = op.get_bind() + dialect = bind.dialect.name + + if dialect in ("mysql", "mariadb"): + op.execute( + "ALTER TABLE inbounds MODIFY protocol ENUM('VMess', 'VLESS', 'Trojan', 'Shadowsocks', 'Shadowsocks2022', 'Hysteria2', 'WireGuard', 'TUIC')" + ) diff --git a/app/models/proxy.py b/app/models/proxy.py index 8dfee0d..6e67094 100644 --- a/app/models/proxy.py +++ b/app/models/proxy.py @@ -15,6 +15,7 @@ class ProxyTypes(str, Enum): Hysteria2 = "hysteria2" WireGuard = "wireguard" TUIC = "tuic" + ShadowTLS = "shadowtls" class InboundHostSecurity(str, Enum): diff --git a/app/utils/share.py b/app/utils/share.py index ec546a7..1a22f18 100644 --- a/app/utils/share.py +++ b/app/utils/share.py @@ -317,6 +317,7 @@ def generate_user_configs( "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.3" }, shadowsocks_method="chacha20-ietf-poly1305", + shadowtls_version=inbound.get("shadowtls_version"), weight=host.weight, ) if host.fragment: diff --git a/dashboard/src/modules/hosts/dialogs/mutation/profiles/shadowtls/default.ts b/dashboard/src/modules/hosts/dialogs/mutation/profiles/shadowtls/default.ts new file mode 100644 index 0000000..95b4d88 --- /dev/null +++ b/dashboard/src/modules/hosts/dialogs/mutation/profiles/shadowtls/default.ts @@ -0,0 +1,11 @@ +import { ShadowTlsSchemaType } from "./schema"; + +export const shadowTlsProfileDefaultValue: ShadowTlsSchemaType = { + sni: '', + port: 8080, + address: '', + remark: '', + alpn: "", + allowinsecure: false, + is_disabled: false, +}; diff --git a/dashboard/src/modules/hosts/dialogs/mutation/profiles/shadowtls/index.tsx b/dashboard/src/modules/hosts/dialogs/mutation/profiles/shadowtls/index.tsx new file mode 100644 index 0000000..b35dc03 --- /dev/null +++ b/dashboard/src/modules/hosts/dialogs/mutation/profiles/shadowtls/index.tsx @@ -0,0 +1,23 @@ +import { + CommonFields, +} from "../../fields"; +import { + TlsFields +} from "../../sections"; +import { + Accordion, +} from "@marzneshin/common/components"; + +export const ShadowTlsProfileFields = () => { + return ( +
+ + + + +
+ ) +} + +export * from "./schema"; +export * from "./default"; diff --git a/dashboard/src/modules/hosts/dialogs/mutation/profiles/shadowtls/schema.ts b/dashboard/src/modules/hosts/dialogs/mutation/profiles/shadowtls/schema.ts new file mode 100644 index 0000000..e4ab869 --- /dev/null +++ b/dashboard/src/modules/hosts/dialogs/mutation/profiles/shadowtls/schema.ts @@ -0,0 +1,11 @@ +import { z } from "zod"; +import { HostSchema, TlsSchema } from "@marzneshin/modules/hosts"; + +export const ShadowTlsSchema = + HostSchema.merge( + TlsSchema.extend({ + is_disabled: z.boolean(), + })) + ; + +export type ShadowTlsSchemaType = z.infer; diff --git a/dashboard/src/modules/hosts/dialogs/mutation/profiles/use-profile-strategy.ts b/dashboard/src/modules/hosts/dialogs/mutation/profiles/use-profile-strategy.ts index b86e6f0..f146f63 100644 --- a/dashboard/src/modules/hosts/dialogs/mutation/profiles/use-profile-strategy.ts +++ b/dashboard/src/modules/hosts/dialogs/mutation/profiles/use-profile-strategy.ts @@ -3,6 +3,7 @@ import { FC } from "react"; import { GeneralSchema, GeneralProfileFields, generalProfileDefaultValue } from "./general"; import { WireguardSchema, WireguardProfileFields, wireguardProfileDefaultValue } from "./wireguard"; import { Hysteria2Schema, Hysteria2ProfileFields, hysteria2ProfileDefaultValue } from "./hysteria2"; +import { ShadowTlsSchema, ShadowTlsProfileFields, shadowTlsProfileDefaultValue } from "./shadowtls"; import { TuicSchema, TuicProfileFields, tuicProfileDefaultValue } from "./tuic"; type ProfileSchema = typeof GeneralSchema | typeof WireguardSchema | typeof Hysteria2Schema | typeof TuicSchema; @@ -26,6 +27,7 @@ export const useProfileStrategy = ( shadowsocks2022: [GeneralSchema, GeneralProfileFields, generalProfileDefaultValue], wireguard: [WireguardSchema, WireguardProfileFields, wireguardProfileDefaultValue], hysteria2: [Hysteria2Schema, Hysteria2ProfileFields, hysteria2ProfileDefaultValue], + shadowtls: [ShadowTlsSchema, ShadowTlsProfileFields, shadowTlsProfileDefaultValue], tuic: [TuicSchema, TuicProfileFields, tuicProfileDefaultValue], }; diff --git a/dashboard/src/modules/inbounds/types/index.ts b/dashboard/src/modules/inbounds/types/index.ts index a1eb884..f21b015 100644 --- a/dashboard/src/modules/inbounds/types/index.ts +++ b/dashboard/src/modules/inbounds/types/index.ts @@ -5,6 +5,7 @@ export type ProtocolType = | "vless" | "vmess" | "trojan" + | "shadowtls" | "shadowsocks" | "shadowsocks2022" | "hysteria2" diff --git a/requirements.txt b/requirements.txt index 3362eca..d3f5c2b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,7 +23,7 @@ aiohttp==3.10.2 xxhash==3.4.1 grpcio==1.65.4 psycopg==3.1.18 -v2share==0.1.0b24 +v2share==0.1.0b26 PyJWT~=2.8.0 PyNaCl==1.5.0 starlette==0.40.0