diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index 085313d8..91088b34 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -405,7 +405,7 @@ namespace v2rayN.Forms } v2rayHandler.LoadV2ray(config); Global.reloadV2ray = false; - ConfigHandler.ToJsonFile(config); + ConfigHandler.SaveConfig(ref config, false); ChangeSysAgent(config.sysAgentEnabled); DisplayToolStatus(); @@ -416,7 +416,7 @@ namespace v2rayN.Forms /// private void CloseV2ray() { - ConfigHandler.ToJsonFile(config); + ConfigHandler.SaveConfig(ref config, false); ChangeSysAgent(false); @@ -1234,6 +1234,7 @@ namespace v2rayN.Forms break; } } + ConfigHandler.SaveConfig(ref config, false); DisplayToolStatus(); } @@ -1399,7 +1400,7 @@ namespace v2rayN.Forms private void tsbPromotion_Click(object sender, EventArgs e) { - System.Diagnostics.Process.Start(Global.PromotionUrl); + System.Diagnostics.Process.Start($"{Global.PromotionUrl}?t={DateTime.Now.Ticks}"); } #endregion diff --git a/v2rayN/v2rayN/Forms/OptionSettingForm.cs b/v2rayN/v2rayN/Forms/OptionSettingForm.cs index 83dc9f30..06ae6164 100644 --- a/v2rayN/v2rayN/Forms/OptionSettingForm.cs +++ b/v2rayN/v2rayN/Forms/OptionSettingForm.cs @@ -44,7 +44,7 @@ namespace v2rayN.Forms chkudpEnabled.Checked = config.inbound[0].udpEnabled; chksniffingEnabled.Checked = config.inbound[0].sniffingEnabled; - txtlocalPort2.Text = "socks + 1"; + txtlocalPort2.Text = $"{config.inbound[0].localPort + 1}"; cmbprotocol2.Text = Global.InboundHttp; if (config.inbound.Count > 1) @@ -127,7 +127,7 @@ namespace v2rayN.Forms cbFreshrate.DisplayMember = "Text"; cbFreshrate.ValueMember = "ID"; - switch(config.statisticsFreshRate) + switch (config.statisticsFreshRate) { case (int)Global.StatisticsFreshRate.quick: cbFreshrate.SelectedItem = cbSource[0]; @@ -369,10 +369,14 @@ namespace v2rayN.Forms private void btnSetDefRountingRule_Click(object sender, EventArgs e) { + txtUseragent.Text = Utils.GetEmbedText(Global.CustomRoutingFileName + Global.agentTag); + txtUserdirect.Text = Utils.GetEmbedText(Global.CustomRoutingFileName + Global.directTag); + txtUserblock.Text = Utils.GetEmbedText(Global.CustomRoutingFileName + Global.blockTag); + var lstUrl = new List(); - lstUrl.Add(Global.CustomRoutingListUrl + "proxy"); - lstUrl.Add(Global.CustomRoutingListUrl + "direct"); - lstUrl.Add(Global.CustomRoutingListUrl + "block"); + lstUrl.Add(Global.CustomRoutingListUrl + Global.agentTag); + lstUrl.Add(Global.CustomRoutingListUrl + Global.directTag); + lstUrl.Add(Global.CustomRoutingListUrl + Global.blockTag); var lstTxt = new List(); lstTxt.Add(txtUseragent); @@ -415,7 +419,13 @@ namespace v2rayN.Forms class ComboItem { - public int ID { get; set; } - public string Text { get; set; } + public int ID + { + get; set; + } + public string Text + { + get; set; + } } } diff --git a/v2rayN/v2rayN/Global.cs b/v2rayN/v2rayN/Global.cs index af6ab9e8..8f0a7675 100644 --- a/v2rayN/v2rayN/Global.cs +++ b/v2rayN/v2rayN/Global.cs @@ -63,6 +63,8 @@ namespace v2rayN /// public const string BlankPacFileName = "v2rayN.Sample.BlankPac.txt"; + public const string CustomRoutingFileName = "v2rayN.Sample.custom_routing_"; + /// /// 默认加密方式 @@ -98,7 +100,7 @@ namespace v2rayN /// 阻止 tag值 /// public const string blockTag = "block"; - + /// /// /// @@ -172,32 +174,50 @@ namespace v2rayN /// /// 是否需要重启服务V2ray /// - public static bool reloadV2ray { get; set; } + public static bool reloadV2ray + { + get; set; + } /// /// 是否开启全局代理(http) /// - public static bool sysAgent { get; set; } + public static bool sysAgent + { + get; set; + } /// /// socks端口 /// - public static int socksPort { get; set; } + public static int socksPort + { + get; set; + } /// /// http端口 /// - public static int httpPort { get; set; } + public static int httpPort + { + get; set; + } /// /// PAC端口 /// - public static int pacPort { get; set; } + public static int pacPort + { + get; set; + } /// /// /// - public static int statePort { get; set; } + public static int statePort + { + get; set; + } #endregion diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs index 51ed743f..cf816827 100644 --- a/v2rayN/v2rayN/Handler/ConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs @@ -307,9 +307,9 @@ namespace v2rayN.Handler /// /// /// - public static int SaveConfig(ref Config config) + public static int SaveConfig(ref Config config, bool reload = true) { - Global.reloadV2ray = true; + Global.reloadV2ray = reload; ToJsonFile(config); @@ -320,7 +320,7 @@ namespace v2rayN.Handler /// 存储文件 /// /// - public static void ToJsonFile(Config config) + private static void ToJsonFile(Config config) { Utils.ToJsonFile(config, Utils.GetPath(configRes)); } diff --git a/v2rayN/v2rayN/Properties/AssemblyInfo.cs b/v2rayN/v2rayN/Properties/AssemblyInfo.cs index fbd258fc..8aa478a9 100644 --- a/v2rayN/v2rayN/Properties/AssemblyInfo.cs +++ b/v2rayN/v2rayN/Properties/AssemblyInfo.cs @@ -33,4 +33,4 @@ using System.Runtime.InteropServices; // 方法是按如下所示使用“*”: //[assembly: AssemblyVersion("1.0.*")] //[assembly: AssemblyVersion("1.0.0")] -[assembly: AssemblyFileVersion("2.48")] +[assembly: AssemblyFileVersion("2.49")] diff --git a/v2rayN/v2rayN/Sample/custom_routing_block b/v2rayN/v2rayN/Sample/custom_routing_block new file mode 100644 index 00000000..738fe38c --- /dev/null +++ b/v2rayN/v2rayN/Sample/custom_routing_block @@ -0,0 +1 @@ +geosite:category-ads, \ No newline at end of file diff --git a/v2rayN/v2rayN/Sample/custom_routing_direct b/v2rayN/v2rayN/Sample/custom_routing_direct new file mode 100644 index 00000000..5408992c --- /dev/null +++ b/v2rayN/v2rayN/Sample/custom_routing_direct @@ -0,0 +1,132 @@ +domain:12306.com, +domain:51ym.me, +domain:52pojie.cn, +domain:8686c.com, +domain:abercrombie.com, +domain:adobesc.com, +domain:air-matters.com, +domain:air-matters.io, +domain:airtable.com, +domain:akadns.net, +domain:apache.org, +domain:api.crisp.chat, +domain:api.termius.com, +domain:appshike.com, +domain:appstore.com, +domain:aweme.snssdk.com, +domain:bababian.com, +domain:battle.net, +domain:beatsbydre.com, +domain:bet365.com, +domain:bilibili.cn, +domain:ccgslb.com, +domain:ccgslb.net, +domain:chunbo.com, +domain:chunboimg.com, +domain:clashroyaleapp.com, +domain:cloudsigma.com, +domain:cloudxns.net, +domain:cmfu.com, +domain:culturedcode.com, +domain:dct-cloud.com, +domain:didialift.com, +domain:douyutv.com, +domain:duokan.com, +domain:dytt8.net, +domain:easou.com, +domain:ecitic.net, +domain:eclipse.org, +domain:eudic.net, +domain:ewqcxz.com, +domain:fir.im, +domain:frdic.com, +domain:fresh-ideas.cc, +domain:godic.net, +domain:goodread.com, +domain:haibian.com, +domain:hdslb.net, +domain:hollisterco.com, +domain:hongxiu.com, +domain:hxcdn.net, +domain:images.unsplash.com, +domain:img4me.com, +domain:ipify.org, +domain:ixdzs.com, +domain:jd.hk, +domain:jianshuapi.com, +domain:jomodns.com, +domain:jsboxbbs.com, +domain:knewone.com, +domain:kuaidi100.com, +domain:lemicp.com, +domain:letvcloud.com, +domain:lizhi.io, +domain:localizecdn.com, +domain:lucifr.com, +domain:luoo.net, +domain:mai.tn, +domain:maven.org, +domain:miwifi.com, +domain:moji.com, +domain:moke.com, +domain:mtalk.google.com, +domain:mxhichina.com, +domain:myqcloud.com, +domain:myunlu.com, +domain:netease.com, +domain:nfoservers.com, +domain:nssurge.com, +domain:nuomi.com, +domain:ourdvs.com, +domain:overcast.fm, +domain:paypal.com, +domain:paypalobjects.com, +domain:pgyer.com, +domain:qdaily.com, +domain:qdmm.com, +domain:qin.io, +domain:qingmang.me, +domain:qingmang.mobi, +domain:qqurl.com, +domain:rarbg.to, +domain:rrmj.tv, +domain:ruguoapp.com, +domain:sm.ms, +domain:snwx.com, +domain:soku.com, +domain:startssl.com, +domain:store.steampowered.com, +domain:symcd.com, +domain:teamviewer.com, +domain:tmzvps.com, +domain:trello.com, +domain:trellocdn.com, +domain:ttmeiju.com, +domain:udache.com, +domain:uxengine.net, +domain:weather.bjango.com, +domain:weather.com, +domain:webqxs.com, +domain:weico.cc, +domain:wenku8.net, +domain:werewolf.53site.com, +domain:windowsupdate.com, +domain:wkcdn.com, +domain:workflowy.com, +domain:xdrig.com, +domain:xiaojukeji.com, +domain:xiaomi.net, +domain:xiaomicp.com, +domain:ximalaya.com, +domain:xitek.com, +domain:xmcdn.com, +domain:xslb.net, +domain:xteko.com, +domain:yach.me, +domain:yixia.com, +domain:yunjiasu-cdn.net, +domain:zealer.com, +domain:zgslb.net, +domain:zimuzu.tv, +domain:zmz002.com, +domain:samsungdm.com, \ No newline at end of file diff --git a/v2rayN/v2rayN/Sample/custom_routing_proxy b/v2rayN/v2rayN/Sample/custom_routing_proxy new file mode 100644 index 00000000..d67a6237 --- /dev/null +++ b/v2rayN/v2rayN/Sample/custom_routing_proxy @@ -0,0 +1,33 @@ +geosite:google, +geosite:github, +geosite:netflix, +geosite:steam, +geosite:telegram, +geosite:tumblr, +geosite:speedtest, +geosite:bbc, +domain:gvt1.com, +domain:textnow.com, +domain:twitch.tv, +domain:wikileaks.org, +domain:naver.com, +91.108.4.0/22, +91.108.8.0/22, +91.108.12.0/22, +91.108.20.0/22, +91.108.36.0/23, +91.108.38.0/23, +91.108.56.0/22, +149.154.160.0/20, +149.154.164.0/22, +149.154.172.0/22, +74.125.0.0/16, +173.194.0.0/16, +172.217.0.0/16, +216.58.200.0/24, +216.58.220.0/24, +91.108.56.116, +91.108.56.0/24, +109.239.140.0/24, +149.154.167.0/24, +149.154.175.0/24, \ No newline at end of file diff --git a/v2rayN/v2rayN/v2rayN.csproj b/v2rayN/v2rayN/v2rayN.csproj index 250af9ba..d39a838a 100644 --- a/v2rayN/v2rayN/v2rayN.csproj +++ b/v2rayN/v2rayN/v2rayN.csproj @@ -150,6 +150,12 @@ MainForm.cs + + Form + + + RoutingRuleSettingForm.cs + Form @@ -286,6 +292,9 @@ QRCodeControl.cs Designer + + RoutingRuleSettingForm.cs + SubSettingControl.cs @@ -340,6 +349,9 @@ Settings.settings True + + +