mirror of
https://github.com/2dust/v2rayN.git
synced 2026-02-28 21:23:04 +00:00
Compare commits
4 commits
7a70f630ad
...
e1dc2287f7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1dc2287f7 | ||
|
|
c76c302e44 | ||
|
|
a9cd6394d0 | ||
|
|
3a5293bf87 |
5 changed files with 51 additions and 34 deletions
|
|
@ -1251,6 +1251,47 @@ public static class ConfigHandler
|
||||||
return itemSocks;
|
return itemSocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CoreConfigContext? GetPreSocksCoreConfigContext(CoreConfigContext nodeContext)
|
||||||
|
{
|
||||||
|
var config = nodeContext.AppConfig;
|
||||||
|
var node = nodeContext.Node;
|
||||||
|
var coreType = AppManager.Instance.GetCoreType(node, node.ConfigType);
|
||||||
|
|
||||||
|
var preSocksItem = GetPreSocksItem(config, node, coreType);
|
||||||
|
if (preSocksItem != null)
|
||||||
|
{
|
||||||
|
return nodeContext with { Node = preSocksItem, };
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((!nodeContext.IsTunEnabled)
|
||||||
|
|| coreType != ECoreType.Xray
|
||||||
|
|| node.ConfigType == EConfigType.Custom)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var tunProtectSsPort = Utils.GetFreePort();
|
||||||
|
var proxyRelaySsPort = Utils.GetFreePort();
|
||||||
|
var preItem = new ProfileItem()
|
||||||
|
{
|
||||||
|
CoreType = ECoreType.sing_box,
|
||||||
|
ConfigType = EConfigType.Shadowsocks,
|
||||||
|
Address = Global.Loopback,
|
||||||
|
Port = proxyRelaySsPort,
|
||||||
|
Password = Global.None,
|
||||||
|
};
|
||||||
|
preItem.SetProtocolExtra(preItem.GetProtocolExtra() with
|
||||||
|
{
|
||||||
|
SsMethod = Global.None,
|
||||||
|
});
|
||||||
|
var preContext = nodeContext with
|
||||||
|
{
|
||||||
|
Node = preItem,
|
||||||
|
TunProtectSsPort = tunProtectSsPort,
|
||||||
|
ProxyRelaySsPort = proxyRelaySsPort,
|
||||||
|
};
|
||||||
|
return preContext;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove servers with invalid test results (timeout)
|
/// Remove servers with invalid test results (timeout)
|
||||||
/// Useful for cleaning up subscription lists
|
/// Useful for cleaning up subscription lists
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public class Hysteria2Fmt : BaseFmt
|
||||||
if (!item.CertSha.IsNullOrEmpty())
|
if (!item.CertSha.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
var sha = item.CertSha;
|
var sha = item.CertSha;
|
||||||
var idx = sha.IndexOf('~');
|
var idx = sha.IndexOf(',');
|
||||||
if (idx > 0)
|
if (idx > 0)
|
||||||
{
|
{
|
||||||
sha = sha[..idx];
|
sha = sha[..idx];
|
||||||
|
|
|
||||||
|
|
@ -67,37 +67,13 @@ public class CoreManager
|
||||||
|
|
||||||
var fileName = Utils.GetBinConfigPath(Global.CoreConfigFileName);
|
var fileName = Utils.GetBinConfigPath(Global.CoreConfigFileName);
|
||||||
var context = await CoreConfigHandler.BuildCoreConfigContext(_config, node);
|
var context = await CoreConfigHandler.BuildCoreConfigContext(_config, node);
|
||||||
CoreConfigContext? preContext = null;
|
var preContext = ConfigHandler.GetPreSocksCoreConfigContext(context);
|
||||||
if (context.IsTunEnabled)
|
if (preContext is not null)
|
||||||
{
|
{
|
||||||
var coreType = AppManager.Instance.GetCoreType(node, node.ConfigType);
|
context = context with
|
||||||
if (coreType == ECoreType.Xray && node.ConfigType != EConfigType.Custom)
|
|
||||||
{
|
{
|
||||||
var tunProtectSsPort = Utils.GetFreePort();
|
TunProtectSsPort = preContext.TunProtectSsPort, ProxyRelaySsPort = preContext.ProxyRelaySsPort,
|
||||||
var proxyRelaySsPort = Utils.GetFreePort();
|
};
|
||||||
context = context with { TunProtectSsPort = tunProtectSsPort, ProxyRelaySsPort = proxyRelaySsPort, };
|
|
||||||
var preItem = new ProfileItem()
|
|
||||||
{
|
|
||||||
CoreType = ECoreType.sing_box,
|
|
||||||
ConfigType = EConfigType.Shadowsocks,
|
|
||||||
Address = Global.Loopback,
|
|
||||||
Port = proxyRelaySsPort,
|
|
||||||
Password = Global.None,
|
|
||||||
};
|
|
||||||
preItem.SetProtocolExtra(preItem.GetProtocolExtra() with
|
|
||||||
{
|
|
||||||
SsMethod = Global.None,
|
|
||||||
});
|
|
||||||
preContext = context with { Node = preItem, };
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var preItem = ConfigHandler.GetPreSocksItem(_config, node, coreType);
|
|
||||||
if (preItem is not null)
|
|
||||||
{
|
|
||||||
preContext = context with { Node = preItem, };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var result = await CoreConfigHandler.GenerateClientConfig(context, fileName);
|
var result = await CoreConfigHandler.GenerateClientConfig(context, fileName);
|
||||||
if (result.Success != true)
|
if (result.Success != true)
|
||||||
|
|
|
||||||
|
|
@ -305,7 +305,7 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
||||||
|
|
||||||
var protectNode = new ProfileItem()
|
var protectNode = new ProfileItem()
|
||||||
{
|
{
|
||||||
CoreType = ECoreType.sing_box,
|
CoreType = ECoreType.Xray,
|
||||||
ConfigType = EConfigType.Shadowsocks,
|
ConfigType = EConfigType.Shadowsocks,
|
||||||
Address = Global.Loopback,
|
Address = Global.Loopback,
|
||||||
Port = context.TunProtectSsPort,
|
Port = context.TunProtectSsPort,
|
||||||
|
|
@ -334,7 +334,7 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
||||||
{
|
{
|
||||||
inboundTag = new List<string> { "proxy-relay-ss" },
|
inboundTag = new List<string> { "proxy-relay-ss" },
|
||||||
outboundTag = hasBalancer ? null : Global.ProxyTag,
|
outboundTag = hasBalancer ? null : Global.ProxyTag,
|
||||||
balancerTag = hasBalancer ? Global.ProxyTag : null,
|
balancerTag = hasBalancer ? Global.ProxyTag + Global.BalancerTagSuffix: null,
|
||||||
type = "field"
|
type = "field"
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<string> shaList = new();
|
List<string> shaList = [];
|
||||||
foreach (var cert in certList)
|
foreach (var cert in certList)
|
||||||
{
|
{
|
||||||
var sha = CertPemManager.GetCertSha256Thumbprint(cert);
|
var sha = CertPemManager.GetCertSha256Thumbprint(cert);
|
||||||
|
|
@ -228,7 +228,7 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
shaList.Add(sha);
|
shaList.Add(sha);
|
||||||
}
|
}
|
||||||
CertSha = string.Join('~', shaList);
|
CertSha = string.Join(',', shaList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task FetchCert()
|
private async Task FetchCert()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue