mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-24 03:47:15 +00:00
feat(sub): per-client external links and remote subscriptions
Add a Links tab to the client form for attaching third-party share links and remote subscription URLs per client. They are merged into the client's raw/JSON/Clash subscription output: links are emitted verbatim and parsed for JSON/Clash; subscription URLs are fetched (cached, with a short timeout) and their configs merged in. i18n keys added across all 13 locales.
This commit is contained in:
@@ -25,9 +25,16 @@ func (s *SubClashService) GetClash(subId string, host string) (string, string, e
|
||||
// Set per-request state so resolveInboundAddress sees the node map.
|
||||
s.SubService.PrepareForRequest(host)
|
||||
inbounds, err := s.SubService.getInboundsBySubId(subId)
|
||||
if err != nil || len(inbounds) == 0 {
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
externalLinks, err := s.SubService.getClientExternalLinksBySubId(subId)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
if len(inbounds) == 0 && len(externalLinks) == 0 {
|
||||
return "", "", nil
|
||||
}
|
||||
|
||||
var proxies []map[string]any
|
||||
|
||||
@@ -43,6 +50,18 @@ func (s *SubClashService) GetClash(subId string, host string) (string, string, e
|
||||
proxies = append(proxies, s.getProxies(inbound, client, host)...)
|
||||
}
|
||||
}
|
||||
for _, ext := range externalLinks {
|
||||
for _, el := range expandEntry(ext) {
|
||||
name := el.Name
|
||||
if name == "" {
|
||||
name = ext.Email
|
||||
}
|
||||
if proxy := s.clashProxyFromExternal(el.Link, name); proxy != nil {
|
||||
seenEmails[ext.Email] = struct{}{}
|
||||
proxies = append(proxies, proxy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(proxies) == 0 {
|
||||
return "", "", nil
|
||||
|
||||
Reference in New Issue
Block a user