Skip to content

Commit

Permalink
up routing
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Nov 8, 2019
1 parent 9eab95e commit 70dadf9
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 21 deletions.
7 changes: 4 additions & 3 deletions v2rayN/v2rayN/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ private void LoadV2ray()
}
v2rayHandler.LoadV2ray(config);
Global.reloadV2ray = false;
ConfigHandler.ToJsonFile(config);
ConfigHandler.SaveConfig(ref config, false);

ChangeSysAgent(config.sysAgentEnabled);
DisplayToolStatus();
Expand All @@ -416,7 +416,7 @@ private void LoadV2ray()
/// </summary>
private void CloseV2ray()
{
ConfigHandler.ToJsonFile(config);
ConfigHandler.SaveConfig(ref config, false);

ChangeSysAgent(false);

Expand Down Expand Up @@ -1234,6 +1234,7 @@ private void ChangePACButtonStatus(int type)
break;
}
}
ConfigHandler.SaveConfig(ref config, false);
DisplayToolStatus();
}

Expand Down Expand Up @@ -1399,7 +1400,7 @@ private void tsbAbout_Click(object sender, EventArgs e)

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

Expand Down
24 changes: 17 additions & 7 deletions v2rayN/v2rayN/Forms/OptionSettingForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void InitBase()
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)
Expand Down Expand Up @@ -127,7 +127,7 @@ private void InitGUI()
cbFreshrate.DisplayMember = "Text";
cbFreshrate.ValueMember = "ID";

switch(config.statisticsFreshRate)
switch (config.statisticsFreshRate)
{
case (int)Global.StatisticsFreshRate.quick:
cbFreshrate.SelectedItem = cbSource[0];
Expand Down Expand Up @@ -369,10 +369,14 @@ private void chkAllowIn2State()

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<string>();
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<TextBox>();
lstTxt.Add(txtUseragent);
Expand Down Expand Up @@ -415,7 +419,13 @@ void AppendText(bool notify, string text)

class ComboItem
{
public int ID { get; set; }
public string Text { get; set; }
public int ID
{
get; set;
}
public string Text
{
get; set;
}
}
}
34 changes: 27 additions & 7 deletions v2rayN/v2rayN/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class Global
/// </summary>
public const string BlankPacFileName = "v2rayN.Sample.BlankPac.txt";

public const string CustomRoutingFileName = "v2rayN.Sample.custom_routing_";


/// <summary>
/// 默认加密方式
Expand Down Expand Up @@ -98,7 +100,7 @@ class Global
/// 阻止 tag值
/// </summary>
public const string blockTag = "block";

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -172,32 +174,50 @@ public enum StatisticsFreshRate
/// <summary>
/// 是否需要重启服务V2ray
/// </summary>
public static bool reloadV2ray { get; set; }
public static bool reloadV2ray
{
get; set;
}

/// <summary>
/// 是否开启全局代理(http)
/// </summary>
public static bool sysAgent { get; set; }
public static bool sysAgent
{
get; set;
}

/// <summary>
/// socks端口
/// </summary>
public static int socksPort { get; set; }
public static int socksPort
{
get; set;
}

/// <summary>
/// http端口
/// </summary>
public static int httpPort { get; set; }
public static int httpPort
{
get; set;
}

/// <summary>
/// PAC端口
/// </summary>
public static int pacPort { get; set; }
public static int pacPort
{
get; set;
}

/// <summary>
///
/// </summary>
public static int statePort { get; set; }
public static int statePort
{
get; set;
}

#endregion

Expand Down
6 changes: 3 additions & 3 deletions v2rayN/v2rayN/Handler/ConfigHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ public static int SetDefaultServer(ref Config config, int index)
/// </summary>
/// <param name="config"></param>
/// <returns></returns>
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);

Expand All @@ -320,7 +320,7 @@ public static int SaveConfig(ref Config config)
/// 存储文件
/// </summary>
/// <param name="config"></param>
public static void ToJsonFile(Config config)
private static void ToJsonFile(Config config)
{
Utils.ToJsonFile(config, Utils.GetPath(configRes));
}
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
// 方法是按如下所示使用“*”:
//[assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("2.48")]
[assembly: AssemblyFileVersion("2.49")]
1 change: 1 addition & 0 deletions v2rayN/v2rayN/Sample/custom_routing_block
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
geosite:category-ads,
132 changes: 132 additions & 0 deletions v2rayN/v2rayN/Sample/custom_routing_direct
Original file line number Diff line number Diff line change
@@ -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,
33 changes: 33 additions & 0 deletions v2rayN/v2rayN/Sample/custom_routing_proxy
Original file line number Diff line number Diff line change
@@ -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,
12 changes: 12 additions & 0 deletions v2rayN/v2rayN/v2rayN.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@
<Compile Include="Forms\MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\RoutingRuleSettingForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\RoutingRuleSettingForm.Designer.cs">
<DependentUpon>RoutingRuleSettingForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\SubSettingForm.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -286,6 +292,9 @@
<DependentUpon>QRCodeControl.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\RoutingRuleSettingForm.resx">
<DependentUpon>RoutingRuleSettingForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\SubSettingControl.resx">
<DependentUpon>SubSettingControl.cs</DependentUpon>
</EmbeddedResource>
Expand Down Expand Up @@ -340,6 +349,9 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Sample\custom_routing_block" />
<EmbeddedResource Include="Sample\custom_routing_direct" />
<EmbeddedResource Include="Sample\custom_routing_proxy" />
<Protobuf Include="Protos\Statistics.proto" />
<None Include="Resources\abp.js.gz" />
<None Include="Resources\grpc_csharp_ext.x64.dll.gz" />
Expand Down

0 comments on commit 70dadf9

Please sign in to comment.