From a6aa89184d6be2e38cdd1cff6f57a6510db7aa9e Mon Sep 17 00:00:00 2001 From: Malloc of Kuzkycyziklistan Date: Mon, 21 Aug 2017 16:03:32 -0500 Subject: [PATCH] resharper is cute ye --- server/App.config | 18 ++++-- server/Configuration.cs | 29 ++++------ server/DAL/Origin.cs | 10 ++-- server/DAL/ScapeDb.cs | 6 +- server/DAL/Session.cs | 12 ++-- server/DAL/User.cs | 2 + server/Encryption/Cipher.cs | 4 +- server/Encryption/KeyExchange.cs | 15 +++-- server/Libraries/Glove/Glove.csproj | 4 +- server/Libraries/Glove/INI/Instance.cs | 4 +- server/Libraries/Glove/INI/Section.cs | 22 ++----- server/Libraries/Glove/INI/SettingsFile.cs | 2 +- server/Libraries/Glove/INI/Value.cs | 6 +- server/Libraries/Glove/RandomContext.cs | 3 +- server/Libraries/Kneesocks/Connection.cs | 28 ++++----- server/Libraries/Kneesocks/Frame.cs | 4 +- server/Libraries/Kneesocks/Handshake.cs | 12 ++-- server/Libraries/Kneesocks/Pool.cs | 16 +++--- server/Libraries/Kneesocks/ReadBuffer.cs | 11 ++-- server/Libraries/Kneesocks/Server.cs | 2 +- server/Libraries/Kneesocks/Stack.cs | 8 +-- server/Migrations/Configuration.cs | 4 +- server/SockScape.csproj | 58 +++++++++++++++---- server/Socks/MasterConnection.cs | 2 +- server/Socks/MasterUdpServer.cs | 6 +- server/Socks/Protocols/Packet.cs | 24 ++++---- server/packages.config | 67 +++++++++++++++++++++- 27 files changed, 229 insertions(+), 150 deletions(-) diff --git a/server/App.config b/server/App.config index eb0f533..8a3524e 100644 --- a/server/App.config +++ b/server/App.config @@ -15,16 +15,24 @@ - + + + + + + + + + - + + - + - - \ No newline at end of file + \ No newline at end of file diff --git a/server/Configuration.cs b/server/Configuration.cs index b3f5958..d6c269b 100644 --- a/server/Configuration.cs +++ b/server/Configuration.cs @@ -7,7 +7,7 @@ using Glove.INI; namespace SockScape { public static class Configuration { - private static SettingsFile Settings; + private static readonly SettingsFile Settings; static Configuration() { Settings = new SettingsFile( @@ -16,7 +16,7 @@ namespace SockScape { new SectionRules { Name = "General", Required = true, - RequiredFields = new string[] { + RequiredFields = new[] { "Run Master", "Master Port", "Master Addr", @@ -27,7 +27,7 @@ namespace SockScape { new SectionRules { Name = "Database", Required = true, - RequiredFields = new string[] { + RequiredFields = new[] { "Server", "Username", "Password", @@ -39,7 +39,7 @@ namespace SockScape { Name = "Server", AllowMultiple = true, Required = true, - RequiredFields = new string[] { + RequiredFields = new[] { "Id", "Port" } @@ -52,22 +52,13 @@ namespace SockScape { return Settings[section]; } - public static Instance General { - get { - return Settings["General"][0]; - } - } + public static Instance General + => Settings["General"][0]; - public static Instance Database { - get { - return Settings["Database"][0]; - } - } + public static Instance Database + => Settings["Database"][0]; - public static Section Servers { - get { - return Settings["Server"]; - } - } + public static Section Servers + => Settings["Server"]; } } diff --git a/server/DAL/Origin.cs b/server/DAL/Origin.cs index 1d639d1..6793982 100644 --- a/server/DAL/Origin.cs +++ b/server/DAL/Origin.cs @@ -15,13 +15,11 @@ namespace SockScape.DAL { public virtual User User { get; set; } protected string RawIp { get; set; } + + [NotMapped] public IPAddress Ip { - get { - return IPAddress.Parse(RawIp); - } - set { - RawIp = value.ToString(); - } + get => IPAddress.Parse(RawIp); + set => RawIp = value.ToString(); } } } diff --git a/server/DAL/ScapeDb.cs b/server/DAL/ScapeDb.cs index 81005f0..2370672 100644 --- a/server/DAL/ScapeDb.cs +++ b/server/DAL/ScapeDb.cs @@ -13,6 +13,7 @@ namespace SockScape.DAL { public ScapeDb() : base("server="+ Config.Database["Server"] + +";port="+ (Config.Database["Port"] ?? "3306") +";user id="+ Config.Database["Username"] +";password="+ Config.Database["Password"] +";persistsecurityinfo=True;" @@ -25,9 +26,8 @@ namespace SockScape.DAL { public DbSet Origins { get; set; } public DbSet Sessions { get; set; } - - protected override void OnModelCreating(DbModelBuilder modelBuilder) { - base.OnModelCreating(modelBuilder); + protected override void OnModelCreating(DbModelBuilder builder) { + base.OnModelCreating(builder); } } } diff --git a/server/DAL/Session.cs b/server/DAL/Session.cs index 1cfca6c..09abde8 100644 --- a/server/DAL/Session.cs +++ b/server/DAL/Session.cs @@ -14,14 +14,14 @@ namespace SockScape.DAL { public int UserId { get; set; } public virtual User User { get; set; } + + protected string RawIp { get; set; } + + [NotMapped] public IPAddress Ip { - get { - return IPAddress.Parse(RawIp); - } - set { - RawIp = value.ToString(); - } + get => IPAddress.Parse(RawIp); + set => RawIp = value.ToString(); } public int ServerId { get; set; } diff --git a/server/DAL/User.cs b/server/DAL/User.cs index 6ce1188..6b438cb 100644 --- a/server/DAL/User.cs +++ b/server/DAL/User.cs @@ -10,9 +10,11 @@ namespace SockScape.DAL { public long Id { get; set; } [Required] + [MaxLength(16)] public string Username { get; set; } [Required] + [MaxLength(256)] public string Password { get; set; } [Required] diff --git a/server/Encryption/Cipher.cs b/server/Encryption/Cipher.cs index 6fdd81a..d94d199 100644 --- a/server/Encryption/Cipher.cs +++ b/server/Encryption/Cipher.cs @@ -8,8 +8,8 @@ using Glove; namespace SockScape.Encryption { class Cipher { - private byte[] Key = new byte[512 / 8]; - private byte[] State = new byte[256]; + private readonly byte[] Key = new byte[512 / 8]; + private readonly byte[] State = new byte[256]; public Cipher(BigInteger key) { int i = 0, j = 0; diff --git a/server/Encryption/KeyExchange.cs b/server/Encryption/KeyExchange.cs index 605a3ce..cf69e8b 100644 --- a/server/Encryption/KeyExchange.cs +++ b/server/Encryption/KeyExchange.cs @@ -9,13 +9,12 @@ using System.Globalization; namespace SockScape.Encryption { class Key { - private readonly static BigInteger Secret = RNG.NextPrime(512 / 8); - public BigInteger Generator { get; private set; } = 2; - public BigInteger Modulus { get; private set; } + private static readonly BigInteger Secret = RNG.NextPrime(512 / 8); + public BigInteger Generator { get; } = 2; + public BigInteger Modulus { get; } public BigInteger PrivateKey { get; private set; } = BigInteger.Zero; - public bool Succeeded { - get => !PrivateKey.IsZero; - } + public bool Succeeded + => !PrivateKey.IsZero; public Key() { Modulus = RNG.NextPrime(512 / 8); @@ -34,7 +33,7 @@ namespace SockScape.Encryption { if(packet.Id != 1 || packet.RegionCount != 3) return null; - bool check = BigInteger.TryParse(packet[0], NumberStyles.HexNumber, + var check = BigInteger.TryParse(packet[0], NumberStyles.HexNumber, NumberFormatInfo.InvariantInfo, out BigInteger generator); check &= BigInteger.TryParse(packet[1], NumberStyles.HexNumber, NumberFormatInfo.InvariantInfo, out BigInteger modulus); @@ -59,7 +58,7 @@ namespace SockScape.Encryption { if(!BigInteger.TryParse(packet[0], NumberStyles.HexNumber, NumberFormatInfo.InvariantInfo, out BigInteger clientKey)) return -1; - return (PrivateKey = BigInteger.ModPow(clientKey, Secret, Modulus)); + return PrivateKey = BigInteger.ModPow(clientKey, Secret, Modulus); } } } diff --git a/server/Libraries/Glove/Glove.csproj b/server/Libraries/Glove/Glove.csproj index 2cea401..7de4a48 100644 --- a/server/Libraries/Glove/Glove.csproj +++ b/server/Libraries/Glove/Glove.csproj @@ -7,8 +7,8 @@ {054F172E-9683-40BC-8BDD-7671340EC193} Library Properties - Square - Square + Glove + Glove v4.5.2 512 diff --git a/server/Libraries/Glove/INI/Instance.cs b/server/Libraries/Glove/INI/Instance.cs index 4d343c8..379c29c 100644 --- a/server/Libraries/Glove/INI/Instance.cs +++ b/server/Libraries/Glove/INI/Instance.cs @@ -7,14 +7,14 @@ using System.Threading.Tasks; namespace Glove.INI { public class Instance : IEnumerable> { - private Dictionary Data + private readonly Dictionary Data = new Dictionary(StringComparer.OrdinalIgnoreCase); internal Instance() { } internal void Push(string line) { if(line.Contains('=')) { - var parts = line.Split(new char[] { '=' }, 2); + var parts = line.Split(new[] { '=' }, 2); Data.Add(parts[0].Trim(), new Value(parts[1].Trim())); } else throw new FormatException("Line is not a key-value pair delimited by an equals sign."); diff --git a/server/Libraries/Glove/INI/Section.cs b/server/Libraries/Glove/INI/Section.cs index c25ef9e..e24e864 100644 --- a/server/Libraries/Glove/INI/Section.cs +++ b/server/Libraries/Glove/INI/Section.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Glove.INI { public class Section : IEnumerable { - private List Instances = new List(); + private readonly List Instances = new List(); internal Section() { } @@ -16,23 +16,13 @@ namespace Glove.INI { return Instances[Instances.Count - 1]; } - public string this[string key] { - get { - return Instances[0][key]; - } - } + public string this[string key] + => Instances[0][key]; - public Instance this[int i] { - get { - return Instances[i]; - } - } + public Instance this[int i] + => Instances[i]; - public int Count { - get { - return Instances.Count; - } - } + public int Count => Instances.Count; IEnumerator IEnumerable.GetEnumerator() { return Instances.GetEnumerator(); diff --git a/server/Libraries/Glove/INI/SettingsFile.cs b/server/Libraries/Glove/INI/SettingsFile.cs index 1134d05..2f8e990 100644 --- a/server/Libraries/Glove/INI/SettingsFile.cs +++ b/server/Libraries/Glove/INI/SettingsFile.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Glove.INI { public class SettingsFile { - private Dictionary Sections + private readonly Dictionary Sections = new Dictionary(StringComparer.OrdinalIgnoreCase); public SettingsFile(string path) { diff --git a/server/Libraries/Glove/INI/Value.cs b/server/Libraries/Glove/INI/Value.cs index 2ab74a7..d820785 100644 --- a/server/Libraries/Glove/INI/Value.cs +++ b/server/Libraries/Glove/INI/Value.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Glove.INI { public class Value { - private string Raw; + private readonly string Raw; public Value(string raw) { Raw = raw; @@ -17,9 +17,7 @@ namespace Glove.INI { } public static implicit operator bool(Value value) { - return Boolean.TryParse(value.Raw, out bool retval) - ? retval - : false; + return Boolean.TryParse(value.Raw, out bool retval) && retval; } public static implicit operator Int32(Value value) { diff --git a/server/Libraries/Glove/RandomContext.cs b/server/Libraries/Glove/RandomContext.cs index 07040d1..53a49b5 100644 --- a/server/Libraries/Glove/RandomContext.cs +++ b/server/Libraries/Glove/RandomContext.cs @@ -7,7 +7,8 @@ using System.Numerics; namespace Glove { public static class RNG { - private static Random RandCtx = new Random(); + // TODO add cryptographically secure rng + private static readonly Random RandCtx = new Random(); public static int Next() { lock(RandCtx) { diff --git a/server/Libraries/Kneesocks/Connection.cs b/server/Libraries/Kneesocks/Connection.cs index 22cba31..c8ad887 100644 --- a/server/Libraries/Kneesocks/Connection.cs +++ b/server/Libraries/Kneesocks/Connection.cs @@ -17,17 +17,16 @@ namespace Kneesocks { get { if(_Id == null) throw new ArgumentNullException(); - else - return (UInt64)_Id; + + return (UInt64)_Id; } set { if(_Id == null) _Id = value; } } - internal bool IsIdNull { - get => _Id == null; - } + internal bool IsIdNull + => _Id == null; private TcpClient Socket = null; private NetworkStream Stream = null; @@ -43,12 +42,11 @@ namespace Kneesocks { protected const int PingInterval = 30; protected const int TimeoutInterval = 120; - private byte[] PingData = Encoding.ASCII.GetBytes("woomy!"); + private readonly byte[] PingData = Encoding.ASCII.GetBytes("woomy!"); private DateTime LastPing; private bool AwaitingPingResponse = false; - private TimeSpan TimeSinceLastPing { - get => DateTime.UtcNow - LastPing; - } + private TimeSpan TimeSinceLastPing + => DateTime.UtcNow - LastPing; internal bool OutsidePool = false; public bool Disconnected { get; private set; } = false; @@ -57,11 +55,8 @@ namespace Kneesocks { public bool Handshaked { get; private set; } = false; public Handshake ClientHandshake { get; private set; } = null; - public IPAddress IP { - get { - return ((IPEndPoint)Socket.Client.RemoteEndPoint).Address; - } - } + public IPAddress IP + => ((IPEndPoint)Socket.Client.RemoteEndPoint).Address; public void Initialize(TcpClient sock) { if(Initialized) @@ -117,7 +112,7 @@ namespace Kneesocks { int frameCount = singleFrame ? 0 : (message.Length / MaximumSendFrameSize); for(var i = 0; i <= frameCount; ++i) { SendFrameBuffer.Add(new Frame { - IsFinal = (i == frameCount && isFinal) ? true : false, + IsFinal = (i == frameCount && isFinal), IsMasked = false, Opcode = (i == 0 || (singleFrame && first)) ? Frame.kOpcode.BinaryFrame : Frame.kOpcode.Continuation, Content = message.Subset(i * (MaximumSendFrameSize + 1), MaximumSendFrameSize) @@ -143,10 +138,9 @@ namespace Kneesocks { if(stream.Position == stream.Length) { _Send(bytesRead == MaximumSendFrameSize ? byteBuffer : byteBuffer.Take(bytesRead).ToArray(), true, true, firstRead); return; - } else { - _Send(bytesRead == MaximumSendFrameSize ? byteBuffer : byteBuffer.Take(bytesRead).ToArray(), false, true, firstRead); } + _Send(bytesRead == MaximumSendFrameSize ? byteBuffer : byteBuffer.Take(bytesRead).ToArray(), false, true, firstRead); firstRead = false; } } diff --git a/server/Libraries/Kneesocks/Frame.cs b/server/Libraries/Kneesocks/Frame.cs index 8992074..506e7a7 100644 --- a/server/Libraries/Kneesocks/Frame.cs +++ b/server/Libraries/Kneesocks/Frame.cs @@ -50,7 +50,7 @@ namespace Kneesocks { private int _BodyLength = 0; public int BodyLength { - get => Content == null ? _BodyLength : Content.Length; + get => Content?.Length ?? _BodyLength; } public byte[] Content { get; set; } = null; @@ -159,7 +159,7 @@ namespace Kneesocks { throw new FormatException("Raw frame length ("+ (uint)raw.Length + ") is less than described size ("+ expectedFrameLength + ")"); returnFrame.Content = new byte[returnFrame.BodyLength]; - Array.Copy(raw, returnFrame.HeaderLength, returnFrame.Content, 0L, (long)returnFrame.BodyLength); + Array.Copy(raw, returnFrame.HeaderLength, returnFrame.Content, 0L, returnFrame.BodyLength); if(returnFrame.IsMasked) returnFrame.Content = returnFrame.MaskedContent; diff --git a/server/Libraries/Kneesocks/Handshake.cs b/server/Libraries/Kneesocks/Handshake.cs index e9827d9..410c11c 100644 --- a/server/Libraries/Kneesocks/Handshake.cs +++ b/server/Libraries/Kneesocks/Handshake.cs @@ -34,14 +34,14 @@ namespace Kneesocks { get => Enum.GetName(typeof(kStatusCode), StatusCode).Replace('_', ' '); } - private Dictionary Headers = - new Dictionary(StringComparer.OrdinalIgnoreCase); + private readonly Dictionary Headers = + new Dictionary(StringComparer.OrdinalIgnoreCase); public string Content { get; set; } = null; public Handshake(string rawData) { IsRequest = true; - var headerLength = rawData.IndexOf("\r\n\r\n"); + var headerLength = rawData.IndexOf("\r\n\r\n", StringComparison.InvariantCulture); if(headerLength == -1) throw new FormatException("Header delimeter not found in raw data"); @@ -57,14 +57,14 @@ namespace Kneesocks { if(parts.Length < 3) throw new FormatException("Status line in header malformed"); } else { - parts = line.Trim().Split(new char[] {':'}, 2); + parts = line.Trim().Split(new[] {':'}, 2); if(parts.Length == 2) Headers.Add(parts[0].Trim(), parts[1].Trim()); } } if(Headers.ContainsKey("Content-Length")) { - rawData.Substring(headerLength + 4, int.Parse(Headers["Content-Length"])); + Content = rawData.Substring(headerLength + 4, int.Parse(Headers["Content-Length"])); } else { if(rawData.Length > headerLength + 4) Content = rawData.Substring(headerLength + 4); @@ -106,7 +106,7 @@ namespace Kneesocks { var raw = "HTTP/"+ HttpVersion +" "+ (int)StatusCode + " "+ StatusCodeText +"\r\n"; foreach(var header in Headers) raw += header.Key.Trim() + ": " + header.Value.Trim() + "\r\n"; - return raw += "\r\n"; + return raw + "\r\n"; } public bool HasHeader(string name) => Headers.ContainsKey(name); diff --git a/server/Libraries/Kneesocks/Pool.cs b/server/Libraries/Kneesocks/Pool.cs index 364e50d..6bcfc86 100644 --- a/server/Libraries/Kneesocks/Pool.cs +++ b/server/Libraries/Kneesocks/Pool.cs @@ -33,11 +33,11 @@ namespace Kneesocks { private int _fullThreadCount; private volatile bool updateFullThreadCount = true; - private List Threads + private readonly List Threads = new List(); private long InternalCounter = 0; - private Dictionary Connections + private readonly Dictionary Connections = new Dictionary(); public Pool() { @@ -47,9 +47,11 @@ namespace Kneesocks { public T this[UInt64 id] { get { - if(HasConnection(id)) - return Connections[id]; - else return null; + lock (Connections) { + if (HasConnection(id)) + return Connections[id]; + else return null; + } } } @@ -108,7 +110,7 @@ namespace Kneesocks { internal void InvalidateThread(Stack stackRef) { lock(Threads) { - var ctx = Threads.FirstOrDefault(x => Object.ReferenceEquals(x.Stack, stackRef)); + var ctx = Threads.FirstOrDefault(x => ReferenceEquals(x.Stack, stackRef)); if(ctx != null) { Threads.Remove(ctx); updateFullThreadCount = true; @@ -120,7 +122,7 @@ namespace Kneesocks { var stack = new Stack(this, runWithNoClients, initialConnection); var ctx = new ThreadContext { Stack = stack, - Thread = new Thread(new ThreadStart(stack.ManageStack)) + Thread = new Thread(stack.ManageStack) }; ctx.Thread.Start(); diff --git a/server/Libraries/Kneesocks/ReadBuffer.cs b/server/Libraries/Kneesocks/ReadBuffer.cs index b9ef5a5..f968242 100644 --- a/server/Libraries/Kneesocks/ReadBuffer.cs +++ b/server/Libraries/Kneesocks/ReadBuffer.cs @@ -12,25 +12,24 @@ namespace Kneesocks { private List Buffer; private int ExpectedLength; private string ExpectedString; - private NetworkStream Source; + private readonly NetworkStream Source; private DateTime StartTime; - public bool IsReading { get; private set; } = false; + public bool IsReading { get; private set; } public ReadBuffer(NetworkStream source) { Source = source; Buffer = new List(); } - public TimeSpan ElapsedReadTime { - get => DateTime.UtcNow - StartTime; - } + public TimeSpan ElapsedReadTime + => DateTime.UtcNow - StartTime; private byte[] CheckBuffer() { byte[] returnValue = null; if(ExpectedString != null) { - var location = Encoding.ASCII.GetString(Buffer.ToArray()).IndexOf(ExpectedString); + var location = Encoding.ASCII.GetString(Buffer.ToArray()).IndexOf(ExpectedString, StringComparison.InvariantCulture); if(location != -1) { var fullJump = location + ExpectedString.Length; returnValue = Buffer.Take(fullJump).ToArray(); diff --git a/server/Libraries/Kneesocks/Server.cs b/server/Libraries/Kneesocks/Server.cs index e31c208..ac9b7cb 100644 --- a/server/Libraries/Kneesocks/Server.cs +++ b/server/Libraries/Kneesocks/Server.cs @@ -35,7 +35,7 @@ namespace Kneesocks { public Server(UInt16 port, Pool pool, object config = null) { Port = port; Socket = new TcpListener(IPAddress.Any, port); - Listener = new Thread(new ThreadStart(ListenThread)); + Listener = new Thread(ListenThread); ConnectionPool = pool; Configuration = config; } diff --git a/server/Libraries/Kneesocks/Stack.cs b/server/Libraries/Kneesocks/Stack.cs index 4630fd5..0f3fc0f 100644 --- a/server/Libraries/Kneesocks/Stack.cs +++ b/server/Libraries/Kneesocks/Stack.cs @@ -7,12 +7,12 @@ using System.Threading; namespace Kneesocks { internal class Stack where T : Connection { - private Pool PoolRef = null; - private List Clients = new List(); - private bool RunWithNoClients = false; + private readonly Pool PoolRef; + private readonly List Clients = new List(); + private readonly bool RunWithNoClients; private bool Running = true; - public bool Finished { get; private set; } = false; + public bool Finished { get; private set; } public Stack(Pool poolRef, T initialConnection = null) { PoolRef = poolRef; diff --git a/server/Migrations/Configuration.cs b/server/Migrations/Configuration.cs index c3ac6e9..2e1523a 100644 --- a/server/Migrations/Configuration.cs +++ b/server/Migrations/Configuration.cs @@ -5,7 +5,7 @@ namespace SockScape.Migrations using System.Data.Entity.Migrations; using System.Linq; - internal sealed class Configuration : DbMigrationsConfiguration + internal sealed class Configuration : DbMigrationsConfiguration { public Configuration() { @@ -13,7 +13,7 @@ namespace SockScape.Migrations AutomaticMigrationsEnabled = false; } - protected override void Seed(SockScape.DAL.ScapeDb context) + protected override void Seed(DAL.ScapeDb context) { // This method will be called after migrating to the latest version. diff --git a/server/SockScape.csproj b/server/SockScape.csproj index 3a01b33..99e0a5b 100644 --- a/server/SockScape.csproj +++ b/server/SockScape.csproj @@ -46,28 +46,66 @@ packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll - - packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll + + packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll - - packages\MySql.Data.6.9.9\lib\net45\MySql.Data.dll - True + + packages\MySql.Data.8.0.8-dmr\lib\net452\MySql.Data.dll - - packages\MySql.Data.Entity.6.9.9\lib\net45\MySql.Data.Entity.EF6.dll - True + + packages\MySql.Data.Entity.7.0.7-m61\lib\net451\MySql.Data.Entity.EF6.dll + + packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll + + + packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll + True + + + + packages\System.Console.4.3.0\lib\net46\System.Console.dll + + + packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll + + + packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll + + + packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll + + + packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll + + + packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll + + + packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll + + + packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net46\System.Security.Cryptography.Algorithms.dll + + + packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net46\System.Security.Cryptography.X509Certificates.dll + + - - diff --git a/server/Socks/MasterConnection.cs b/server/Socks/MasterConnection.cs index 5af8b9f..fc4533e 100644 --- a/server/Socks/MasterConnection.cs +++ b/server/Socks/MasterConnection.cs @@ -10,7 +10,7 @@ using SockScape.Encryption; namespace SockScape { class MasterConnection : Connection { private Key Key; - public Cipher Encryptor { get; private set; } = null; + public Cipher Encryptor { get; private set; } protected override void OnOpen() { Key = new Key(); diff --git a/server/Socks/MasterUdpServer.cs b/server/Socks/MasterUdpServer.cs index 4a5fafd..cc152eb 100644 --- a/server/Socks/MasterUdpServer.cs +++ b/server/Socks/MasterUdpServer.cs @@ -10,8 +10,8 @@ using System.Threading.Tasks; namespace SockScape.Socks { static class MasterUdpServer { private static UdpClient Sock; - private static Thread ListeningThread = null; - private static bool IsOpen = false; + private static Thread ListeningThread; + private static bool IsOpen; public static void Initialize() { if(!IsOpen && ListeningThread == null) @@ -21,7 +21,7 @@ namespace SockScape.Socks { Sock = new UdpClient(port); IsOpen = true; - ListeningThread = new Thread(new ThreadStart(Listener)); + ListeningThread = new Thread(Listener); ListeningThread.Start(); } diff --git a/server/Socks/Protocols/Packet.cs b/server/Socks/Protocols/Packet.cs index a98abf7..1c54f6c 100644 --- a/server/Socks/Protocols/Packet.cs +++ b/server/Socks/Protocols/Packet.cs @@ -57,11 +57,10 @@ namespace SockScape { return packet; } - private List Regions = new List(); + private readonly List Regions = new List(); public int Id { get; private set; } - public int RegionCount { - get => Regions.Count; - } + public int RegionCount + => Regions.Count; protected Packet() { } @@ -72,9 +71,8 @@ namespace SockScape { AddRegion(region); } - public Region this[int i] { - get => new Region(Regions[i]); - } + public Region this[int i] + => new Region(Regions[i]); public Packet AddRegion(object region) { if(region.GetType() == typeof(byte[])) @@ -110,16 +108,15 @@ namespace SockScape { } public class Region { - public byte[] Data { get; private set; } + public byte[] Data { get; } public Region(byte[] data) { Data = data; } public static implicit operator byte[] (Region region) => region.Data; - public string Bytes { - get => this; - } + public string Bytes + => this; public static implicit operator string(Region region) { try { @@ -128,9 +125,8 @@ namespace SockScape { return Encoding.ASCII.GetString(region.Data); } } - public string Str { - get => this; - } + public string Str + => this; } } } diff --git a/server/packages.config b/server/packages.config index e535184..0c99cf2 100644 --- a/server/packages.config +++ b/server/packages.config @@ -3,6 +3,69 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file