Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Code clean
  • Loading branch information
2dust committed Nov 28, 2023
1 parent 81efd25 commit 12be8bd
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 30 deletions.
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/App.xaml
@@ -1,9 +1,9 @@
<Application
x:Class="v2rayN.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:conv="clr-namespace:v2rayN.Converters"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
ShutdownMode="OnExplicitShutdown"
StartupUri="Views/MainWindow.xaml">
<Application.Resources>
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/Global.cs
Expand Up @@ -177,4 +177,4 @@ internal class Global

#endregion global variable
}
}
}
1 change: 0 additions & 1 deletion v2rayN/v2rayN/Handler/ConfigHandler.cs
Expand Up @@ -205,7 +205,6 @@ public static int LoadConfig(ref Config config)
};
}


LazyConfig.Instance.SetConfig(config);
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/Handler/CoreConfigHandler.cs
Expand Up @@ -155,4 +155,4 @@ public static string GenerateClientSpeedtestConfigString(Config config, List<Ser
return coreConfigV2ray.GenerateClientSpeedtestConfigString(selecteds, out msg);
}
}
}
}
1 change: 0 additions & 1 deletion v2rayN/v2rayN/Handler/CoreHandler.cs
Expand Up @@ -62,7 +62,6 @@ public void LoadCore()
Utils.SaveLog("Tun mode restart the core once");
}
}
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/Handler/LazyConfig.cs
Expand Up @@ -378,4 +378,4 @@ private void InitCoreInfo()

