Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 60a75d9
Author: 2dust <31833384+2dust@users.noreply.github.com>
Date:   Mon Sep 23 17:23:23 2024 +0800

    up 6.60

commit 2456690
Author: 2dust <31833384+2dust@users.noreply.github.com>
Date:   Mon Sep 23 17:22:14 2024 +0800

    up PackageReference

commit cc42861
Author: 2dust <31833384+2dust@users.noreply.github.com>
Date:   Mon Sep 23 17:17:12 2024 +0800

    Adjusting the text display

commit 4d330ce
Author: 2dust <31833384+2dust@users.noreply.github.com>
Date:   Mon Sep 23 17:05:03 2024 +0800

    Disable auto update geo

commit 2503583
Author: 2dust <31833384+2dust@users.noreply.github.com>
Date:   Mon Sep 23 17:03:28 2024 +0800

    System proxy and tun mode

    2dust#5651

commit 1b11916
Author: 2dust <31833384+2dust@users.noreply.github.com>
Date:   Mon Sep 23 15:16:32 2024 +0800

    Preparing to remove part of the core

    2dust#5703

commit 3dfd557
Author: 2dust <31833384+2dust@users.noreply.github.com>
Date:   Mon Sep 23 15:00:25 2024 +0800

    Fix the problem of showing and hiding statistics columns

commit cd6bea2
Author: 2dust <31833384+2dust@users.noreply.github.com>
Date:   Mon Sep 23 14:10:58 2024 +0800

    Improved font display

    2dust#5713

commit 054f0f2
Author: 2dust <31833384+2dust@users.noreply.github.com>
Date:   Mon Sep 23 13:37:18 2024 +0800

    Bug fix

    2dust#5725

commit 9734767
Author: 2dust <31833384+2dust@users.noreply.github.com>
Date:   Mon Sep 23 12:09:17 2024 +0800

    Bug fix

    2dust#5724

commit 36d1585
Author: 2dust <31833384+2dust@users.noreply.github.com>
Date:   Mon Sep 23 11:04:37 2024 +0800

    Setting up not to automatically update the GEO file on first run

    2dust#5704

commit 4813610
Author: 2dust <31833384+2dust@users.noreply.github.com>
Date:   Mon Sep 23 11:01:03 2024 +0800

    When running for the first time, switch the interface language to English when judging that the system language is not Chinese.

    2dust#5670
  • Loading branch information
lowercase78 committed Sep 23, 2024
1 parent 8f58f56 commit b5fa1f9
Show file tree
Hide file tree
Showing 53 changed files with 213 additions and 204 deletions.
4 changes: 2 additions & 2 deletions v2rayN/ProtosLib/ProtosLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.28.1" />
<PackageReference Include="Grpc.Net.Client" Version="2.65.0" />
<PackageReference Include="Google.Protobuf" Version="3.28.2" />
<PackageReference Include="Grpc.Net.Client" Version="2.66.0" />
<PackageReference Include="Grpc.Tools" Version="2.66.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
8 changes: 4 additions & 4 deletions v2rayN/ServiceLib/Enums/EConfigType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ public enum EConfigType
VMess = 1,
Custom = 2,
Shadowsocks = 3,
Socks = 4,
SOCKS = 4,
VLESS = 5,
Trojan = 6,
Hysteria2 = 7,
Tuic = 8,
Wireguard = 9,
Http = 10
TUIC = 8,
WireGuard = 9,
HTTP = 10
}
}
16 changes: 8 additions & 8 deletions v2rayN/ServiceLib/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,25 @@ public class Global
{
{EConfigType.VMess,"vmess://"},
{EConfigType.Shadowsocks,"ss://"},
{EConfigType.Socks,"socks://"},
{EConfigType.SOCKS,"socks://"},
{EConfigType.VLESS,"vless://"},
{EConfigType.Trojan,"trojan://"},
{EConfigType.Hysteria2,"hysteria2://"},
{EConfigType.Tuic,"tuic://"},
{EConfigType.Wireguard,"wireguard://"}
{EConfigType.TUIC,"tuic://"},
{EConfigType.WireGuard,"wireguard://"}
};

