sock refactor

considerations
This commit is contained in:
Malloc of Kuzkycyziklistan 2017-06-06 16:13:25 -05:00
parent 7a7da0095b
commit f4e34c84bd
20 changed files with 146 additions and 68 deletions

8
ClassLibrary1/Class1.cs Normal file
View file

@ -0,0 +1,8 @@
using System;
namespace ClassLibrary1
{
public class Class1
{
}
}

View file

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
</PropertyGroup>
</Project>

View file

@ -71,7 +71,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DAL\Origin.cs" />
<Compile Include="DAL\ScapeDb.cs" />
<Compile Include="DAL\Session.cs" />
<Compile Include="DAL\User.cs" />
<Compile Include="Encryption\KeyExchange.cs" />
<Compile Include="Encryption\Cipher.cs" />
@ -80,11 +82,10 @@
<DependentUpon>201706040437361_Initial.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Socks\MasterConnection.cs" />
<Compile Include="Socks\Packet.cs" />
<Compile Include="Socks\ActiveConnection.cs" />
<Compile Include="Entrypoint.cs" />
<Compile Include="Socks\PendingConnection.cs" />
<Compile Include="Socks\PoolManager.cs" />
<Compile Include="Socks\PlayerConnection.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
@ -92,8 +93,8 @@
<SubType>Designer</SubType>
</None>
<None Include="connectionStrings.config">
<SubType>Designer</SubType>
<DependentUpon>App.config</DependentUpon>
<SubType>Designer</SubType>
</None>
<None Include="packages.config">
<SubType>Designer</SubType>

View file

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.7
VisualStudioVersion = 15.0.26430.6
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CircleScape", "CircleScape.csproj", "{438DBAC1-BA37-40BB-9CCE-0FE1F23C6DC5}"
EndProject

View file

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
@ -13,6 +14,14 @@ namespace CircleScape.DAL {
public long UserId { get; set; }
public virtual User User { get; set; }
public string Ip { get; set; }
protected string RawIp { get; set; }
public IPAddress Ip {
get {
return IPAddress.Parse(RawIp);
}
set {
RawIp = value.ToString();
}
}
}
}

View file

@ -18,6 +18,7 @@ namespace CircleScape.DAL {
public DbSet<User> Users { get; set; }
public DbSet<Origin> Origins { get; set; }
public DbSet<Session> Sessions { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder) {

View file

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
@ -13,6 +14,16 @@ namespace CircleScape.DAL {
public int UserId { get; set; }
public virtual User User { get; set; }
protected string RawIp { get; set; }
public IPAddress Ip {
get {
return IPAddress.Parse(RawIp);
}
set {
RawIp = value.ToString();
}
}
public int ServerId { get; set; }
}
}

View file

@ -20,5 +20,6 @@ namespace CircleScape.DAL {
public DateTime? LastLogin { get; set; }
public virtual ICollection<Origin> Origins { get; set; }
public virtual Session Session { get; set; }
}
}

View file

@ -6,11 +6,12 @@ using System.Threading.Tasks;
//using CircleScape.DAL;
using System.Numerics;
using Square;
using System.Net;
namespace CircleScape {
class Entrypoint {
static void Main(string[] args) {
var server = new Kneesocks.Server<PendingConnection>(6770, PoolManager.Pending);
var server = new Kneesocks.Server<PlayerConnection>(6770, PoolManager.Pending);
server.Start();
/*while(true) {

View file

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Square.INI {
class Instance {
private Dictionary<string, string> Data { get; set; }
}
}

View file

@ -0,0 +1,16 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Square.INI {
public class Section : IEnumerable {
private List<Instance> Instances;
public IEnumerator GetEnumerator() {
return Instances.GetEnumerator();
}
}
}

View file

@ -4,9 +4,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CircleScape.DAL {
class Server {
public int Id { get; set; }
namespace Square.INI {
public class SectionRules {
}
}

View file

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Square.INI {
public class SettingsFile {
private Dictionary<string, Section> Sections
= new Dictionary<string, Section>(StringComparer.OrdinalIgnoreCase);
public SettingsFile(string path) {
var lines = File.ReadAllLines(path);
string currentSection = null;
foreach(var line in lines) {
}
}
public SettingsFile(string path, List<SectionRules> rules) {
}
public Section this[string section] {
get {
if(Sections.ContainsKey(section))
return Sections[section];
else return null;
}
}
}
}

View file

@ -44,11 +44,16 @@
<Compile Include="ArrayExtensions.cs" />
<Compile Include="CryptoExtensions.cs" />
<Compile Include="General.cs" />
<Compile Include="INI\Instance.cs" />
<Compile Include="INI\Section.cs" />
<Compile Include="INI\SectionRules.cs" />
<Compile Include="INI\SettingsFile.cs" />
<Compile Include="NumericExtensions.cs" />
<Compile Include="RandomContext.cs" />
<Compile Include="StringExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View file

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using Kneesocks;
using CircleScape.Encryption;
namespace CircleScape {
class ActiveConnection : Connection {
private Cipher Encryptor;
public void Initialize(PendingConnection conn) {
Initialize(conn, false);
Encryptor = conn.Encryptor;
}
}
}

View file

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kneesocks;
using Square;
namespace CircleScape.Socks {
class MasterConnection : Connection {
}
}

View file

@ -4,12 +4,12 @@ using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using Square;
using Kneesocks;
using Square;
using CircleScape.Encryption;
namespace CircleScape {
class PendingConnection : Connection {
class PlayerConnection : Connection {
private DateTime ConnectionOpened;
private Key Key;
public Cipher Encryptor { get; private set; } = null;

View file

@ -1,37 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kneesocks;
using System.Net.Sockets;
namespace CircleScape {
static class PoolManager {
private static Pool<PendingConnection> PendingConnectionsPool;
private static Pool<ActiveConnection> ActiveConnectionsPool;
public static Pool<PendingConnection> Pending {
get => PendingConnectionsPool;
}
public static Pool<ActiveConnection> Active {
get => ActiveConnectionsPool;
}
static PoolManager() {
PendingConnectionsPool = new Pool<PendingConnection> {
InitialCount = 1,
InitialSize = 10,
SizeGrowth = 10,
MaxSize = 50,
MaxCount = 5
};
ActiveConnectionsPool = new Pool<ActiveConnection>();
}
public static void Dispose() {
PendingConnectionsPool.Dispose();
ActiveConnectionsPool.Dispose();
}
}
}

8
server/What/INIFile.cs Normal file
View file

@ -0,0 +1,8 @@
using System;
namespace What
{
public class INIFile {
}
}

7
server/What/What.csproj Normal file
View file

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
</PropertyGroup>
</Project>