#endregion Core Type
}
}
}
13 changes: 7 additions & 6 deletions v2rayN/v2rayN/Handler/ProxySetting.cs
Expand Up @@ -78,7 +78,7 @@ private static bool SetConnectionProxy(string? connectionName, string? strProxy,
if (optionCount > 1)
{
options[1].m_Option = m_Option;
options[1].m_Value.m_StringPtr = Marshal.StringToHGlobalAuto(strProxy); // !! remember to deallocate memory 1
options[1].m_Value.m_StringPtr = Marshal.StringToHGlobalAuto(strProxy); // !! remember to deallocate memory 1
// except for these addresses ...
if (optionCount > 2)
{
Expand All @@ -91,10 +91,10 @@ private static bool SetConnectionProxy(string? connectionName, string? strProxy,
list.dwSize = Marshal.SizeOf(list);
if (connectionName != null)
{
list.szConnection = Marshal.StringToHGlobalAuto(connectionName); // !! remember to deallocate memory 3
list.szConnection = Marshal.StringToHGlobalAuto(connectionName); // !! remember to deallocate memory 3
}
else
{
{
list.szConnection = IntPtr.Zero;
}
list.dwOptionCount = options.Length;
Expand Down Expand Up @@ -141,7 +141,7 @@ private static bool SetConnectionProxy(string? connectionName, string? strProxy,
}

// FREE the data ASAP
if(list.szConnection != IntPtr.Zero) Marshal.FreeHGlobal(list.szConnection); // release mem 3
if (list.szConnection != IntPtr.Zero) Marshal.FreeHGlobal(list.szConnection); // release mem 3
if (optionCount > 1)
{
Marshal.FreeHGlobal(options[1].m_Value.m_StringPtr); // release mem 1
Expand All @@ -155,7 +155,7 @@ private static bool SetConnectionProxy(string? connectionName, string? strProxy,
if (returnvalue != 0)
{
// throw the error codes, they might be helpful
throw new ApplicationException($"Set Internet Proxy failed with error code: {Marshal.GetLastWin32Error()}" );
throw new ApplicationException($"Set Internet Proxy failed with error code: {Marshal.GetLastWin32Error()}");
}

return true;
Expand Down Expand Up @@ -256,8 +256,8 @@ public struct RASENTRYNAME

// Constants
public const int RAS_MaxEntryName = 256;
public const int MAX_PATH = 260; // Standard MAX_PATH value in Windows

public const int MAX_PATH = 260; // Standard MAX_PATH value in Windows
}

#endregion WinInet structures
Expand Down Expand Up @@ -310,6 +310,7 @@ internal static class NativeMethods
[DllImport("WinInet.dll", SetLastError = true, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool InternetSetOption(IntPtr hInternet, InternetOption dwOption, IntPtr lpBuffer, int dwBufferLength);

[DllImport("Rasapi32.dll", CharSet = CharSet.Auto)]
public static extern uint RasEnumEntries(
string? reserved, // Reserved, must be null
Expand Down
6 changes: 0 additions & 6 deletions v2rayN/v2rayN/Handler/SysProxyHandle.cs
@@ -1,10 +1,5 @@
using PacLib;
using System.Diagnostics;
using System.IO;
using System.Text;
using v2rayN.Mode;
using v2rayN.Properties;
using v2rayN.Tool;

namespace v2rayN.Handler
{
Expand Down Expand Up @@ -33,7 +28,6 @@ private enum RET_ERRORS : int

static SysProxyHandle()
{

}

public static bool UpdateSysProxy(Config config, bool forceDisable)
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/Mode/Config.cs
Expand Up @@ -28,7 +28,7 @@ public class Config
public ConstItem constItem { get; set; }
public SpeedTestItem speedTestItem { get; set; }
public Mux4SboxItem mux4SboxItem { get; set; }
public HysteriaItem hysteriaItem { get; set; }
public HysteriaItem hysteriaItem { get; set; }
public List<InItem> inbound { get; set; }
public List<KeyEventItem> globalHotkeys { get; set; }
public List<CoreTypeItem> coreTypeItem { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/Mode/ECoreType.cs
Expand Up @@ -16,4 +16,4 @@ public enum ECoreType
hysteria2 = 26,
v2rayN = 99
}
}
}
5 changes: 4 additions & 1 deletion v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs
Expand Up @@ -89,7 +89,7 @@ public class MainWindowViewModel : ReactiveObject
public ReactiveCommand<Unit, Unit> AddShadowsocksServerCmd { get; }
public ReactiveCommand<Unit, Unit> AddSocksServerCmd { get; }
public ReactiveCommand<Unit, Unit> AddTrojanServerCmd { get; }
public ReactiveCommand<Unit, Unit> AddHysteria2ServerCmd { get; }
public ReactiveCommand<Unit, Unit> AddHysteria2ServerCmd { get; }
public ReactiveCommand<Unit, Unit> AddCustomServerCmd { get; }
public ReactiveCommand<Unit, Unit> AddServerViaClipboardCmd { get; }
public ReactiveCommand<Unit, Unit> AddServerViaScanCmd { get; }
Expand Down Expand Up @@ -148,11 +148,14 @@ public class MainWindowViewModel : ReactiveObject
public ReactiveCommand<Unit, Unit> CheckUpdateNCmd { get; }

public ReactiveCommand<Unit, Unit> CheckUpdateV2flyCoreCmd { get; }

//public ReactiveCommand<Unit, Unit> CheckUpdateSagerNetCoreCmd { get; }
public ReactiveCommand<Unit, Unit> CheckUpdateXrayCoreCmd { get; }

//public ReactiveCommand<Unit, Unit> CheckUpdateClashCoreCmd { get; }
//public ReactiveCommand<Unit, Unit> CheckUpdateClashMetaCoreCmd { get; }
public ReactiveCommand<Unit, Unit> CheckUpdateSingBoxCoreCmd { get; }

public ReactiveCommand<Unit, Unit> CheckUpdateGeoCmd { get; }

public ReactiveCommand<Unit, Unit> ReloadCmd { get; }
Expand Down
8 changes: 4 additions & 4 deletions v2rayN/v2rayN/Views/AddServerWindow.xaml
@@ -1,12 +1,12 @@
<reactiveui:ReactiveWindow
x:Class="v2rayN.Views.AddServerWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:conv="clr-namespace:v2rayN.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:reactiveui="http://reactiveui.net"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:conv="clr-namespace:v2rayN.Converters"
xmlns:resx="clr-namespace:v2rayN.Resx"
xmlns:vms="clr-namespace:v2rayN.ViewModels"
Title="{x:Static resx:ResUI.menuServers}"
Expand Down
8 changes: 7 additions & 1 deletion v2rayN/v2rayN/Views/MainWindow.xaml.cs
Expand Up @@ -328,21 +328,27 @@ private void MainWindow_PreviewKeyDown(object sender, KeyEventArgs e)
case Key.V:
ViewModel?.AddServerViaClipboard();
break;

case Key.P:
ViewModel?.ServerSpeedtest(ESpeedActionType.Ping);
break;

case Key.O:
ViewModel?.ServerSpeedtest(ESpeedActionType.Tcping);
break;

case Key.R:
ViewModel?.ServerSpeedtest(ESpeedActionType.Realping);
break;

case Key.S:
_ = ViewModel?.ScanScreenTaskAsync();
break;

case Key.T:
ViewModel?.ServerSpeedtest(ESpeedActionType.Speedtest);
break;

case Key.E:
ViewModel?.ServerSpeedtest(ESpeedActionType.Mixedtest);
break;
Expand Down Expand Up @@ -652,4 +658,4 @@ private void LstProfiles_Drop(object sender, DragEventArgs e)

#endregion Drag and Drop
}
}
}
4 changes: 0 additions & 4 deletions v2rayN/v2rayN/Views/OptionSettingWindow.xaml
Expand Up @@ -309,7 +309,6 @@
Margin="{StaticResource SettingItemMargin}"
Style="{StaticResource DefComboBox}" />


<TextBlock
Grid.Row="15"
Grid.Column="0"
Expand All @@ -335,10 +334,7 @@
Margin="{StaticResource SettingItemMargin}"
materialDesign:HintAssist.Hint="Down"
Style="{StaticResource DefTextBox}" />

</StackPanel>


</Grid>
</ScrollViewer>
</TabItem>
Expand Down

2 comments on commit 12be8bd

@The-Mojoo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这种代码格式化,建议用CodeMaid来批量操作,会规范很多,也不会漏,就是每个人标准无法统一,可以考虑每次发版本的时候操作一次。

@2dust
Copy link
Owner Author

@2dust 2dust commented on 12be8bd Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这种代码格式化,建议用CodeMaid来批量操作,会规范很多,也不会漏,就是每个人标准无法统一,可以考虑每次发版本的时候操作一次。

现在就是

Please sign in to comment.