Browse Source

🧹 Some cleanup

- Removed some legacy compatibility code from Program.cs as we are not using .NET Framework.
- Changed CurrentDirectory detection method so that Self-Contained .exe can have its configuration files in the same directory as the .exe instead of in the temporary folder.
pull/2909/head
database64128 4 years ago
parent
commit
a8a2e62552
No known key found for this signature in database GPG Key ID: 1CA27546BEDB8B01
4 changed files with 4 additions and 33 deletions
  1. +0
    -15
      OPENSSL-GUIDE
  2. +1
    -1
      appveyor.yml
  3. +0
    -1
      shadowsocks-csharp/Controller/System/ProtocolHandler.cs
  4. +3
    -16
      shadowsocks-csharp/Program.cs

+ 0
- 15
OPENSSL-GUIDE View File

@@ -1,15 +0,0 @@
OpenSSL library guide for VS2017
# Read NOTES.WIN and NOTES.PERL
# use Visual Studio native tools command prompt
# use activeperl, install NASM assembler
ppm install dmake
# Win32 x86
set PATH=D:\NASM-32;%PATH%
perl Configure VC-WIN32 --release --prefix=C:\Users\home\Downloads\openssl-1.1.0g\x86-build --openssldir=C:\Users\home\Downloads\openssl-1.1.0g\x86-install
nmake
nmake test
# to rebuild
nmake distclean

+ 1
- 1
appveyor.yml View File

@@ -114,7 +114,7 @@ after_build:
$text += 'SHA-256' + $newLine
$text += (Get-FileHash $file -Algorithm SHA256).Hash + $newLine
$text += 'SHA-512' + $newLine
$text += (Get-FileHash $file -Algorithm SHA512).Hash
$text += (Get-FileHash $file -Algorithm SHA512).Hash + $newLine
return $text
}


+ 0
- 1
shadowsocks-csharp/Controller/System/ProtocolHandler.cs View File

@@ -20,7 +20,6 @@ namespace Shadowsocks.Controller
// see https://stackoverflow.com/questions/12945805/odd-c-sharp-path-issue
private static readonly string ExecutablePath = Assembly.GetEntryAssembly().Location;

// TODO: Elevate when necessary
public static bool Set(bool enabled)
{
RegistryKey ssURLAssociation = null;


+ 3
- 16
shadowsocks-csharp/Program.cs View File

@@ -26,32 +26,17 @@ namespace Shadowsocks
public static MenuViewController MenuController { get; private set; }
public static string[] Args { get; private set; }
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool SetProcessDPIAware();
/// <summary>
/// 应用程序的主入口点。
/// </summary>
/// </summary>
[STAThread]
static void Main(string[] args)
{
// todo: initialize the NLog configuartion
Model.NLogConfig.TouchAndApplyNLogConfig();
// .NET Framework 4.7.2 on Win7 compatibility
System.Net.ServicePointManager.SecurityProtocol |=
System.Net.SecurityProtocolType.Tls | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls12;
// store args for further use
Args = args;
// Check OS since we are using dual-mode socket
if (!Utils.IsWinVistaOrHigher())
{
MessageBox.Show(I18N.GetString("Unsupported operating system, use Windows Vista at least."),
"Shadowsocks Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string pipename = $"Shadowsocks\\{Application.StartupPath.GetHashCode()}";
string addedUrl = null;
@@ -125,7 +110,9 @@ namespace Shadowsocks
Application.SetCompatibleTextRenderingDefault(false);
AutoStartup.RegisterForRestart(true);
Directory.SetCurrentDirectory(Application.StartupPath);
// See https://github.com/dotnet/runtime/issues/13051
// we have to do this for self-contained executables
Directory.SetCurrentDirectory(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName));
#if DEBUG
// truncate privoxy log file while debugging


Loading…
Cancel
Save