mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-08 21:45:01 +03:00
Metrics listen directly (#9533)
This commit is contained in:
@@ -20,7 +20,7 @@ public class Stats4Ray
|
|||||||
|
|
||||||
public class Metrics4Ray
|
public class Metrics4Ray
|
||||||
{
|
{
|
||||||
public string tag { get; set; }
|
public string listen { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Policy4Ray
|
public class Policy4Ray
|
||||||
|
|||||||
@@ -17,14 +17,6 @@
|
|||||||
],
|
],
|
||||||
"routing": {
|
"routing": {
|
||||||
"domainStrategy": "IPIfNonMatch",
|
"domainStrategy": "IPIfNonMatch",
|
||||||
"rules": [
|
"rules": []
|
||||||
{
|
|
||||||
"inboundTag": [
|
|
||||||
"api"
|
|
||||||
],
|
|
||||||
"outboundTag": "api",
|
|
||||||
"type": "field"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,45 +6,19 @@ public partial class CoreConfigV2rayService
|
|||||||
{
|
{
|
||||||
if (_config.GuiItem.EnableStatistics || _config.GuiItem.DisplayRealTimeSpeed)
|
if (_config.GuiItem.EnableStatistics || _config.GuiItem.DisplayRealTimeSpeed)
|
||||||
{
|
{
|
||||||
const string tag = nameof(EInboundProtocol.api);
|
Metrics4Ray metricsObj = new();
|
||||||
Metrics4Ray apiObj = new();
|
|
||||||
Policy4Ray policyObj = new();
|
Policy4Ray policyObj = new();
|
||||||
SystemPolicy4Ray policySystemSetting = new();
|
SystemPolicy4Ray policySystemSetting = new();
|
||||||
|
|
||||||
_coreConfig.stats = new Stats4Ray();
|
_coreConfig.stats = new Stats4Ray();
|
||||||
|
|
||||||
apiObj.tag = tag;
|
metricsObj.listen = $"{Global.Loopback}:{AppManager.Instance.StatePort}";
|
||||||
_coreConfig.metrics = apiObj;
|
_coreConfig.metrics = metricsObj;
|
||||||
|
|
||||||
policySystemSetting.statsOutboundDownlink = true;
|
policySystemSetting.statsOutboundDownlink = true;
|
||||||
policySystemSetting.statsOutboundUplink = true;
|
policySystemSetting.statsOutboundUplink = true;
|
||||||
policyObj.system = policySystemSetting;
|
policyObj.system = policySystemSetting;
|
||||||
_coreConfig.policy = policyObj;
|
_coreConfig.policy = policyObj;
|
||||||
|
|
||||||
if (!_coreConfig.inbounds.Exists(item => item.tag == tag))
|
|
||||||
{
|
|
||||||
Inbounds4Ray apiInbound = new();
|
|
||||||
Inboundsettings4Ray apiInboundSettings = new();
|
|
||||||
apiInbound.tag = tag;
|
|
||||||
apiInbound.listen = Global.Loopback;
|
|
||||||
apiInbound.port = AppManager.Instance.StatePort;
|
|
||||||
apiInbound.protocol = Global.InboundAPIProtocol;
|
|
||||||
apiInboundSettings.address = Global.Loopback;
|
|
||||||
apiInbound.settings = apiInboundSettings;
|
|
||||||
_coreConfig.inbounds.Add(apiInbound);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_coreConfig.routing.rules.Exists(item => item.outboundTag == tag))
|
|
||||||
{
|
|
||||||
RulesItem4Ray apiRoutingRule = new()
|
|
||||||
{
|
|
||||||
inboundTag = new List<string> { tag },
|
|
||||||
outboundTag = tag,
|
|
||||||
type = "field"
|
|
||||||
};
|
|
||||||
|
|
||||||
_coreConfig.routing.rules.Add(apiRoutingRule);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user