mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-04-26 01:15:57 +00:00
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.
This commit is contained in:
parent
eb4791a1cd
commit
17f67ef3a5
1 changed files with 9 additions and 3 deletions
|
|
@ -987,12 +987,18 @@ func (s *SubService) genHysteriaLink(inbound *model.Inbound, email string) strin
|
||||||
if len(externalProxies) > 0 {
|
if len(externalProxies) > 0 {
|
||||||
links := make([]string, 0, len(externalProxies))
|
links := make([]string, 0, len(externalProxies))
|
||||||
for _, externalProxy := range externalProxies {
|
for _, externalProxy := range externalProxies {
|
||||||
ep, _ := externalProxy.(map[string]interface{})
|
ep, ok := externalProxy.(map[string]interface{})
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
dest, _ := ep["dest"].(string)
|
dest, _ := ep["dest"].(string)
|
||||||
epPort := int(ep["port"].(float64))
|
portF, okPort := ep["port"].(float64)
|
||||||
|
if dest == "" || !okPort {
|
||||||
|
continue
|
||||||
|
}
|
||||||
epRemark, _ := ep["remark"].(string)
|
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)
|
u, _ := url.Parse(link)
|
||||||
q := u.Query()
|
q := u.Query()
|
||||||
for k, v := range params {
|
for k, v := range params {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue