|
|
@ -216,8 +216,8 @@ namespace ServiceLib.Services.CoreConfig |
|
|
|
|
|
|
|
|
|
|
|
ret.Msg = ResUI.InitialConfiguration; |
|
|
|
ret.Msg = ResUI.InitialConfiguration; |
|
|
|
|
|
|
|
|
|
|
|
string result = Utils.GetEmbedText(Global.V2raySampleClient); |
|
|
|
var result = Utils.GetEmbedText(Global.V2raySampleClient); |
|
|
|
string txtOutbound = Utils.GetEmbedText(Global.V2raySampleOutbound); |
|
|
|
var txtOutbound = Utils.GetEmbedText(Global.V2raySampleOutbound); |
|
|
|
if (Utils.IsNullOrEmpty(result) || txtOutbound.IsNullOrEmpty()) |
|
|
|
if (Utils.IsNullOrEmpty(result) || txtOutbound.IsNullOrEmpty()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ret.Msg = ResUI.FailedGetDefaultConfiguration; |
|
|
|
ret.Msg = ResUI.FailedGetDefaultConfiguration; |
|
|
@ -244,10 +244,11 @@ namespace ServiceLib.Services.CoreConfig |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await GenLog(v2rayConfig); |
|
|
|
await GenLog(v2rayConfig); |
|
|
|
v2rayConfig.inbounds.Clear(); // Remove "proxy" service for speedtest, avoiding port conflicts. |
|
|
|
v2rayConfig.inbounds.Clear(); |
|
|
|
v2rayConfig.outbounds.RemoveAt(0); |
|
|
|
v2rayConfig.outbounds.Clear(); |
|
|
|
|
|
|
|
v2rayConfig.routing.rules.Clear(); |
|
|
|
|
|
|
|
|
|
|
|
int httpPort = AppHandler.Instance.GetLocalPort(EInboundProtocol.speedtest); |
|
|
|
var httpPort = AppHandler.Instance.GetLocalPort(EInboundProtocol.speedtest); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var it in selecteds) |
|
|
|
foreach (var it in selecteds) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -270,7 +271,7 @@ namespace ServiceLib.Services.CoreConfig |
|
|
|
|
|
|
|
|
|
|
|
//find unused port |
|
|
|
//find unused port |
|
|
|
var port = httpPort; |
|
|
|
var port = httpPort; |
|
|
|
for (int k = httpPort; k < Global.MaxPort; k++) |
|
|
|
for (var k = httpPort; k < Global.MaxPort; k++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (lstIpEndPoints?.FindIndex(_it => _it.Port == k) >= 0) |
|
|
|
if (lstIpEndPoints?.FindIndex(_it => _it.Port == k) >= 0) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -294,16 +295,6 @@ namespace ServiceLib.Services.CoreConfig |
|
|
|
it.Port = port; |
|
|
|
it.Port = port; |
|
|
|
it.AllowTest = true; |
|
|
|
it.AllowTest = true; |
|
|
|
|
|
|
|
|
|
|
|
//inbound |
|
|
|
|
|
|
|
Inbounds4Ray inbound = new() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
listen = Global.Loopback, |
|
|
|
|
|
|
|
port = port, |
|
|
|
|
|
|
|
protocol = EInboundProtocol.http.ToString(), |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
inbound.tag = inbound.protocol + inbound.port.ToString(); |
|
|
|
|
|
|
|
v2rayConfig.inbounds.Add(inbound); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//outbound |
|
|
|
//outbound |
|
|
|
if (item is null) |
|
|
|
if (item is null) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -326,6 +317,16 @@ namespace ServiceLib.Services.CoreConfig |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//inbound |
|
|
|
|
|
|
|
Inbounds4Ray inbound = new() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
listen = Global.Loopback, |
|
|
|
|
|
|
|
port = port, |
|
|
|
|
|
|
|
protocol = EInboundProtocol.http.ToString(), |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
inbound.tag = inbound.protocol + inbound.port.ToString(); |
|
|
|
|
|
|
|
v2rayConfig.inbounds.Add(inbound); |
|
|
|
|
|
|
|
|
|
|
|
var outbound = JsonUtils.Deserialize<Outbounds4Ray>(txtOutbound); |
|
|
|
var outbound = JsonUtils.Deserialize<Outbounds4Ray>(txtOutbound); |
|
|
|
await GenOutbound(item, outbound); |
|
|
|
await GenOutbound(item, outbound); |
|
|
|
outbound.tag = Global.ProxyTag + inbound.port.ToString(); |
|
|
|
outbound.tag = Global.ProxyTag + inbound.port.ToString(); |
|
|
|