Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
HMBSbige committed Jul 3, 2019
1 parent aa2b031 commit b88a4ac
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 646 deletions.
510 changes: 0 additions & 510 deletions shadowsocks-csharp/Model/ByteCircularBuffer.cs

This file was deleted.

54 changes: 0 additions & 54 deletions shadowsocks-csharp/Model/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.IO;
using System.Net;
using System.Text;
using System.Windows.Forms;

namespace Shadowsocks.Model
{
Expand Down Expand Up @@ -368,23 +367,6 @@ public Dictionary<int, PortMapConfigCache> GetPortMapCache()
return portMapCache;
}

public static void CheckServer(Server server)
{
CheckPort(server.Server_Port);
if (server.Server_Udp_Port != 0)
CheckPort(server.Server_Udp_Port);
try
{
CheckPassword(server.Password);
}
catch (ConfigurationWarning cw)
{
server.Password = string.Empty;
MessageBox.Show(cw.Message, cw.Message, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
CheckServer(server.server);
}

public Configuration()
{
index = 0;
Expand Down Expand Up @@ -615,26 +597,6 @@ public bool IsDefaultConfig()
return configs.Count == 1 && configs[0].server == GetDefaultServer().server;
}

public static Server CopyServer(Server server)
{
var s = new Server
{
server = server.server,
Server_Port = server.Server_Port,
Method = server.Method,
Protocol = server.Protocol,
ProtocolParam = server.ProtocolParam ?? string.Empty,
obfs = server.obfs,
ObfsParam = server.ObfsParam ?? string.Empty,
Password = server.Password,
Remarks = server.Remarks,
Group = server.Group,
UdpOverTcp = server.UdpOverTcp,
Server_Udp_Port = server.Server_Udp_Port
};
return s;
}

private static Server GetErrorServer()
{
var server = new Server { server = "invalid" };
Expand All @@ -649,22 +611,6 @@ public static void CheckPort(int port)
}
}

private static void CheckPassword(string password)
{
if (string.IsNullOrEmpty(password))
{
throw new ConfigurationWarning(I18N.GetString("Password are blank"));
}
}

private static void CheckServer(string server)
{
if (string.IsNullOrEmpty(server))
{
throw new ConfigurationException(I18N.GetString("Server IP can not be blank"));
}
}

}

[Serializable]
Expand Down
12 changes: 1 addition & 11 deletions shadowsocks-csharp/Model/Connections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,7 @@ public void CloseAll()
}
catch
{

}
}
}
public int Count
{
get
{
lock (this)
{
return sockets.Count;
// ignored
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion shadowsocks-csharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal static class Program
[STAThread]
private static void Main(string[] args)
{
Directory.SetCurrentDirectory(Path.GetDirectoryName(Utils.GetExecutablePath()));
Directory.SetCurrentDirectory(Path.GetDirectoryName(Utils.GetExecutablePath()) ?? throw new InvalidOperationException());
if (args.Any(arg => arg == @"--setautorun"))
{
if (!AutoStartup.Switch())
Expand Down
3 changes: 0 additions & 3 deletions shadowsocks-csharp/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@
<data name="ss24" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ss24.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ssw128" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ssw128.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="user_rule" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\data\user-rule.txt;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
Expand Down
Binary file removed shadowsocks-csharp/Resources/ssw128.png
Binary file not shown.
52 changes: 0 additions & 52 deletions shadowsocks-csharp/Util/ServerName.cs

This file was deleted.

15 changes: 2 additions & 13 deletions shadowsocks-csharp/Util/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ private static IPAddress Query(string host, string dnsServers, bool IPv6_first =
{
UseCache = false
};
IPAddress r = null;
IPAddress r;
if (IPv6_first)
{
try
Expand Down Expand Up @@ -528,7 +528,7 @@ public static string GetExecutablePath()
}

var dllPath = GetDllPath();
return Path.Combine(Path.GetDirectoryName(dllPath), $@"{Path.GetFileNameWithoutExtension(dllPath)}.exe");
return Path.Combine(Path.GetDirectoryName(dllPath) ?? throw new InvalidOperationException(), $@"{Path.GetFileNameWithoutExtension(dllPath)}.exe");
}

public static string GetDllPath()
Expand Down Expand Up @@ -573,17 +573,6 @@ public static int RunAsAdmin(string Arguments)
return -1;
}

public static int GetDpiMul()
{
int dpi;
using (var graphics = Graphics.FromHwnd(IntPtr.Zero))
{
dpi = (int)graphics.DpiX;
}

return (dpi * 4 + 48) / 96;
}

private static string _tempPath;

// return path to store temporary files
Expand Down
2 changes: 1 addition & 1 deletion shadowsocks-csharp/View/MenuViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ private void AboutItem_Click(object sender, EventArgs e)
Utils.OpenURL("https://github.com/HMBSbige/ShadowsocksR-Windows");
}

[DllImport("user32.dll")]
[DllImport(@"user32.dll")]
private static extern short GetAsyncKeyState(Keys vKey);

private void notifyIcon1_Click(object sender, MouseEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion shadowsocks-csharp/View/ShowTextWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBox x:Name="TextBox" Grid.Row="0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" AcceptsReturn="True" AcceptsTab="True" />
<Image x:Name="PictureQrCode" Grid.Row="1" Stretch="None" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
<Image x:Name="PictureQrCode" Grid.Row="1" Stretch="Uniform" StretchDirection="Both" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>

</Grid>
</Window>

0 comments on commit b88a4ac

Please sign in to comment.