diff --git a/v2rayN/PacLib/PacHandler.cs b/v2rayN/PacLib/PacHandler.cs
index 5806d471..4b2fe2c3 100644
--- a/v2rayN/PacLib/PacHandler.cs
+++ b/v2rayN/PacLib/PacHandler.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading;
@@ -43,6 +44,12 @@ public class PacHandler
}
_pacText = File.ReadAllText(path).Replace("__PROXY__", $"PROXY 127.0.0.1:{_httpPort};DIRECT;");
+
+ var userPac = LoadUserPac(_configPath);
+ if (userPac != "")
+ {
+ _pacText = _pacText.Replace(" [],\n []", userPac);
+ }
}
private static void RunListener()
@@ -100,4 +107,32 @@ public class PacHandler
}
}
}
+
+ public static string LoadUserPac(string configPath)
+ {
+ var userPac = "";
+ var userPacPath = Path.Combine(_configPath, "pacUser.txt");
+ if (File.Exists(userPacPath))
+ {
+ userPac = File.ReadAllText(userPacPath);
+ }
+ return userPac;
+ }
+
+ public static void SaveUserPac(string directDomains, string proxyDomains, string configPath)
+ {
+ var directDomainsArray = directDomains.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
+ var proxyDomainsArray = proxyDomains.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
+
+ var userPac = directDomainsArray.Aggregate("[\n", (current, directDomain) => $"{current} \"{directDomain}\",\n");
+
+ userPac += " ],\n [\n";
+
+ userPac = proxyDomainsArray.Aggregate(userPac, (current, proxyDomain) => $"{current} \"{proxyDomain}\",\n");
+
+ userPac += "]";
+
+ var path = Path.Combine(configPath, "pacUser.txt");
+ File.WriteAllText(path, userPac);
+ }
}
\ No newline at end of file
diff --git a/v2rayN/v2rayN/Resx/ResUI.Designer.cs b/v2rayN/v2rayN/Resx/ResUI.Designer.cs
index 6c208a7c..d585e109 100644
--- a/v2rayN/v2rayN/Resx/ResUI.Designer.cs
+++ b/v2rayN/v2rayN/Resx/ResUI.Designer.cs
@@ -2887,6 +2887,33 @@ namespace v2rayN.Resx {
}
}
+ ///
+ /// 查找类似 User Pac settings 的本地化字符串。
+ ///
+ public static string TbSettingsUserPac {
+ get {
+ return ResourceManager.GetString("TbSettingsUserPac", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Direct domains(One at a line): 的本地化字符串。
+ ///
+ public static string TbSettingsUserPacDirectDomains {
+ get {
+ return ResourceManager.GetString("TbSettingsUserPacDirectDomains", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Proxy domains(One at a line): 的本地化字符串。
+ ///
+ public static string TbSettingsUserPacProxyDomains {
+ get {
+ return ResourceManager.GetString("TbSettingsUserPacProxyDomains", resourceCulture);
+ }
+ }
+
///
/// 查找类似 ShortId 的本地化字符串。
///
diff --git a/v2rayN/v2rayN/Resx/ResUI.fa-Ir.resx b/v2rayN/v2rayN/Resx/ResUI.fa-Ir.resx
index 39f211d2..5e87e1b6 100644
--- a/v2rayN/v2rayN/Resx/ResUI.fa-Ir.resx
+++ b/v2rayN/v2rayN/Resx/ResUI.fa-Ir.resx
@@ -1009,4 +1009,13 @@
فعالسازی شتابدهنده سختافزاری (نیاز به راهاندازی مجدد)
+
+ User Pac settings
+
+
+ Proxy domains(One at a line):
+
+
+ Direct domains(One at a line):
+
\ No newline at end of file
diff --git a/v2rayN/v2rayN/Resx/ResUI.resx b/v2rayN/v2rayN/Resx/ResUI.resx
index 1625e449..73b1e053 100644
--- a/v2rayN/v2rayN/Resx/ResUI.resx
+++ b/v2rayN/v2rayN/Resx/ResUI.resx
@@ -814,6 +814,15 @@
Auth user
+
+ User Pac settings
+
+
+ Direct domains(One at a line):
+
+
+ Proxy domains(One at a line):
+
Clear system proxy
diff --git a/v2rayN/v2rayN/Resx/ResUI.ru.resx b/v2rayN/v2rayN/Resx/ResUI.ru.resx
index 99be3632..3338c270 100644
--- a/v2rayN/v2rayN/Resx/ResUI.ru.resx
+++ b/v2rayN/v2rayN/Resx/ResUI.ru.resx
@@ -1051,4 +1051,13 @@
Включить аппаратное ускорение (требуется перезагрузка)
+
+ User Pac settings
+
+
+ Proxy domains(One at a line):
+
+
+ Direct domains(One at a line):
+
\ No newline at end of file
diff --git a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx
index 0363c124..aab89bb3 100644
--- a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx
+++ b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx
@@ -1135,4 +1135,13 @@
IP 或 IP CIDR
+
+ 用户Pac设置
+
+
+ 直连的域名(每行一个):
+
+
+ 需要代理的域名(每行一个):
+
\ No newline at end of file
diff --git a/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs b/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs
index b1d9e803..50b281b0 100644
--- a/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs
+++ b/v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs
@@ -3,6 +3,7 @@ using ReactiveUI.Fody.Helpers;
using Splat;
using System.Reactive;
using System.Windows;
+using PacLib;
using v2rayN.Handler;
using v2rayN.Mode;
using v2rayN.Resx;
@@ -96,6 +97,13 @@ namespace v2rayN.ViewModels
#endregion CoreType
+ #region User Pac
+
+ [Reactive] public string userPacDirectDomains { get; set; }
+ [Reactive] public string userPacProxyDomains { get; set; }
+
+ #endregion System proxy
+
public ReactiveCommand SaveCmd { get; }
public OptionSettingViewModel(Window view)
@@ -177,6 +185,8 @@ namespace v2rayN.ViewModels
InitCoreType();
+ InitUserPac();
+
SaveCmd = ReactiveCommand.Create(() =>
{
SaveSetting();
@@ -333,6 +343,8 @@ namespace v2rayN.ViewModels
{
UI.ShowWarning(ResUI.OperationFailed);
}
+
+ SaveUserPac();
}
private int SaveCoreType()
@@ -371,5 +383,25 @@ namespace v2rayN.ViewModels
}
return 0;
}
+
+ private void InitUserPac()
+ {
+ var userPac = PacHandler.LoadUserPac(Utils.GetConfigPath());
+ if (userPac == "") return;
+
+ userPac = userPac.Replace(" \"", "").Replace("\",", "");
+ var arr = userPac.Split(" ],\n [\n", StringSplitOptions.RemoveEmptyEntries);
+ userPacDirectDomains = arr[0].Replace("[\n", "");
+ userPacProxyDomains = arr[1].Replace("]", "");
+ }
+
+ private int SaveUserPac()
+ {
+ var result = -1;
+
+ PacHandler.SaveUserPac(userPacDirectDomains, userPacProxyDomains, Utils.GetConfigPath());
+
+ return result;
+ }
}
}
\ No newline at end of file
diff --git a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml
index ac4c5272..306a78bc 100644
--- a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml
+++ b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml
@@ -954,6 +954,51 @@
Style="{StaticResource DefComboBox}" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs
index 5a70e301..8196e8f0 100644
--- a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs
+++ b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs
@@ -181,6 +181,9 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.CoreType5, v => v.cmbCoreType5.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CoreType6, v => v.cmbCoreType6.Text).DisposeWith(disposables);
+ this.Bind(ViewModel, vm => vm.userPacDirectDomains, v => v.txtUserPacDirectDomains.Text).DisposeWith(disposables);
+ this.Bind(ViewModel, vm => vm.userPacProxyDomains, v => v.txtUserPacProxyDomains.Text).DisposeWith(disposables);
+
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
});
}