Skip to content

Commit 2ecfca1

Browse files
committed
fix: try to handle transport_settings as dict when loading from database
1 parent 0e69a02 commit 2ecfca1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

app/core/hosts.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from app.db import GetDB
1010
from app.db.crud.host import get_host_by_id, get_hosts, upsert_inbounds
1111
from app.db.models import ProxyHostSecurity
12-
from app.models.host import BaseHost
12+
from app.models.host import BaseHost, TransportSettings
1313
from app.models.subscription import (
1414
GRPCTransportConfig,
1515
KCPTransportConfig,
@@ -36,6 +36,9 @@ async def _prepare_subscription_inbound_data(
3636
protocol = inbound_config["protocol"]
3737

3838
ts = host.transport_settings
39+
if isinstance(ts, dict):
40+
ts = TransportSettings.model_validate(ts) if ts else None
41+
3942
network = inbound_config.get("network", "tcp")
4043
path = host.path or inbound_config.get("path", "")
4144

@@ -254,7 +257,9 @@ async def _prepare_host_entry(
254257
and (ds_host := host.transport_settings.xhttp_settings.download_settings)
255258
):
256259
downstream = await get_host_by_id(db, ds_host)
257-
downstream_data: SubscriptionInboundData = await _prepare_subscription_inbound_data(downstream)
260+
if downstream:
261+
downstream_base = BaseHost.model_validate(downstream)
262+
downstream_data: SubscriptionInboundData = await _prepare_subscription_inbound_data(downstream_base)
258263
subscription_data = await _prepare_subscription_inbound_data(host, downstream_data)
259264

260265
# Return subscription data directly

0 commit comments

Comments
 (0)