Compare commits

..

No commits in common. "0c758a7fdc47ed035e86224fc96d213f32956640" and "2b5cbb5e74d2fc629332fa8eb984a807e8042a1a" have entirely different histories.

20 changed files with 34 additions and 45 deletions

View file

@ -710,7 +710,7 @@ namespace ServiceLib.Common
public static string StartupPath() public static string StartupPath()
{ {
if (Utils.IsNonWindows() && Environment.GetEnvironmentVariable("V2RAYN_LOCAL_APPLICATION_DATA") == "1") if (Utils.IsLinux() && 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,8 +838,6 @@ 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;

View file

@ -46,7 +46,7 @@
public bool InitApp() public bool InitApp()
{ {
if (Utils.IsNonWindows() && Utils.HasWritePermission() == false) if (Utils.IsLinux() && Utils.HasWritePermission() == false)
{ {
Environment.SetEnvironmentVariable("V2RAYN_LOCAL_APPLICATION_DATA", "1", EnvironmentVariableTarget.Process); Environment.SetEnvironmentVariable("V2RAYN_LOCAL_APPLICATION_DATA", "1", EnvironmentVariableTarget.Process);
} }

View file

@ -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.IsNonWindows()) if (Utils.IsLinux() || Utils.IsOSX())
{ {
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.IsNonWindows()) && (Utils.IsLinux() || Utils.IsOSX())
//&& _config.TunModeItem.LinuxSudoPwd.IsNotEmpty() //&& _config.TunModeItem.LinuxSudoPwd.IsNotEmpty()
; ;
} }

View file

@ -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, string exceptions) public static async Task SetProxy(string host, int port)
{ {
var lstCmd = GetSetCmds(host, port, exceptions); var lstCmd = GetSetCmds(host, port);
await ExecCmd(lstCmd); await ExecCmd(lstCmd);
} }
@ -42,7 +42,7 @@
} }
} }
private static List<CmdItem> GetSetCmds(string host, int port, string exceptions) private static List<CmdItem> GetSetCmds(string host, int port)
{ {
List<CmdItem> lstCmd = []; List<CmdItem> lstCmd = [];
foreach (var interf in LstInterface) foreach (var interf in LstInterface)
@ -52,17 +52,7 @@
lstCmd.Add(new CmdItem() lstCmd.Add(new CmdItem()
{ {
Cmd = "networksetup", Cmd = "networksetup",
Arguments = [$"-{type}", interf, host, port.ToString()] Arguments = [$"-{type}", interf, host, (type.Contains("socks") ? (port - 1) : port).ToString()]
});
}
if (exceptions.IsNotEmpty())
{
List<string> args = [$"-setproxybypassdomains", interf];
args.AddRange(exceptions.Split(','));
lstCmd.Add(new CmdItem()
{
Cmd = "networksetup",
Arguments = args
}); });
} }
} }

View file

@ -32,7 +32,7 @@
break; break;
case ESysProxyType.ForcedChange when Utils.IsOSX(): case ESysProxyType.ForcedChange when Utils.IsOSX():
await ProxySettingOSX.SetProxy(Global.Loopback, port, exceptions); await ProxySettingOSX.SetProxy(Global.Loopback, port);
break; break;
case ESysProxyType.ForcedClear when Utils.IsWindows(): case ESysProxyType.ForcedClear when Utils.IsWindows():

View file

