mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-03 08:57:15 +00:00
feat(node): per node outbound routing (#5275)
* feat: add per-node outbound routing for panel-to-node connections * feat(ui): add outbound tag selector to node form with i18n * fix(xray): avoid potential overflow warning in node egress rule allocation * chore: run "npm run gen" * fix --------- Co-authored-by: Sanaei <ho3ein.sanaei@gmail.com>
This commit is contained in:
@@ -434,6 +434,26 @@ func (s *SettingService) PanelEgressProxyURL() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (s *SettingService) NodeEgressProxyURL(nodeID int) string {
|
||||
tag := NodeEgressInboundTag(nodeID)
|
||||
proc := XrayProcess()
|
||||
if proc == nil || !proc.IsRunning() {
|
||||
logger.Warning("node outbound [", tag, "] is set but Xray is not running, using a direct connection")
|
||||
return ""
|
||||
}
|
||||
cfg := proc.GetConfig()
|
||||
if cfg == nil {
|
||||
return ""
|
||||
}
|
||||
for i := range cfg.InboundConfigs {
|
||||
if cfg.InboundConfigs[i].Tag == tag {
|
||||
return fmt.Sprintf("socks5://127.0.0.1:%d", cfg.InboundConfigs[i].Port)
|
||||
}
|
||||
}
|
||||
logger.Warning("node outbound [", tag, "] is set but the egress bridge is not in the running config, using a direct connection")
|
||||
return ""
|
||||
}
|
||||
|
||||
// NewProxiedHTTPClient returns an HTTP client that routes the panel's own
|
||||
// outbound requests through the configured panel outbound (via the loopback
|
||||
// SOCKS bridge in the running Xray). When the feature is off or the bridge
|
||||
|
||||
Reference in New Issue
Block a user