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>
|
</defaultConnectionFactory>
|
||||||
<providers>
|
<providers>
|
||||||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
|
<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>
|
</entityFramework>
|
||||||
<runtime>
|
<runtime>
|
||||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
<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>
|
</assemblyBinding>
|
||||||
</runtime>
|
</runtime>
|
||||||
<system.data>
|
|
||||||
|
<system.data>
|
||||||
<DbProviderFactories>
|
<DbProviderFactories>
|
||||||
<remove invariant="MySql.Data.MySqlClient" />
|
<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>
|
</DbProviderFactories>
|
||||||
</system.data>
|
</system.data></configuration>
|
||||||
</configuration>
|
|
|
@ -7,7 +7,7 @@ using Glove.INI;
|
||||||
|
|
||||||
namespace SockScape {
|
namespace SockScape {
|
||||||
public static class Configuration {
|
public static class Configuration {
|
||||||
private static SettingsFile Settings;
|
private static readonly SettingsFile Settings;
|
||||||
|
|
||||||
static Configuration() {
|
static Configuration() {
|
||||||
Settings = new SettingsFile(
|
Settings = new SettingsFile(
|
||||||
|
@ -16,7 +16,7 @@ namespace SockScape {
|
||||||
new SectionRules {
|
new SectionRules {
|
||||||
Name = "General",
|
Name = "General",
|
||||||
Required = true,
|
Required = true,
|
||||||
RequiredFields = new string[] {
|
RequiredFields = new[] {
|
||||||
"Run Master",
|
"Run Master",
|
||||||
"Master Port",
|
"Master Port",
|
||||||
"Master Addr",
|
"Master Addr",
|
||||||
|
@ -27,7 +27,7 @@ namespace SockScape {
|
||||||
new SectionRules {
|
new SectionRules {
|
||||||
Name = "Database",
|
Name = "Database",
|
||||||
Required = true,
|
Required = true,
|
||||||
RequiredFields = new string[] {
|
RequiredFields = new[] {
|
||||||
"Server",
|
"Server",
|
||||||
"Username",
|
"Username",
|
||||||
"Password",
|
"Password",
|
||||||
|
@ -39,7 +39,7 @@ namespace SockScape {
|
||||||
Name = "Server",
|
Name = "Server",
|
||||||
AllowMultiple = true,
|
AllowMultiple = true,
|
||||||
Required = true,
|
Required = true,
|
||||||
RequiredFields = new string[] {
|
RequiredFields = new[] {
|
||||||
"Id",
|
"Id",
|
||||||
"Port"
|
"Port"
|
||||||
}
|
}
|
||||||
|
@ -52,22 +52,13 @@ namespace SockScape {
|
||||||
return Settings[section];
|
return Settings[section];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Instance General {
|
public static Instance General
|
||||||
get {
|
=> Settings["General"][0];
|
||||||
return Settings["General"][0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Instance Database {
|
public static Instance Database
|
||||||
get {
|
=> Settings["Database"][0];
|
||||||
return Settings["Database"][0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Section Servers {
|
public static Section Servers
|
||||||
get {
|
=> Settings["Server"];
|
||||||
return Settings["Server"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,11 @@ namespace SockScape.DAL {
|
||||||
public virtual User User { get; set; }
|
public virtual User User { get; set; }
|
||||||
|
|
||||||
protected string RawIp { get; set; }
|
protected string RawIp { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
public IPAddress Ip {
|
public IPAddress Ip {
|
||||||
get {
|
get => IPAddress.Parse(RawIp);
|
||||||
return IPAddress.Parse(RawIp);
|
set => RawIp = value.ToString();
|
||||||
}
|
|
||||||
set {
|
|
||||||
RawIp = value.ToString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace SockScape.DAL {
|
||||||
|
|
||||||
public ScapeDb()
|
public ScapeDb()
|
||||||
: base("server="+ Config.Database["Server"]
|
: base("server="+ Config.Database["Server"]
|
||||||
|
+";port="+ (Config.Database["Port"] ?? "3306")
|
||||||
+";user id="+ Config.Database["Username"]
|
+";user id="+ Config.Database["Username"]
|
||||||
+";password="+ Config.Database["Password"]
|
+";password="+ Config.Database["Password"]
|
||||||
+";persistsecurityinfo=True;"
|
+";persistsecurityinfo=True;"
|
||||||
|
@ -25,9 +26,8 @@ namespace SockScape.DAL {
|
||||||
public DbSet<Origin> Origins { get; set; }
|
public DbSet<Origin> Origins { get; set; }
|
||||||
public DbSet<Session> Sessions { get; set; }
|
public DbSet<Session> Sessions { get; set; }
|
||||||
|
|
||||||
|
protected override void OnModelCreating(DbModelBuilder builder) {
|
||||||
protected override void OnModelCreating(DbModelBuilder modelBuilder) {
|
base.OnModelCreating(builder);
|
||||||
base.OnModelCreating(modelBuilder);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,14 @@ namespace SockScape.DAL {
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
public virtual User User { get; set; }
|
public virtual User User { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected string RawIp { get; set; }
|
protected string RawIp { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
public IPAddress Ip {
|
public IPAddress Ip {
|
||||||
get {
|
get => IPAddress.Parse(RawIp);
|
||||||
return IPAddress.Parse(RawIp);
|
set => RawIp = value.ToString();
|
||||||
}
|
|
||||||
set {
|
|
||||||
RawIp = value.ToString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ServerId { get; set; }
|
public int ServerId { get; set; }
|
||||||
|
|
|
@ -10,9 +10,11 @@ namespace SockScape.DAL {
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[MaxLength(16)]
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
[MaxLength(256)]
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
|
|
@ -8,8 +8,8 @@ using Glove;
|
||||||
|
|
||||||
namespace SockScape.Encryption {
|
namespace SockScape.Encryption {
|
||||||
class Cipher {
|
class Cipher {
|
||||||
private byte[] Key = new byte[512 / 8];
|
private readonly byte[] Key = new byte[512 / 8];
|
||||||
private byte[] State = new byte[256];
|
private readonly byte[] State = new byte[256];
|
||||||
|
|
||||||
public Cipher(BigInteger key) {
|
public Cipher(BigInteger key) {
|
||||||
int i = 0, j = 0;
|
int i = 0, j = 0;
|
||||||
|
|
|
@ -9,13 +9,12 @@ using System.Globalization;
|
||||||
|
|
||||||
namespace SockScape.Encryption {
|
namespace SockScape.Encryption {
|
||||||
class Key {
|
class Key {
|
||||||
private readonly static BigInteger Secret = RNG.NextPrime(512 / 8);
|
private static readonly BigInteger Secret = RNG.NextPrime(512 / 8);
|
||||||
public BigInteger Generator { get; private set; } = 2;
|
public BigInteger Generator { get; } = 2;
|
||||||
public BigInteger Modulus { get; private set; }
|
public BigInteger Modulus { get; }
|
||||||
public BigInteger PrivateKey { get; private set; } = BigInteger.Zero;
|
public BigInteger PrivateKey { get; private set; } = BigInteger.Zero;
|
||||||
public bool Succeeded {
|
public bool Succeeded
|
||||||
get => !PrivateKey.IsZero;
|
=> !PrivateKey.IsZero;
|
||||||
}
|
|
||||||
|
|
||||||
public Key() {
|
public Key() {
|
||||||
Modulus = RNG.NextPrime(512 / 8);
|
Modulus = RNG.NextPrime(512 / 8);
|
||||||
|
@ -34,7 +33,7 @@ namespace SockScape.Encryption {
|
||||||
if(packet.Id != 1 || packet.RegionCount != 3)
|
if(packet.Id != 1 || packet.RegionCount != 3)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
bool check = BigInteger.TryParse(packet[0], NumberStyles.HexNumber,
|
var check = BigInteger.TryParse(packet[0], NumberStyles.HexNumber,
|
||||||
NumberFormatInfo.InvariantInfo, out BigInteger generator);
|
NumberFormatInfo.InvariantInfo, out BigInteger generator);
|
||||||
check &= BigInteger.TryParse(packet[1], NumberStyles.HexNumber,
|
check &= BigInteger.TryParse(packet[1], NumberStyles.HexNumber,
|
||||||
NumberFormatInfo.InvariantInfo, out BigInteger modulus);
|
NumberFormatInfo.InvariantInfo, out BigInteger modulus);
|
||||||
|
@ -59,7 +58,7 @@ namespace SockScape.Encryption {
|
||||||
if(!BigInteger.TryParse(packet[0], NumberStyles.HexNumber, NumberFormatInfo.InvariantInfo, out BigInteger clientKey))
|
if(!BigInteger.TryParse(packet[0], NumberStyles.HexNumber, NumberFormatInfo.InvariantInfo, out BigInteger clientKey))
|
||||||
return -1;
|
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>
|
<ProjectGuid>{054F172E-9683-40BC-8BDD-7671340EC193}</ProjectGuid>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>Square</RootNamespace>
|
<RootNamespace>Glove</RootNamespace>
|
||||||
<AssemblyName>Square</AssemblyName>
|
<AssemblyName>Glove</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
@ -7,14 +7,14 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Glove.INI {
|
namespace Glove.INI {
|
||||||
public class Instance : IEnumerable<KeyValuePair<string, Value>> {
|
public class Instance : IEnumerable<KeyValuePair<string, Value>> {
|
||||||
private Dictionary<string, Value> Data
|
private readonly Dictionary<string, Value> Data
|
||||||
= new Dictionary<string, Value>(StringComparer.OrdinalIgnoreCase);
|
= new Dictionary<string, Value>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
internal Instance() { }
|
internal Instance() { }
|
||||||
|
|
||||||
internal void Push(string line) {
|
internal void Push(string line) {
|
||||||
if(line.Contains('=')) {
|
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()));
|
Data.Add(parts[0].Trim(), new Value(parts[1].Trim()));
|
||||||
} else
|
} else
|
||||||
throw new FormatException("Line is not a key-value pair delimited by an equals sign.");
|
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 {
|
namespace Glove.INI {
|
||||||
public class Section : IEnumerable<Instance> {
|
public class Section : IEnumerable<Instance> {
|
||||||
private List<Instance> Instances = new List<Instance>();
|
private readonly List<Instance> Instances = new List<Instance>();
|
||||||
|
|
||||||
internal Section() { }
|
internal Section() { }
|
||||||
|
|
||||||
|
@ -16,23 +16,13 @@ namespace Glove.INI {
|
||||||
return Instances[Instances.Count - 1];
|
return Instances[Instances.Count - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public string this[string key] {
|
public string this[string key]
|
||||||
get {
|
=> Instances[0][key];
|
||||||
return Instances[0][key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Instance this[int i] {
|
public Instance this[int i]
|
||||||
get {
|
=> Instances[i];
|
||||||
return Instances[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Count {
|
public int Count => Instances.Count;
|
||||||
get {
|
|
||||||
return Instances.Count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() {
|
IEnumerator IEnumerable.GetEnumerator() {
|
||||||
return Instances.GetEnumerator();
|
return Instances.GetEnumerator();
|
||||||
|
|
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Glove.INI {
|
namespace Glove.INI {
|
||||||
public class SettingsFile {
|
public class SettingsFile {
|
||||||
private Dictionary<string, Section> Sections
|
private readonly Dictionary<string, Section> Sections
|
||||||
= new Dictionary<string, Section>(StringComparer.OrdinalIgnoreCase);
|
= new Dictionary<string, Section>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
public SettingsFile(string path) {
|
public SettingsFile(string path) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Glove.INI {
|
namespace Glove.INI {
|
||||||
public class Value {
|
public class Value {
|
||||||
private string Raw;
|
private readonly string Raw;
|
||||||
|
|
||||||
public Value(string raw) {
|
public Value(string raw) {
|
||||||
Raw = raw;
|
Raw = raw;
|
||||||
|
@ -17,9 +17,7 @@ namespace Glove.INI {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static implicit operator bool(Value value) {
|
public static implicit operator bool(Value value) {
|
||||||
return Boolean.TryParse(value.Raw, out bool retval)
|
return Boolean.TryParse(value.Raw, out bool retval) && retval;
|
||||||
? retval
|
|
||||||
: false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static implicit operator Int32(Value value) {
|
public static implicit operator Int32(Value value) {
|
||||||
|
|
|
@ -7,7 +7,8 @@ using System.Numerics;
|
||||||
|
|
||||||
namespace Glove {
|
namespace Glove {
|
||||||
public static class RNG {
|
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() {
|
public static int Next() {
|
||||||
lock(RandCtx) {
|
lock(RandCtx) {
|
||||||
|
|
|
@ -17,17 +17,16 @@ namespace Kneesocks {
|
||||||
get {
|
get {
|
||||||
if(_Id == null)
|
if(_Id == null)
|
||||||
throw new ArgumentNullException();
|
throw new ArgumentNullException();
|
||||||
else
|
|
||||||
return (UInt64)_Id;
|
return (UInt64)_Id;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
if(_Id == null)
|
if(_Id == null)
|
||||||
_Id = value;
|
_Id = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal bool IsIdNull {
|
internal bool IsIdNull
|
||||||
get => _Id == null;
|
=> _Id == null;
|
||||||
}
|
|
||||||
|
|
||||||
private TcpClient Socket = null;
|
private TcpClient Socket = null;
|
||||||
private NetworkStream Stream = null;
|
private NetworkStream Stream = null;
|
||||||
|
@ -43,12 +42,11 @@ namespace Kneesocks {
|
||||||
|
|
||||||
protected const int PingInterval = 30;
|
protected const int PingInterval = 30;
|
||||||
protected const int TimeoutInterval = 120;
|
protected const int TimeoutInterval = 120;
|
||||||
private byte[] PingData = Encoding.ASCII.GetBytes("woomy!");
|
private readonly byte[] PingData = Encoding.ASCII.GetBytes("woomy!");
|
||||||
private DateTime LastPing;
|
private DateTime LastPing;
|
||||||
private bool AwaitingPingResponse = false;
|
private bool AwaitingPingResponse = false;
|
||||||
private TimeSpan TimeSinceLastPing {
|
private TimeSpan TimeSinceLastPing
|
||||||
get => DateTime.UtcNow - LastPing;
|
=> DateTime.UtcNow - LastPing;
|
||||||
}
|
|
||||||
|
|
||||||
internal bool OutsidePool = false;
|
internal bool OutsidePool = false;
|
||||||
public bool Disconnected { get; private set; } = false;
|
public bool Disconnected { get; private set; } = false;
|
||||||
|
@ -57,11 +55,8 @@ namespace Kneesocks {
|
||||||
public bool Handshaked { get; private set; } = false;
|
public bool Handshaked { get; private set; } = false;
|
||||||
public Handshake ClientHandshake { get; private set; } = null;
|
public Handshake ClientHandshake { get; private set; } = null;
|
||||||
|
|
||||||
public IPAddress IP {
|
public IPAddress IP
|
||||||
get {
|
=> ((IPEndPoint)Socket.Client.RemoteEndPoint).Address;
|
||||||
return ((IPEndPoint)Socket.Client.RemoteEndPoint).Address;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Initialize(TcpClient sock) {
|
public void Initialize(TcpClient sock) {
|
||||||
if(Initialized)
|
if(Initialized)
|
||||||
|
@ -117,7 +112,7 @@ namespace Kneesocks {
|
||||||
int frameCount = singleFrame ? 0 : (message.Length / MaximumSendFrameSize);
|
int frameCount = singleFrame ? 0 : (message.Length / MaximumSendFrameSize);
|
||||||
for(var i = 0; i <= frameCount; ++i) {
|
for(var i = 0; i <= frameCount; ++i) {
|
||||||
SendFrameBuffer.Add(new Frame {
|
SendFrameBuffer.Add(new Frame {
|
||||||
IsFinal = (i == frameCount && isFinal) ? true : false,
|
IsFinal = (i == frameCount && isFinal),
|
||||||
IsMasked = false,
|
IsMasked = false,
|
||||||
Opcode = (i == 0 || (singleFrame && first)) ? Frame.kOpcode.BinaryFrame : Frame.kOpcode.Continuation,
|
Opcode = (i == 0 || (singleFrame && first)) ? Frame.kOpcode.BinaryFrame : Frame.kOpcode.Continuation,
|
||||||
Content = message.Subset(i * (MaximumSendFrameSize + 1), MaximumSendFrameSize)
|
Content = message.Subset(i * (MaximumSendFrameSize + 1), MaximumSendFrameSize)
|
||||||
|
@ -143,10 +138,9 @@ namespace Kneesocks {
|
||||||
if(stream.Position == stream.Length) {
|
if(stream.Position == stream.Length) {
|
||||||
_Send(bytesRead == MaximumSendFrameSize ? byteBuffer : byteBuffer.Take(bytesRead).ToArray(), true, true, firstRead);
|
_Send(bytesRead == MaximumSendFrameSize ? byteBuffer : byteBuffer.Take(bytesRead).ToArray(), true, true, firstRead);
|
||||||
return;
|
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;
|
firstRead = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace Kneesocks {
|
||||||
|
|
||||||
private int _BodyLength = 0;
|
private int _BodyLength = 0;
|
||||||
public int BodyLength {
|
public int BodyLength {
|
||||||
get => Content == null ? _BodyLength : Content.Length;
|
get => Content?.Length ?? _BodyLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] Content { get; set; } = null;
|
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 + ")");
|
throw new FormatException("Raw frame length ("+ (uint)raw.Length + ") is less than described size ("+ expectedFrameLength + ")");
|
||||||
|
|
||||||
returnFrame.Content = new byte[returnFrame.BodyLength];
|
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)
|
if(returnFrame.IsMasked)
|
||||||
returnFrame.Content = returnFrame.MaskedContent;
|
returnFrame.Content = returnFrame.MaskedContent;
|
||||||
|
|
||||||
|
|
|
@ -34,14 +34,14 @@ namespace Kneesocks {
|
||||||
get => Enum.GetName(typeof(kStatusCode), StatusCode).Replace('_', ' ');
|
get => Enum.GetName(typeof(kStatusCode), StatusCode).Replace('_', ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<string, string> Headers =
|
private readonly Dictionary<string, string> Headers =
|
||||||
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||||
public string Content { get; set; } = null;
|
public string Content { get; set; } = null;
|
||||||
|
|
||||||
public Handshake(string rawData) {
|
public Handshake(string rawData) {
|
||||||
IsRequest = true;
|
IsRequest = true;
|
||||||
|
|
||||||
var headerLength = rawData.IndexOf("\r\n\r\n");
|
var headerLength = rawData.IndexOf("\r\n\r\n", StringComparison.InvariantCulture);
|
||||||
if(headerLength == -1)
|
if(headerLength == -1)
|
||||||
throw new FormatException("Header delimeter not found in raw data");
|
throw new FormatException("Header delimeter not found in raw data");
|
||||||
|
|
||||||
|
@ -57,14 +57,14 @@ namespace Kneesocks {
|
||||||
if(parts.Length < 3)
|
if(parts.Length < 3)
|
||||||
throw new FormatException("Status line in header malformed");
|
throw new FormatException("Status line in header malformed");
|
||||||
} else {
|
} else {
|
||||||
parts = line.Trim().Split(new char[] {':'}, 2);
|
parts = line.Trim().Split(new[] {':'}, 2);
|
||||||
if(parts.Length == 2)
|
if(parts.Length == 2)
|
||||||
Headers.Add(parts[0].Trim(), parts[1].Trim());
|
Headers.Add(parts[0].Trim(), parts[1].Trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Headers.ContainsKey("Content-Length")) {
|
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 {
|
} else {
|
||||||
if(rawData.Length > headerLength + 4)
|
if(rawData.Length > headerLength + 4)
|
||||||
Content = rawData.Substring(headerLength + 4);
|
Content = rawData.Substring(headerLength + 4);
|
||||||
|
@ -106,7 +106,7 @@ namespace Kneesocks {
|
||||||
var raw = "HTTP/"+ HttpVersion +" "+ (int)StatusCode + " "+ StatusCodeText +"\r\n";
|
var raw = "HTTP/"+ HttpVersion +" "+ (int)StatusCode + " "+ StatusCodeText +"\r\n";
|
||||||
foreach(var header in Headers)
|
foreach(var header in Headers)
|
||||||
raw += header.Key.Trim() + ": " + header.Value.Trim() + "\r\n";
|
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);
|
public bool HasHeader(string name) => Headers.ContainsKey(name);
|
||||||
|
|
|
@ -33,11 +33,11 @@ namespace Kneesocks {
|
||||||
private int _fullThreadCount;
|
private int _fullThreadCount;
|
||||||
private volatile bool updateFullThreadCount = true;
|
private volatile bool updateFullThreadCount = true;
|
||||||
|
|
||||||
private List<ThreadContext> Threads
|
private readonly List<ThreadContext> Threads
|
||||||
= new List<ThreadContext>();
|
= new List<ThreadContext>();
|
||||||
|
|
||||||
private long InternalCounter = 0;
|
private long InternalCounter = 0;
|
||||||
private Dictionary<UInt64, T> Connections
|
private readonly Dictionary<UInt64, T> Connections
|
||||||
= new Dictionary<UInt64, T>();
|
= new Dictionary<UInt64, T>();
|
||||||
|
|
||||||
public Pool() {
|
public Pool() {
|
||||||
|
@ -47,9 +47,11 @@ namespace Kneesocks {
|
||||||
|
|
||||||
public T this[UInt64 id] {
|
public T this[UInt64 id] {
|
||||||
get {
|
get {
|
||||||
if(HasConnection(id))
|
lock (Connections) {
|
||||||
return Connections[id];
|
if (HasConnection(id))
|
||||||
else return null;
|
return Connections[id];
|
||||||
|
else return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +110,7 @@ namespace Kneesocks {
|
||||||
|
|
||||||
internal void InvalidateThread(Stack<T> stackRef) {
|
internal void InvalidateThread(Stack<T> stackRef) {
|
||||||
lock(Threads) {
|
lock(Threads) {
|
||||||
var ctx = Threads.FirstOrDefault(x => Object.ReferenceEquals(x.Stack, stackRef));
|
var ctx = Threads.FirstOrDefault(x => ReferenceEquals(x.Stack, stackRef));
|
||||||
if(ctx != null) {
|
if(ctx != null) {
|
||||||
Threads.Remove(ctx);
|
Threads.Remove(ctx);
|
||||||
updateFullThreadCount = true;
|
updateFullThreadCount = true;
|
||||||
|
@ -120,7 +122,7 @@ namespace Kneesocks {
|
||||||
var stack = new Stack<T>(this, runWithNoClients, initialConnection);
|
var stack = new Stack<T>(this, runWithNoClients, initialConnection);
|
||||||
var ctx = new ThreadContext {
|
var ctx = new ThreadContext {
|
||||||
Stack = stack,
|
Stack = stack,
|
||||||
Thread = new Thread(new ThreadStart(stack.ManageStack))
|
Thread = new Thread(stack.ManageStack)
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.Thread.Start();
|
ctx.Thread.Start();
|
||||||
|
|
|
@ -12,25 +12,24 @@ namespace Kneesocks {
|
||||||
private List<byte> Buffer;
|
private List<byte> Buffer;
|
||||||
private int ExpectedLength;
|
private int ExpectedLength;
|
||||||
private string ExpectedString;
|
private string ExpectedString;
|
||||||
private NetworkStream Source;
|
private readonly NetworkStream Source;
|
||||||
private DateTime StartTime;
|
private DateTime StartTime;
|
||||||
|
|
||||||
public bool IsReading { get; private set; } = false;
|
public bool IsReading { get; private set; }
|
||||||
|
|
||||||
public ReadBuffer(NetworkStream source) {
|
public ReadBuffer(NetworkStream source) {
|
||||||
Source = source;
|
Source = source;
|
||||||
Buffer = new List<byte>();
|
Buffer = new List<byte>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeSpan ElapsedReadTime {
|
public TimeSpan ElapsedReadTime
|
||||||
get => DateTime.UtcNow - StartTime;
|
=> DateTime.UtcNow - StartTime;
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] CheckBuffer() {
|
private byte[] CheckBuffer() {
|
||||||
byte[] returnValue = null;
|
byte[] returnValue = null;
|
||||||
|
|
||||||
if(ExpectedString != 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) {
|
if(location != -1) {
|
||||||
var fullJump = location + ExpectedString.Length;
|
var fullJump = location + ExpectedString.Length;
|
||||||
returnValue = Buffer.Take(fullJump).ToArray();
|
returnValue = Buffer.Take(fullJump).ToArray();
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace Kneesocks {
|
||||||
public Server(UInt16 port, Pool<T> pool, object config = null) {
|
public Server(UInt16 port, Pool<T> pool, object config = null) {
|
||||||
Port = port;
|
Port = port;
|
||||||
Socket = new TcpListener(IPAddress.Any, port);
|
Socket = new TcpListener(IPAddress.Any, port);
|
||||||
Listener = new Thread(new ThreadStart(ListenThread));
|
Listener = new Thread(ListenThread);
|
||||||
ConnectionPool = pool;
|
ConnectionPool = pool;
|
||||||
Configuration = config;
|
Configuration = config;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,12 @@ using System.Threading;
|
||||||
|
|
||||||
namespace Kneesocks {
|
namespace Kneesocks {
|
||||||
internal class Stack<T> where T : Connection {
|
internal class Stack<T> where T : Connection {
|
||||||
private Pool<T> PoolRef = null;
|
private readonly Pool<T> PoolRef;
|
||||||
private List<T> Clients = new List<T>();
|
private readonly List<T> Clients = new List<T>();
|
||||||
private bool RunWithNoClients = false;
|
private readonly bool RunWithNoClients;
|
||||||
private bool Running = true;
|
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) {
|
public Stack(Pool<T> poolRef, T initialConnection = null) {
|
||||||
PoolRef = poolRef;
|
PoolRef = poolRef;
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace SockScape.Migrations
|
||||||
using System.Data.Entity.Migrations;
|
using System.Data.Entity.Migrations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
internal sealed class Configuration : DbMigrationsConfiguration<SockScape.DAL.ScapeDb>
|
internal sealed class Configuration : DbMigrationsConfiguration<DAL.ScapeDb>
|
||||||
{
|
{
|
||||||
public Configuration()
|
public Configuration()
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ namespace SockScape.Migrations
|
||||||
AutomaticMigrationsEnabled = false;
|
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.
|
// 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">
|
<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>
|
<HintPath>packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Win32.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
<HintPath>packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
<Reference Include="MySql.Data, Version=8.0.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\MySql.Data.6.9.9\lib\net45\MySql.Data.dll</HintPath>
|
<HintPath>packages\MySql.Data.8.0.8-dmr\lib\net452\MySql.Data.dll</HintPath>
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="MySql.Data.Entity.EF6, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
<Reference Include="MySql.Data.Entity.EF6, Version=7.0.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\MySql.Data.Entity.6.9.9\lib\net45\MySql.Data.Entity.EF6.dll</HintPath>
|
<HintPath>packages\MySql.Data.Entity.7.0.7-m61\lib\net451\MySql.Data.Entity.EF6.dll</HintPath>
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<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.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.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.Numerics" />
|
||||||
<Reference Include="System.Runtime.Serialization" />
|
<Reference Include="System.Runtime.Serialization" />
|
||||||
<Reference Include="System.Security" />
|
<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.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Net.Http" />
|
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -10,7 +10,7 @@ using SockScape.Encryption;
|
||||||
namespace SockScape {
|
namespace SockScape {
|
||||||
class MasterConnection : Connection {
|
class MasterConnection : Connection {
|
||||||
private Key Key;
|
private Key Key;
|
||||||
public Cipher Encryptor { get; private set; } = null;
|
public Cipher Encryptor { get; private set; }
|
||||||
|
|
||||||
protected override void OnOpen() {
|
protected override void OnOpen() {
|
||||||
Key = new Key();
|
Key = new Key();
|
||||||
|
|
|
@ -10,8 +10,8 @@ using System.Threading.Tasks;
|
||||||
namespace SockScape.Socks {
|
namespace SockScape.Socks {
|
||||||
static class MasterUdpServer {
|
static class MasterUdpServer {
|
||||||
private static UdpClient Sock;
|
private static UdpClient Sock;
|
||||||
private static Thread ListeningThread = null;
|
private static Thread ListeningThread;
|
||||||
private static bool IsOpen = false;
|
private static bool IsOpen;
|
||||||
|
|
||||||
public static void Initialize() {
|
public static void Initialize() {
|
||||||
if(!IsOpen && ListeningThread == null)
|
if(!IsOpen && ListeningThread == null)
|
||||||
|
@ -21,7 +21,7 @@ namespace SockScape.Socks {
|
||||||
Sock = new UdpClient(port);
|
Sock = new UdpClient(port);
|
||||||
|
|
||||||
IsOpen = true;
|
IsOpen = true;
|
||||||
ListeningThread = new Thread(new ThreadStart(Listener));
|
ListeningThread = new Thread(Listener);
|
||||||
ListeningThread.Start();
|
ListeningThread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,11 +57,10 @@ namespace SockScape {
|
||||||
return packet;
|
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 Id { get; private set; }
|
||||||
public int RegionCount {
|
public int RegionCount
|
||||||
get => Regions.Count;
|
=> Regions.Count;
|
||||||
}
|
|
||||||
|
|
||||||
protected Packet() { }
|
protected Packet() { }
|
||||||
|
|
||||||
|
@ -72,9 +71,8 @@ namespace SockScape {
|
||||||
AddRegion(region);
|
AddRegion(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Region this[int i] {
|
public Region this[int i]
|
||||||
get => new Region(Regions[i]);
|
=> new Region(Regions[i]);
|
||||||
}
|
|
||||||
|
|
||||||
public Packet AddRegion(object region) {
|
public Packet AddRegion(object region) {
|
||||||
if(region.GetType() == typeof(byte[]))
|
if(region.GetType() == typeof(byte[]))
|
||||||
|
@ -110,16 +108,15 @@ namespace SockScape {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Region {
|
public class Region {
|
||||||
public byte[] Data { get; private set; }
|
public byte[] Data { get; }
|
||||||
|
|
||||||
public Region(byte[] data) {
|
public Region(byte[] data) {
|
||||||
Data = data;
|
Data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static implicit operator byte[] (Region region) => region.Data;
|
public static implicit operator byte[] (Region region) => region.Data;
|
||||||
public string Bytes {
|
public string Bytes
|
||||||
get => this;
|
=> this;
|
||||||
}
|
|
||||||
|
|
||||||
public static implicit operator string(Region region) {
|
public static implicit operator string(Region region) {
|
||||||
try {
|
try {
|
||||||
|
@ -128,9 +125,8 @@ namespace SockScape {
|
||||||
return Encoding.ASCII.GetString(region.Data);
|
return Encoding.ASCII.GetString(region.Data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public string Str {
|
public string Str
|
||||||
get => this;
|
=> this;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,69 @@
|
||||||
<package id="Costura.Fody" version="1.4.0" targetFramework="net46" developmentDependency="true" />
|
<package id="Costura.Fody" version="1.4.0" targetFramework="net46" developmentDependency="true" />
|
||||||
<package id="EntityFramework" version="6.1.3" targetFramework="net46" />
|
<package id="EntityFramework" version="6.1.3" targetFramework="net46" />
|
||||||
<package id="Fody" version="2.0.4" targetFramework="net46" developmentDependency="true" />
|
<package id="Fody" version="2.0.4" targetFramework="net46" developmentDependency="true" />
|
||||||
<package id="MySql.Data" version="6.9.9" targetFramework="net46" />
|
<package id="Google.Protobuf" version="3.3.0" targetFramework="net46" />
|
||||||
<package id="MySql.Data.Entity" version="6.9.9" 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>
|
</packages>
|
Loading…
Reference in a new issue