@ -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.IsNonWindows()) if (Utils.IsLinux() || Utils.IsOSX())
{ {
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)

View file

@ -6,18 +6,18 @@
</Design.PreviewWith> </Design.PreviewWith>
<Style Selector="TextBlock.Margin8"> <Style Selector="TextBlock.Margin8">
<Setter Property="Margin" Value="8" /> <Setter Property="Margin" Value="10" />
</Style> </Style>
<Style Selector="StackPanel.Margin8"> <Style Selector="StackPanel.Margin8">
<Setter Property="Margin" Value="8" /> <Setter Property="Margin" Value="10" />
</Style> </Style>
<Style Selector="DockPanel.Margin8"> <Style Selector="DockPanel.Margin8">
<Setter Property="Margin" Value="8" /> <Setter Property="Margin" Value="10" />
</Style> </Style>
<Style Selector="WrapPanel.Margin8"> <Style Selector="WrapPanel.Margin8">
<Setter Property="Margin" Value="8" /> <Setter Property="Margin" Value="10" />
</Style> </Style>
<Style Selector="Grid.Margin8"> <Style Selector="Grid.Margin8">
<Setter Property="Margin" Value="8" /> <Setter Property="Margin" Value="10" />
</Style> </Style>
</Styles> </Styles>

View file

@ -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="600" Height="700"
x:DataType="vms:AddServerViewModel" x:DataType="vms:AddServerViewModel"
ShowInTaskbar="False" ShowInTaskbar="False"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"

View file

@ -50,7 +50,7 @@
<Border <Border
Width="500" Width="500"
Height="80" Height="80"
Margin="-8" Margin="-2"
VerticalAlignment="Center" VerticalAlignment="Center"
Theme="{StaticResource CardBorder}"> Theme="{StaticResource CardBorder}">
<Grid> <Grid>

View file

@ -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="900" Width="1000"
Height="600" Height="700"
x:DataType="vms:DNSSettingViewModel" x:DataType="vms:DNSSettingViewModel"
ShowInTaskbar="False" ShowInTaskbar="False"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"

View file

@ -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="600" Height="700"
MinWidth="900" MinWidth="900"
x:DataType="vms:MainWindowViewModel" x:DataType="vms:MainWindowViewModel"
Icon="/Assets/NotifyIcon1.ico" Icon="/Assets/NotifyIcon1.ico"

View file

@ -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="600" Height="700"
x:DataType="vms:OptionSettingViewModel" x:DataType="vms:OptionSettingViewModel"
ShowInTaskbar="False" ShowInTaskbar="False"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"

View file

@ -215,7 +215,7 @@ namespace v2rayN.Desktop.Views
{ {
return lstFonts; return lstFonts;
} }
else if (Utils.IsNonWindows()) else if (Utils.IsLinux() || Utils.IsOSX())
{ {
var result = await Utils.GetLinuxFontFamily("zh"); var result = await Utils.GetLinuxFontFamily("zh");
if (result.IsNullOrEmpty()) if (result.IsNullOrEmpty())

View file

@ -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="600" Height="700"
x:DataType="vms:RoutingRuleDetailsViewModel" x:DataType="vms:RoutingRuleDetailsViewModel"
ShowInTaskbar="False" ShowInTaskbar="False"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"

View file

@ -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="900" Width="1000"
Height="600" Height="700"
x:DataType="vms:RoutingRuleSettingViewModel" x:DataType="vms:RoutingRuleSettingViewModel"
ShowInTaskbar="False" ShowInTaskbar="False"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"

View file

@ -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="900" Width="1000"
Height="600" Height="700"
x:DataType="vms:RoutingSettingViewModel" x:DataType="vms:RoutingSettingViewModel"
ShowInTaskbar="False" ShowInTaskbar="False"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"

View file

@ -23,6 +23,7 @@
</StackPanel> </StackPanel>
<StackPanel <StackPanel
Width="120"
Margin="8,0" Margin="8,0"
VerticalAlignment="Center" VerticalAlignment="Center"
DockPanel.Dock="Left"> DockPanel.Dock="Left">
@ -33,6 +34,7 @@
<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"

View file

@ -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="600" Height="650"
ShowInTaskbar="False" ShowInTaskbar="False"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
mc:Ignorable="d"> mc:Ignorable="d">

View file

@ -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="900" Width="1000"
Height="600" Height="700"
x:DataType="vms:SubSettingViewModel" x:DataType="vms:SubSettingViewModel"
ShowInTaskbar="False" ShowInTaskbar="False"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"

View file

@ -27,7 +27,7 @@
</StackPanel> </StackPanel>
<StackPanel <StackPanel
Width="Auto" Width="120"
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,7 +46,6 @@
<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"