Browse Source

Misc

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
tags/3.3
Syrone Wong 9 years ago
parent
commit
f70b177e56
5 changed files with 25 additions and 18 deletions
  1. +12
    -12
      shadowsocks-csharp/Controller/Logging.cs
  2. +4
    -3
      shadowsocks-csharp/Controller/Service/PACServer.cs
  3. +7
    -1
      shadowsocks-csharp/Controller/Service/TCPRelay.cs
  4. +1
    -1
      shadowsocks-csharp/Controller/Service/UpdateChecker.cs
  5. +1
    -1
      shadowsocks-csharp/View/LogForm.cs

+ 12
- 12
shadowsocks-csharp/Controller/Logging.cs View File

@@ -12,8 +12,8 @@ namespace Shadowsocks.Controller
{
public static string LogFilePath;
private static FileStream fs;
private static StreamWriterWithTimestamp sw;
private static FileStream _fs;
private static StreamWriterWithTimestamp _sw;
public static bool OpenLogFile()
{
@@ -21,11 +21,11 @@ namespace Shadowsocks.Controller
{
LogFilePath = Utils.GetTempPath("shadowsocks.log");
fs = new FileStream(LogFilePath, FileMode.Append);
sw = new StreamWriterWithTimestamp(fs);
sw.AutoFlush = true;
Console.SetOut(sw);
Console.SetError(sw);
_fs = new FileStream(LogFilePath, FileMode.Append);
_sw = new StreamWriterWithTimestamp(_fs);
_sw.AutoFlush = true;
Console.SetOut(_sw);
Console.SetError(_sw);
return true;
}
@@ -54,11 +54,11 @@ namespace Shadowsocks.Controller
WriteToLogFile(o);
}
public static void clear() {
sw.Close();
sw.Dispose();
fs.Close();
fs.Dispose();
public static void Clear() {
_sw.Close();
_sw.Dispose();
_fs.Close();
_fs.Dispose();
File.Delete(LogFilePath);
OpenLogFile();
}


+ 4
- 3
shadowsocks-csharp/Controller/Service/PACServer.cs View File

@@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Globalization;
using System.IO;
using System.Net;
using System.Net.Sockets;
@@ -69,7 +70,7 @@ namespace Shadowsocks.Controller
}
else if (kv.Length == 1)
{
if (line.IndexOf("pac") >= 0)
if (line.IndexOf("pac", StringComparison.Ordinal) >= 0)
{
pathMatch = true;
}
@@ -207,7 +208,7 @@ Connection: Close
private void PACFileWatcher_Changed(object sender, FileSystemEventArgs e)
{
string path = e.FullPath.ToString();
string currentLastWriteTime = File.GetLastWriteTime(e.FullPath).ToString();
string currentLastWriteTime = File.GetLastWriteTime(e.FullPath).ToString(CultureInfo.InvariantCulture);
// if there is no path info stored yet or stored path has different time of write then the one now is inspected
if (!fileChangedTime.ContainsKey(path) || fileChangedTime[path].ToString() != currentLastWriteTime)
@@ -226,7 +227,7 @@ Connection: Close
private void UserRuleFileWatcher_Changed(object sender, FileSystemEventArgs e)
{
string path = e.FullPath.ToString();
string currentLastWriteTime = File.GetLastWriteTime(e.FullPath).ToString();
string currentLastWriteTime = File.GetLastWriteTime(e.FullPath).ToString(CultureInfo.InvariantCulture);
// if there is no path info stored yet or stored path has different time of write then the one now is inspected
if (!fileChangedTime.ContainsKey(path) || fileChangedTime[path].ToString() != currentLastWriteTime)


+ 7
- 1
shadowsocks-csharp/Controller/Service/TCPRelay.cs View File

@@ -176,7 +176,13 @@ namespace Shadowsocks.Controller
Server server = controller.GetAServer(IStrategyCallerType.TCP, (IPEndPoint)connection.RemoteEndPoint);
if (server == null || server.server == "")
throw new ArgumentException("No server configured");
encryptor = EncryptorFactory.GetEncryptor(server.method, server.password, server.auth, false);
lock (_encryptionLock)
{
lock (_decryptionLock)
{
encryptor = EncryptorFactory.GetEncryptor(server.method, server.password, server.auth, false);
}
}
this.server = server;
}


+ 1
- 1
shadowsocks-csharp/Controller/Service/UpdateChecker.cs View File

@@ -198,7 +198,7 @@ namespace Shadowsocks.Controller
name = (string)asset["name"];
browser_download_url = (string)asset["browser_download_url"];
version = ParseVersionFromURL(browser_download_url);
prerelease = browser_download_url.IndexOf("prerelease") >= 0;
prerelease = browser_download_url.IndexOf("prerelease", StringComparison.Ordinal) >= 0;
}
private static string ParseVersionFromURL(string url)


+ 1
- 1
shadowsocks-csharp/View/LogForm.cs View File

@@ -247,7 +247,7 @@ namespace Shadowsocks.View
#region Clean up the content in LogMessageTextBox.
private void DoCleanLogs()
{
Logging.clear();
Logging.Clear();
lastOffset = 0;
LogMessageTextBox.Clear();
}


Loading…
Cancel
Save