resharper is cute
ye
This commit is contained in:
parent
813cc76297
commit
a6aa89184d
27 changed files with 229 additions and 150 deletions
|
@ -15,16 +15,24 @@
|
|||
</defaultConnectionFactory>
|
||||
<providers>
|
||||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
|
||||
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider></providers>
|
||||
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=7.0.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider></providers>
|
||||
</entityFramework>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.0.8.0" newVersion="8.0.8.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<system.data>
|
||||
|
||||
<system.data>
|
||||
<DbProviderFactories>
|
||||
<remove invariant="MySql.Data.MySqlClient" />
|
||||
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
|
||||
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=8.0.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
|
||||
</DbProviderFactories>
|
||||
</system.data>
|
||||
</configuration>
|
||||
</system.data></configuration>
|
|
@ -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"];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Origin> Origins { get; set; }
|
||||
public DbSet<Session> Sessions { get; set; }
|
||||
|
||||
|
||||
protected override void OnModelCreating(DbModelBuilder modelBuilder) {
|
||||
base.OnModelCreating(modelBuilder);
|
||||
protected override void OnModelCreating(DbModelBuilder builder) {
|
||||
base.OnModelCreating(builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
<ProjectGuid>{054F172E-9683-40BC-8BDD-7671340EC193}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Square</RootNamespace>
|
||||
<AssemblyName>Square</AssemblyName>
|
||||
<RootNamespace>Glove</RootNamespace>
|
||||
<AssemblyName>Glove</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -7,14 +7,14 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Glove.INI {
|
||||
public class Instance : IEnumerable<KeyValuePair<string, Value>> {
|
||||
private Dictionary<string, Value> Data
|
||||
private readonly Dictionary<string, Value> Data
|
||||
= new Dictionary<string, Value>(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.");
|
||||
|
|
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Glove.INI {
|
||||
public class Section : IEnumerable<Instance> {
|
||||
private List<Instance> Instances = new List<Instance>();
|
||||
private readonly List<Instance> Instances = new List<Instance>();
|
||||
|
||||
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();
|
||||
|
|
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Glove.INI {
|
||||
public class SettingsFile {
|
||||
private Dictionary<string, Section> Sections
|
||||
private readonly Dictionary<string, Section> Sections
|
||||
= new Dictionary<string, Section>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public SettingsFile(string path) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -34,14 +34,14 @@ namespace Kneesocks {
|
|||
get => Enum.GetName(typeof(kStatusCode), StatusCode).Replace('_', ' ');
|
||||
}
|
||||
|
||||
private Dictionary<string, string> Headers =
|
||||
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly Dictionary<string, string> Headers =
|
||||
new Dictionary<string, string>(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);
|
||||
|
|
|
@ -33,11 +33,11 @@ namespace Kneesocks {
|
|||
private int _fullThreadCount;
|
||||
private volatile bool updateFullThreadCount = true;
|
||||
|
||||
private List<ThreadContext> Threads
|
||||
private readonly List<ThreadContext> Threads
|
||||
= new List<ThreadContext>();
|
||||
|
||||
private long InternalCounter = 0;
|
||||
private Dictionary<UInt64, T> Connections
|
||||
private readonly Dictionary<UInt64, T> Connections
|
||||
= new Dictionary<UInt64, T>();
|
||||
|
||||
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<T> 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<T>(this, runWithNoClients, initialConnection);
|
||||
var ctx = new ThreadContext {
|
||||
Stack = stack,
|
||||
Thread = new Thread(new ThreadStart(stack.ManageStack))
|
||||
Thread = new Thread(stack.ManageStack)
|
||||
};
|
||||
|
||||
ctx.Thread.Start();
|
||||
|
|
|
@ -12,25 +12,24 @@ namespace Kneesocks {
|
|||
private List<byte> 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<byte>();
|
||||
}
|
||||
|
||||
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();
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace Kneesocks {
|
|||
public Server(UInt16 port, Pool<T> 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;
|
||||
}
|
||||
|
|
|
@ -7,12 +7,12 @@ using System.Threading;
|
|||
|
||||
namespace Kneesocks {
|
||||
internal class Stack<T> where T : Connection {
|
||||
private Pool<T> PoolRef = null;
|
||||
private List<T> Clients = new List<T>();
|
||||
private bool RunWithNoClients = false;
|
||||
private readonly Pool<T> PoolRef;
|
||||
private readonly List<T> Clients = new List<T>();
|
||||
private readonly bool RunWithNoClients;
|
||||
private bool Running = true;
|
||||
|
||||
public bool Finished { get; private set; } = false;
|
||||
public bool Finished { get; private set; }
|
||||
|
||||
public Stack(Pool<T> poolRef, T initialConnection = null) {
|
||||
PoolRef = poolRef;
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace SockScape.Migrations
|
|||
using System.Data.Entity.Migrations;
|
||||
using System.Linq;
|
||||
|
||||
internal sealed class Configuration : DbMigrationsConfiguration<SockScape.DAL.ScapeDb>
|
||||
internal sealed class Configuration : DbMigrationsConfiguration<DAL.ScapeDb>
|
||||
{
|
||||
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.
|
||||
|
||||
|
|
|
@ -46,28 +46,66 @@
|
|||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
<Reference Include="Microsoft.Win32.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<HintPath>packages\MySql.Data.6.9.9\lib\net45\MySql.Data.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Reference Include="MySql.Data, Version=8.0.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<HintPath>packages\MySql.Data.8.0.8-dmr\lib\net452\MySql.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data.Entity.EF6, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<HintPath>packages\MySql.Data.Entity.6.9.9\lib\net45\MySql.Data.Entity.EF6.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Reference Include="MySql.Data.Entity.EF6, Version=7.0.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<HintPath>packages\MySql.Data.Entity.7.0.7-m61\lib\net451\MySql.Data.Entity.EF6.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.AppContext, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Console, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Console.4.3.0\lib\net46\System.Console.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Globalization.Calendars, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Interactive.Async, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.FileSystem, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.FileSystem.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Sockets, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net46\System.Security.Cryptography.Algorithms.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net46\System.Security.Cryptography.X509Certificates.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -57,11 +57,10 @@ namespace SockScape {
|
|||
return packet;
|
||||
}
|
||||
|
||||
private List<byte[]> Regions = new List<byte[]>();
|
||||
private readonly List<byte[]> Regions = new List<byte[]>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,69 @@
|
|||
<package id="Costura.Fody" version="1.4.0" targetFramework="net46" developmentDependency="true" />
|
||||
<package id="EntityFramework" version="6.1.3" targetFramework="net46" />
|
||||
<package id="Fody" version="2.0.4" targetFramework="net46" developmentDependency="true" />
|
||||
<package id="MySql.Data" version="6.9.9" targetFramework="net46" />
|
||||
<package id="MySql.Data.Entity" version="6.9.9" targetFramework="net46" />
|
||||
<package id="Google.Protobuf" version="3.3.0" targetFramework="net46" />
|
||||
<package id="Microsoft.EntityFrameworkCore" version="1.1.1" targetFramework="net46" />
|
||||
<package id="Microsoft.EntityFrameworkCore.Relational" version="1.1.1" targetFramework="net46" />
|
||||
<package id="Microsoft.Extensions.Caching.Abstractions" version="1.1.1" targetFramework="net46" />
|
||||
<package id="Microsoft.Extensions.Caching.Memory" version="1.1.1" targetFramework="net46" />
|
||||
<package id="Microsoft.Extensions.DependencyInjection" version="1.1.0" targetFramework="net46" />
|
||||
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="1.1.0" targetFramework="net46" />
|
||||
<package id="Microsoft.Extensions.Logging" version="1.1.1" targetFramework="net46" />
|
||||
<package id="Microsoft.Extensions.Logging.Abstractions" version="1.1.1" targetFramework="net46" />
|
||||
<package id="Microsoft.Extensions.Options" version="1.1.1" targetFramework="net46" />
|
||||
<package id="Microsoft.Extensions.Primitives" version="1.1.0" targetFramework="net46" />
|
||||
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net46" />
|
||||
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net46" />
|
||||
<package id="MySql.Data" version="8.0.8-dmr" targetFramework="net46" />
|
||||
<package id="MySql.Data.Entity" version="7.0.7-m61" targetFramework="net46" />
|
||||
<package id="NETStandard.Library" version="1.6.1" targetFramework="net46" />
|
||||
<package id="Remotion.Linq" version="2.1.1" targetFramework="net46" />
|
||||
<package id="System.AppContext" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Collections" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Collections.Immutable" version="1.3.1" targetFramework="net46" />
|
||||
<package id="System.ComponentModel" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Console" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Diagnostics.DiagnosticSource" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Globalization" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Interactive.Async" version="3.0.0" targetFramework="net46" />
|
||||
<package id="System.IO" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.IO.Compression" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Linq" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Linq.Queryable" version="4.0.1" targetFramework="net46" />
|
||||
<package id="System.Net.Http" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Net.Primitives" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Net.Sockets" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.ObjectModel" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Reflection" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Runtime" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Threading" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Threading.Timer" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net46" />
|
||||
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net46" />
|
||||
</packages>
|
Loading…
Reference in a new issue