public static readonly Dictionary<EConfigType, string> ProtocolTypes = new()
{
{EConfigType.VMess,"vmess"},
{EConfigType.Shadowsocks,"shadowsocks"},
{EConfigType.Socks,"socks"},
{EConfigType.Http,"http"},
{EConfigType.SOCKS,"socks"},
{EConfigType.HTTP,"http"},
{EConfigType.VLESS,"vless"},
{EConfigType.Trojan,"trojan"},
{EConfigType.Hysteria2,"hysteria2"},
{EConfigType.Tuic,"tuic"},
{EConfigType.Wireguard,"wireguard"}
{EConfigType.TUIC,"tuic"},
{EConfigType.WireGuard,"wireguard"}
};

public static readonly List<string> VmessSecurities = new() { "aes-128-gcm", "chacha20-poly1305", "auto", "none", "zero" };
Expand All @@ -165,7 +165,7 @@ public class Global
public static readonly List<string> Flows = new() { "", "xtls-rprx-vision", "xtls-rprx-vision-udp443" };
public static readonly List<string> Networks = new() { "tcp", "kcp", "ws", "httpupgrade", "splithttp", "h2", "quic", "grpc" };
public static readonly List<string> KcpHeaderTypes = new() { "srtp", "utp", "wechat-video", "dtls", "wireguard" };
public static readonly List<string> CoreTypes = new() { "v2fly", "SagerNet", "Xray", "sing_box" };
public static readonly List<string> CoreTypes = new() { "v2fly", "Xray", "sing_box" };//TODO
public static readonly List<string> CoreTypes4VLESS = new() { "Xray", "sing_box" };
public static readonly List<string> DomainStrategies = new() { "AsIs", "IPIfNonMatch", "IPOnDemand" };
public static readonly List<string> DomainStrategies4Singbox = new() { "ipv4_only", "ipv6_only", "prefer_ipv4", "prefer_ipv6", "" };
Expand Down
31 changes: 19 additions & 12 deletions v2rayN/ServiceLib/Handler/ConfigHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,14 @@ public static int LoadConfig(ref Config? config)
}
if (Utils.IsNullOrEmpty(config.uiItem.currentLanguage))
{
config.uiItem.currentLanguage = Global.Languages[2];
if (Thread.CurrentThread.CurrentCulture.Name.Equals("zh-cn", StringComparison.CurrentCultureIgnoreCase))
{
config.uiItem.currentLanguage = Global.Languages[0];
}
else
{
config.uiItem.currentLanguage = Global.Languages[2];
}
}

