mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-25 17:54:41 +00:00
Compare commits
5 commits
2b5cbb5e74
...
0c758a7fdc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c758a7fdc | ||
|
|
85cb1d1c92 | ||
|
|
2cd2e8894d | ||
|
|
abb58379b3 | ||
|
|
4f48e8b190 |
20 changed files with 45 additions and 34 deletions
|
|
@ -710,7 +710,7 @@ namespace ServiceLib.Common
|
||||||
|
|
||||||
public static string StartupPath()
|
public static string StartupPath()
|
||||||
{
|
{
|
||||||
if (Utils.IsLinux() && Environment.GetEnvironmentVariable("V2RAYN_LOCAL_APPLICATION_DATA") == "1")
|
if (Utils.IsNonWindows() && Environment.GetEnvironmentVariable("V2RAYN_LOCAL_APPLICATION_DATA") == "1")
|
||||||
{
|
{
|
||||||
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "v2rayN");
|
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "v2rayN");
|
||||||
}
|
}
|
||||||
|
|
@ -838,6 +838,8 @@ namespace ServiceLib.Common
|
||||||
|
|
||||||
public static bool IsOSX() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
public static bool IsOSX() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||||
|
|
||||||
|
public static bool IsNonWindows() => !RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||||
|
|
||||||
public static string GetExeName(string name)
|
public static string GetExeName(string name)
|
||||||
{
|
{
|
||||||
return IsWindows() ? $"{name}.exe" : name;
|
return IsWindows() ? $"{name}.exe" : name;
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
|
|
||||||
public bool InitApp()
|
public bool InitApp()
|
||||||
{
|
{
|
||||||
if (Utils.IsLinux() && Utils.HasWritePermission() == false)
|
if (Utils.IsNonWindows() && Utils.HasWritePermission() == false)
|
||||||
{
|
{
|
||||||
Environment.SetEnvironmentVariable("V2RAYN_LOCAL_APPLICATION_DATA", "1", EnvironmentVariableTarget.Process);
|
Environment.SetEnvironmentVariable("V2RAYN_LOCAL_APPLICATION_DATA", "1", EnvironmentVariableTarget.Process);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace ServiceLib.Handler
|
||||||
Environment.SetEnvironmentVariable("V2RAY_LOCATION_ASSET", Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
|
Environment.SetEnvironmentVariable("V2RAY_LOCATION_ASSET", Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
|
||||||
Environment.SetEnvironmentVariable("XRAY_LOCATION_ASSET", Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
|
Environment.SetEnvironmentVariable("XRAY_LOCATION_ASSET", Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
|
||||||
|
|
||||||
if (Utils.IsLinux() || Utils.IsOSX())
|
if (Utils.IsNonWindows())
|
||||||
{
|
{
|
||||||
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo();
|
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo();
|
||||||
foreach (var it in coreInfo)
|
foreach (var it in coreInfo)
|
||||||
|
|
@ -221,7 +221,7 @@ namespace ServiceLib.Handler
|
||||||
{
|
{
|
||||||
return _config.TunModeItem.EnableTun
|
return _config.TunModeItem.EnableTun
|
||||||
&& eCoreType == ECoreType.sing_box
|
&& eCoreType == ECoreType.sing_box
|
||||||
&& (Utils.IsLinux() || Utils.IsOSX())
|
&& (Utils.IsNonWindows())
|
||||||
//&& _config.TunModeItem.LinuxSudoPwd.IsNotEmpty()
|
//&& _config.TunModeItem.LinuxSudoPwd.IsNotEmpty()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly List<string> LstTypes = ["setwebproxy", "setsecurewebproxy", "setsocksfirewallproxy"];
|
private static readonly List<string> LstTypes = ["setwebproxy", "setsecurewebproxy", "setsocksfirewallproxy"];
|
||||||
|
|
||||||
public static async Task SetProxy(string host, int port)
|
public static async Task SetProxy(string host, int port, string exceptions)
|
||||||
{
|
{
|
||||||
var lstCmd = GetSetCmds(host, port);
|
var lstCmd = GetSetCmds(host, port, exceptions);
|
||||||
await ExecCmd(lstCmd);
|
await ExecCmd(lstCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<CmdItem> GetSetCmds(string host, int port)
|
private static List<CmdItem> GetSetCmds(string host, int port, string exceptions)
|
||||||
{
|
{
|
||||||
List<CmdItem> lstCmd = [];
|
List<CmdItem> lstCmd = [];
|
||||||
foreach (var interf in LstInterface)
|
foreach (var interf in LstInterface)
|
||||||
|
|
@ -52,7 +52,17 @@
|
||||||
lstCmd.Add(new CmdItem()
|
lstCmd.Add(new CmdItem()
|
||||||
{
|
{
|
||||||
Cmd = "networksetup",
|
Cmd = "networksetup",
|
||||||
Arguments = [$"-{type}", interf, host, (type.Contains("socks") ? (port - 1) : port).ToString()]
|
Arguments = [$"-{type}", interf, host, port.ToString()]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (exceptions.IsNotEmpty())
|
||||||
|
{
|
||||||
|
List<string> args = [$"-setproxybypassdomains", interf];
|
||||||
|
args.AddRange(exceptions.Split(','));
|
||||||
|
lstCmd.Add(new CmdItem()
|
||||||
|
{
|
||||||
|
Cmd = "networksetup",
|
||||||
|
Arguments = args
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ESysProxyType.ForcedChange when Utils.IsOSX():
|
case ESysProxyType.ForcedChange when Utils.IsOSX():
|
||||||
await ProxySettingOSX.SetProxy(Global.Loopback, port);
|
await ProxySettingOSX.SetProxy(Global.Loopback, port, exceptions);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ESysProxyType.ForcedClear when Utils.IsWindows():
|
case ESysProxyType.ForcedClear when Utils.IsWindows():
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,7 @@ namespace ServiceLib.ViewModels
|
||||||
FileManager.ZipExtractToFile(fileName, toPath, _config.GuiItem.IgnoreGeoUpdateCore ? "geo" : "");
|
FileManager.ZipExtractToFile(fileName, toPath, _config.GuiItem.IgnoreGeoUpdateCore ? "geo" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.IsLinux() || Utils.IsOSX())
|
if (Utils.IsNonWindows())
|
||||||
{
|
{
|
||||||
var filesList = (new DirectoryInfo(toPath)).GetFiles().Select(u => u.FullName).ToList();
|
var filesList = (new DirectoryInfo(toPath)).GetFiles().Select(u => u.FullName).ToList();
|
||||||
foreach (var file in filesList)
|
foreach (var file in filesList)
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,18 @@
|
||||||
</Design.PreviewWith>
|
</Design.PreviewWith>
|
||||||
|
|
||||||
<Style Selector="TextBlock.Margin8">
|
<Style Selector="TextBlock.Margin8">
|
||||||
<Setter Property="Margin" Value="10" />
|
<Setter Property="Margin" Value="8" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="StackPanel.Margin8">
|
<Style Selector="StackPanel.Margin8">
|
||||||
<Setter Property="Margin" Value="10" />
|
<Setter Property="Margin" Value="8" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="DockPanel.Margin8">
|
<Style Selector="DockPanel.Margin8">
|
||||||
<Setter Property="Margin" Value="10" />
|
<Setter Property="Margin" Value="8" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="WrapPanel.Margin8">
|
<Style Selector="WrapPanel.Margin8">
|
||||||
<Setter Property="Margin" Value="10" />
|
<Setter Property="Margin" Value="8" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="Grid.Margin8">
|
<Style Selector="Grid.Margin8">
|
||||||
<Setter Property="Margin" Value="10" />
|
<Setter Property="Margin" Value="8" />
|
||||||
</Style>
|
</Style>
|
||||||
</Styles>
|
</Styles>
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
||||||
Title="{x:Static resx:ResUI.menuServers}"
|
Title="{x:Static resx:ResUI.menuServers}"
|
||||||
Width="900"
|
Width="900"
|
||||||
Height="700"
|
Height="600"
|
||||||
x:DataType="vms:AddServerViewModel"
|
x:DataType="vms:AddServerViewModel"
|
||||||
ShowInTaskbar="False"
|
ShowInTaskbar="False"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
<Border
|
<Border
|
||||||
Width="500"
|
Width="500"
|
||||||
Height="80"
|
Height="80"
|
||||||
Margin="-2"
|
Margin="-8"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Theme="{StaticResource CardBorder}">
|
Theme="{StaticResource CardBorder}">
|
||||||
<Grid>
|
<Grid>
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
|
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
|
||||||
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
||||||
Title="{x:Static resx:ResUI.menuDNSSetting}"
|
Title="{x:Static resx:ResUI.menuDNSSetting}"
|
||||||
Width="1000"
|
Width="900"
|
||||||
Height="700"
|
Height="600"
|
||||||
x:DataType="vms:DNSSettingViewModel"
|
x:DataType="vms:DNSSettingViewModel"
|
||||||
ShowInTaskbar="False"
|
ShowInTaskbar="False"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
||||||
Title="v2rayN"
|
Title="v2rayN"
|
||||||
Width="900"
|
Width="900"
|
||||||
Height="700"
|
Height="600"
|
||||||
MinWidth="900"
|
MinWidth="900"
|
||||||
x:DataType="vms:MainWindowViewModel"
|
x:DataType="vms:MainWindowViewModel"
|
||||||
Icon="/Assets/NotifyIcon1.ico"
|
Icon="/Assets/NotifyIcon1.ico"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
||||||
Title="{x:Static resx:ResUI.menuSetting}"
|
Title="{x:Static resx:ResUI.menuSetting}"
|
||||||
Width="1000"
|
Width="1000"
|
||||||
Height="700"
|
Height="600"
|
||||||
x:DataType="vms:OptionSettingViewModel"
|
x:DataType="vms:OptionSettingViewModel"
|
||||||
ShowInTaskbar="False"
|
ShowInTaskbar="False"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ namespace v2rayN.Desktop.Views
|
||||||
{
|
{
|
||||||
return lstFonts;
|
return lstFonts;
|
||||||
}
|
}
|
||||||
else if (Utils.IsLinux() || Utils.IsOSX())
|
else if (Utils.IsNonWindows())
|
||||||
{
|
{
|
||||||
var result = await Utils.GetLinuxFontFamily("zh");
|
var result = await Utils.GetLinuxFontFamily("zh");
|
||||||
if (result.IsNullOrEmpty())
|
if (result.IsNullOrEmpty())
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
||||||
Title="{x:Static resx:ResUI.menuRoutingRuleDetailsSetting}"
|
Title="{x:Static resx:ResUI.menuRoutingRuleDetailsSetting}"
|
||||||
Width="900"
|
Width="900"
|
||||||
Height="700"
|
Height="600"
|
||||||
x:DataType="vms:RoutingRuleDetailsViewModel"
|
x:DataType="vms:RoutingRuleDetailsViewModel"
|
||||||
ShowInTaskbar="False"
|
ShowInTaskbar="False"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
|
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
|
||||||
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
||||||
Title="{x:Static resx:ResUI.menuRoutingRuleSetting}"
|
Title="{x:Static resx:ResUI.menuRoutingRuleSetting}"
|
||||||
Width="1000"
|
Width="900"
|
||||||
Height="700"
|
Height="600"
|
||||||
x:DataType="vms:RoutingRuleSettingViewModel"
|
x:DataType="vms:RoutingRuleSettingViewModel"
|
||||||
ShowInTaskbar="False"
|
ShowInTaskbar="False"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
|
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
|
||||||
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
||||||
Title="{x:Static resx:ResUI.menuRoutingSetting}"
|
Title="{x:Static resx:ResUI.menuRoutingSetting}"
|
||||||
Width="1000"
|
Width="900"
|
||||||
Height="700"
|
Height="600"
|
||||||
x:DataType="vms:RoutingSettingViewModel"
|
x:DataType="vms:RoutingSettingViewModel"
|
||||||
ShowInTaskbar="False"
|
ShowInTaskbar="False"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Width="120"
|
|
||||||
Margin="8,0"
|
Margin="8,0"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
DockPanel.Dock="Left">
|
DockPanel.Dock="Left">
|
||||||
|
|
@ -34,7 +33,6 @@
|
||||||
|
|
||||||
<StackPanel
|
<StackPanel
|
||||||
x:Name="spEnableTun"
|
x:Name="spEnableTun"
|
||||||
Width="100"
|
|
||||||
Margin="8,0"
|
Margin="8,0"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
DockPanel.Dock="Left"
|
DockPanel.Dock="Left"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
||||||
Title="{x:Static resx:ResUI.menuSubSetting}"
|
Title="{x:Static resx:ResUI.menuSubSetting}"
|
||||||
Width="700"
|
Width="700"
|
||||||
Height="650"
|
Height="600"
|
||||||
ShowInTaskbar="False"
|
ShowInTaskbar="False"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
|
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
|
||||||
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
||||||
Title="{x:Static resx:ResUI.menuSubSetting}"
|
Title="{x:Static resx:ResUI.menuSubSetting}"
|
||||||
Width="1000"
|
Width="900"
|
||||||
Height="700"
|
Height="600"
|
||||||
x:DataType="vms:SubSettingViewModel"
|
x:DataType="vms:SubSettingViewModel"
|
||||||
ShowInTaskbar="False"
|
ShowInTaskbar="False"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Width="120"
|
Width="Auto"
|
||||||
Margin="{StaticResource MarginLeftRight8}"
|
Margin="{StaticResource MarginLeftRight8}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
DockPanel.Dock="Left">
|
DockPanel.Dock="Left">
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
<StackPanel
|
<StackPanel
|
||||||
x:Name="spEnableTun"
|
x:Name="spEnableTun"
|
||||||
Width="auto"
|
Width="Auto"
|
||||||
Margin="{StaticResource MarginLeftRight8}"
|
Margin="{StaticResource MarginLeftRight8}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
DockPanel.Dock="Left"
|
DockPanel.Dock="Left"
|
||||||
|
|
@ -46,6 +46,7 @@
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="{StaticResource MarginLeftRight8}"
|
Margin="{StaticResource MarginLeftRight8}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
|
Style="{StaticResource StatusbarItem}"
|
||||||
Text="{x:Static resx:ResUI.TbEnableTunAs}" />
|
Text="{x:Static resx:ResUI.TbEnableTunAs}" />
|
||||||
<ToggleButton
|
<ToggleButton
|
||||||
x:Name="togEnableTun"
|
x:Name="togEnableTun"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue