diff options
| author | pwnnex <eternxles@gmail.com> | 2026-04-22 18:55:27 +0300 |
|---|---|---|
| committer | pwnnex <eternxles@gmail.com> | 2026-04-22 18:55:27 +0300 |
| commit | 17f67ef3a51537cbb32b2fcd3884c26434f4ee62 (patch) | |
| tree | 162690874adadab6ea67c89e3ce25cf1ce47930b /sub | |
| parent | eb4791a1cdabebbf0b0d5a81a40ecc7d88924656 (diff) | |
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/<id> handler the
whole subscription returns 500. Skip malformed entries instead.
Diffstat (limited to 'sub')
| -rw-r--r-- | sub/subService.go | 12 |
1 files 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 { |