if (config.constItem == null)
Expand Down Expand Up @@ -394,13 +401,13 @@ public static int AddServer(Config config, ProfileItem profileItem)
{
EConfigType.VMess => AddVMessServer(config, item),
EConfigType.Shadowsocks => AddShadowsocksServer(config, item),
EConfigType.Socks => AddSocksServer(config, item),
EConfigType.Http => AddHttpServer(config, item),
EConfigType.SOCKS => AddSocksServer(config, item),
EConfigType.HTTP => AddHttpServer(config, item),
EConfigType.Trojan => AddTrojanServer(config, item),
EConfigType.VLESS => AddVlessServer(config, item),
EConfigType.Hysteria2 => AddHysteria2Server(config, item),
EConfigType.Tuic => AddTuicServer(config, item),
EConfigType.Wireguard => AddWireguardServer(config, item),
EConfigType.TUIC => AddTuicServer(config, item),
EConfigType.WireGuard => AddWireguardServer(config, item),
_ => -1,
};
return ret;
Expand Down Expand Up @@ -732,7 +739,7 @@ public static int AddShadowsocksServer(Config config, ProfileItem profileItem, b
/// <returns></returns>
public static int AddSocksServer(Config config, ProfileItem profileItem, bool toFile = true)
{
profileItem.configType = EConfigType.Socks;
profileItem.configType = EConfigType.SOCKS;

profileItem.address = profileItem.address.TrimEx();

Expand All @@ -749,7 +756,7 @@ public static int AddSocksServer(Config config, ProfileItem profileItem, bool to
/// <returns></returns>
public static int AddHttpServer(Config config, ProfileItem profileItem, bool toFile = true)
{
profileItem.configType = EConfigType.Http;
profileItem.configType = EConfigType.HTTP;

profileItem.address = profileItem.address.TrimEx();

Expand Down Expand Up @@ -822,7 +829,7 @@ public static int AddHysteria2Server(Config config, ProfileItem profileItem, boo
/// <returns></returns>
public static int AddTuicServer(Config config, ProfileItem profileItem, bool toFile = true)
{
profileItem.configType = EConfigType.Tuic;
profileItem.configType = EConfigType.TUIC;
profileItem.coreType = ECoreType.sing_box;

profileItem.address = profileItem.address.TrimEx();
Expand Down Expand Up @@ -861,7 +868,7 @@ public static int AddTuicServer(Config config, ProfileItem profileItem, bool toF
/// <returns></returns>
public static int AddWireguardServer(Config config, ProfileItem profileItem, bool toFile = true)
{
profileItem.configType = EConfigType.Wireguard;
profileItem.configType = EConfigType.WireGuard;
profileItem.coreType = ECoreType.sing_box;

profileItem.address = profileItem.address.TrimEx();
Expand Down Expand Up @@ -1256,12 +1263,12 @@ private static int AddBatchServers(Config config, string strData, string subid,
{
EConfigType.VMess => AddVMessServer(config, profileItem, false),
EConfigType.Shadowsocks => AddShadowsocksServer(config, profileItem, false),
EConfigType.Socks => AddSocksServer(config, profileItem, false),
EConfigType.SOCKS => AddSocksServer(config, profileItem, false),
EConfigType.Trojan => AddTrojanServer(config, profileItem, false),
EConfigType.VLESS => AddVlessServer(config, profileItem, false),
EConfigType.Hysteria2 => AddHysteria2Server(config, profileItem, false),
EConfigType.Tuic => AddTuicServer(config, profileItem, false),
EConfigType.Wireguard => AddWireguardServer(config, profileItem, false),
EConfigType.TUIC => AddTuicServer(config, profileItem, false),
EConfigType.WireGuard => AddWireguardServer(config, profileItem, false),
_ => -1,
};

Expand Down
10 changes: 5 additions & 5 deletions v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigSingbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ private int GenOutbound(ProfileItem node, Outbound4Sbox outbound)
GenOutboundMux(node, outbound);
break;
}
case EConfigType.Socks:
case EConfigType.SOCKS:
{
outbound.version = "5";
if (Utils.IsNotEmpty(node.security)
Expand All @@ -617,7 +617,7 @@ private int GenOutbound(ProfileItem node, Outbound4Sbox outbound)
}
break;
}
case EConfigType.Http:
case EConfigType.HTTP:
{
if (Utils.IsNotEmpty(node.security)
&& Utils.IsNotEmpty(node.id))
Expand Down Expand Up @@ -667,14 +667,14 @@ private int GenOutbound(ProfileItem node, Outbound4Sbox outbound)
outbound.down_mbps = _config.hysteriaItem.down_mbps > 0 ? _config.hysteriaItem.down_mbps : null;
break;
}
case EConfigType.Tuic:
case EConfigType.TUIC:
{
outbound.uuid = node.id;
outbound.password = node.security;
outbound.congestion_control = node.headerType;
break;
}
case EConfigType.Wireguard:
case EConfigType.WireGuard:
{
outbound.private_key = node.id;
outbound.peer_public_key = node.publicKey;
Expand Down Expand Up @@ -1240,7 +1240,7 @@ private int GenDnsDomains(ProfileItem? node, SingboxConfig singboxConfig, DNSIte
}

//Tun2SocksAddress
if (_config.tunModeItem.enableTun && node?.configType == EConfigType.Socks && Utils.IsDomain(node?.sni))
if (_config.tunModeItem.enableTun && node?.configType == EConfigType.SOCKS && Utils.IsDomain(node?.sni))
{
dns4Sbox.rules.Insert(0, new()
{
Expand Down
14 changes: 7 additions & 7 deletions v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigV2ray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public int GenerateClientMultipleLoadConfig(List<ProfileItem> selecteds, out V2r
{
continue;
}
if (it.configType is EConfigType.Hysteria2 or EConfigType.Tuic or EConfigType.Wireguard)
if (it.configType is EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.WireGuard)
{
continue;
}
Expand Down Expand Up @@ -647,8 +647,8 @@ private int GenOutbound(ProfileItem node, Outbounds4Ray outbound)
outbound.settings.vnext = null;
break;
}
case EConfigType.Socks:
case EConfigType.Http:
case EConfigType.SOCKS:
case EConfigType.HTTP:
{
ServersItem4Ray serversItem;
if (outbound.settings.servers.Count <= 0)
Expand Down Expand Up @@ -1208,8 +1208,8 @@ private int GenMoreOutbounds(ProfileItem node, V2rayConfig v2rayConfig)
if (prevNode is not null
&& prevNode.configType != EConfigType.Custom
&& prevNode.configType != EConfigType.Hysteria2
&& prevNode.configType != EConfigType.Tuic
&& prevNode.configType != EConfigType.Wireguard)
&& prevNode.configType != EConfigType.TUIC
&& prevNode.configType != EConfigType.WireGuard)
{
var prevOutbound = JsonUtils.Deserialize<Outbounds4Ray>(txtOutbound);
GenOutbound(prevNode, prevOutbound);
Expand All @@ -1227,8 +1227,8 @@ private int GenMoreOutbounds(ProfileItem node, V2rayConfig v2rayConfig)
if (nextNode is not null
&& nextNode.configType != EConfigType.Custom
&& nextNode.configType != EConfigType.Hysteria2
&& nextNode.configType != EConfigType.Tuic
&& nextNode.configType != EConfigType.Wireguard)
&& nextNode.configType != EConfigType.TUIC
&& nextNode.configType != EConfigType.WireGuard)
{
var nextOutbound = JsonUtils.Deserialize<Outbounds4Ray>(txtOutbound);
GenOutbound(nextNode, nextOutbound);
Expand Down
6 changes: 3 additions & 3 deletions v2rayN/ServiceLib/Handler/CoreHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void LoadCore(ProfileItem? node)
public int LoadCoreConfigSpeedtest(List<ServerTestItem> selecteds)
{
int pid = -1;
var coreType = selecteds.Exists(t => t.configType == EConfigType.Hysteria2 || t.configType == EConfigType.Tuic || t.configType == EConfigType.Wireguard) ? ECoreType.sing_box : ECoreType.Xray;
var coreType = selecteds.Exists(t => t.configType == EConfigType.Hysteria2 || t.configType == EConfigType.TUIC || t.configType == EConfigType.WireGuard) ? ECoreType.sing_box : ECoreType.Xray;
string configPath = Utils.GetConfigPath(Global.CoreSpeedtestConfigFileName);
if (CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType, out string msg) != 0)
{
Expand Down Expand Up @@ -204,7 +204,7 @@ private void CoreStart(ProfileItem node)
itemSocks = new ProfileItem()
{
coreType = preCoreType,
configType = EConfigType.Socks,
configType = EConfigType.SOCKS,
address = Global.Loopback,
sni = node.address, //Tun2SocksAddress
port = LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks)
Expand All @@ -216,7 +216,7 @@ private void CoreStart(ProfileItem node)
itemSocks = new ProfileItem()
{
coreType = preCoreType,
configType = EConfigType.Socks,
configType = EConfigType.SOCKS,
address = Global.Loopback,
port = node.preSocksPort.Value,
};
Expand Down
12 changes: 6 additions & 6 deletions v2rayN/ServiceLib/Handler/Fmt/FmtHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ public class FmtHandler
{
EConfigType.VMess => VmessFmt.ToUri(item),
EConfigType.Shadowsocks => ShadowsocksFmt.ToUri(item),
EConfigType.Socks => SocksFmt.ToUri(item),
EConfigType.SOCKS => SocksFmt.ToUri(item),
EConfigType.Trojan => TrojanFmt.ToUri(item),
EConfigType.VLESS => VLESSFmt.ToUri(item),
EConfigType.Hysteria2 => Hysteria2Fmt.ToUri(item),
EConfigType.Tuic => TuicFmt.ToUri(item),
EConfigType.Wireguard => WireguardFmt.ToUri(item),
EConfigType.TUIC => TuicFmt.ToUri(item),
EConfigType.WireGuard => WireguardFmt.ToUri(item),
_ => null,
};

Expand Down Expand Up @@ -49,7 +49,7 @@ public class FmtHandler
{
return ShadowsocksFmt.Resolve(str, out msg);
}
else if (str.StartsWith(Global.ProtocolShares[EConfigType.Socks]))
else if (str.StartsWith(Global.ProtocolShares[EConfigType.SOCKS]))
{
return SocksFmt.Resolve(str, out msg);
}
Expand All @@ -65,11 +65,11 @@ public class FmtHandler
{
return Hysteria2Fmt.Resolve(str, out msg);
}
else if (str.StartsWith(Global.ProtocolShares[EConfigType.Tuic]))
else if (str.StartsWith(Global.ProtocolShares[EConfigType.TUIC]))
{
return TuicFmt.Resolve(str, out msg);
}
else if (str.StartsWith(Global.ProtocolShares[EConfigType.Wireguard]))
else if (str.StartsWith(Global.ProtocolShares[EConfigType.WireGuard]))
{
return WireguardFmt.Resolve(str, out msg);
}
Expand Down
8 changes: 4 additions & 4 deletions v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class SocksFmt : BaseFmt
return null;
}

item.configType = EConfigType.Socks;
item.configType = EConfigType.SOCKS;

return item;
}
Expand All @@ -41,17 +41,17 @@ public class SocksFmt : BaseFmt
//new
var pw = Utils.Base64Encode($"{item.security}:{item.id}");
url = $"{pw}@{GetIpv6(item.address)}:{item.port}";
url = $"{Global.ProtocolShares[EConfigType.Socks]}{url}{remark}";
url = $"{Global.ProtocolShares[EConfigType.SOCKS]}{url}{remark}";
return url;
}

private static ProfileItem? ResolveSocks(string result)
{
ProfileItem item = new()
{
configType = EConfigType.Socks
configType = EConfigType.SOCKS
};
result = result[Global.ProtocolShares[EConfigType.Socks].Length..];
result = result[Global.ProtocolShares[EConfigType.SOCKS].Length..];
//remark
int indexRemark = result.IndexOf("#");
if (indexRemark > 0)
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/ServiceLib/Handler/Fmt/TuicFmt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class TuicFmt : BaseFmt

ProfileItem item = new()
{
configType = EConfigType.Tuic
configType = EConfigType.TUIC
};

Uri url = new(str);
Expand Down Expand Up @@ -57,7 +57,7 @@ public class TuicFmt : BaseFmt
$"{item.id}:{item.security}",
GetIpv6(item.address),
item.port);
url = $"{Global.ProtocolShares[EConfigType.Tuic]}{url}{query}{remark}";
url = $"{Global.ProtocolShares[EConfigType.TUIC]}{url}{query}{remark}";
return url;
}
}
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/ServiceLib/Handler/Fmt/WireguardFmt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class WireguardFmt : BaseFmt

ProfileItem item = new()
{
configType = EConfigType.Wireguard
configType = EConfigType.WireGuard
};

Uri url = new(str);
Expand Down Expand Up @@ -62,7 +62,7 @@ public class WireguardFmt : BaseFmt
Utils.UrlEncode(item.id),
GetIpv6(item.address),
item.port);
url = $"{Global.ProtocolShares[EConfigType.Wireguard]}{url}/{query}{remark}";
url = $"{Global.ProtocolShares[EConfigType.WireGuard]}{url}/{query}{remark}";
return url;
}
}
Expand Down
8 changes: 8 additions & 0 deletions v2rayN/ServiceLib/Handler/LazyConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ public LazyConfig()
SQLiteHelper.Instance.CreateTable<RoutingItem>();
SQLiteHelper.Instance.CreateTable<ProfileExItem>();
SQLiteHelper.Instance.CreateTable<DNSItem>();

//TODO
//Prepare to remove the clash
SQLiteHelper.Instance.Execute($"update ProfileItem set coreType = 13 where coreType = 11");
SQLiteHelper.Instance.Execute($"update ProfileItem set coreType = 13 where coreType = 12");
//Prepare to remove the SagerNet
SQLiteHelper.Instance.Execute($"update ProfileItem set coreType = 2 where coreType = 3");

}

#region Config
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/ServiceLib/Handler/TaskHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public TaskHandler()
public void RegUpdateTask(Config config, Action<bool, string> update)
{
Task.Run(() => UpdateTaskRunSubscription(config, update));
Task.Run(() => UpdateTaskRunGeo(config, update));
//Task.Run(() => UpdateTaskRunGeo(config, update));
}

private async Task UpdateTaskRunSubscription(Config config, Action<bool, string> update)
Expand Down
Loading

0 comments on commit b5fa1f9

Please sign in to comment.