From 17f67ef3a51537cbb32b2fcd3884c26434f4ee62 Mon Sep 17 00:00:00 2001 From: pwnnex Date: Wed, 22 Apr 2026 18:55:27 +0300 Subject: [PATCH] sub: dont panic on bad externalProxy entry in genHysteriaLink The externalProxy fanout from #4073 did `int(ep["port"].(float64))` with no ok-check. If any entry is missing port or has the wrong type it panics, and since this runs in the /sub/ handler the whole subscription returns 500. Skip malformed entries instead. --- sub/subService.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sub/subService.go b/sub/subService.go index 44549390..272bf9d5 100644 --- a/sub/subService.go +++ b/sub/subService.go @@ -987,12 +987,18 @@ func (s *SubService) genHysteriaLink(inbound *model.Inbound, email string) strin if len(externalProxies) > 0 { links := make([]string, 0, len(externalProxies)) for _, externalProxy := range externalProxies { - ep, _ := externalProxy.(map[string]interface{}) + ep, ok := externalProxy.(map[string]interface{}) + if !ok { + continue + } dest, _ := ep["dest"].(string) - epPort := int(ep["port"].(float64)) + portF, okPort := ep["port"].(float64) + if dest == "" || !okPort { + continue + } epRemark, _ := ep["remark"].(string) - link := fmt.Sprintf("%s://%s@%s:%d", protocol, auth, dest, epPort) + link := fmt.Sprintf("%s://%s@%s:%d", protocol, auth, dest, int(portF)) u, _ := url.Parse(link) q := u.Query() for k, v := range params {