From f4e34c84bd1738c6bee98b126b26d0a397a34395 Mon Sep 17 00:00:00 2001 From: Malloc of Kuzkycyziklistan Date: Tue, 6 Jun 2017 16:13:25 -0500 Subject: [PATCH] sock refactor considerations --- ClassLibrary1/Class1.cs | 8 ++++ ClassLibrary1/ClassLibrary1.csproj | 7 ++++ server/CircleScape.csproj | 9 +++-- server/CircleScape.sln | 2 +- server/DAL/Origin.cs | 11 +++++- server/DAL/ScapeDb.cs | 1 + server/DAL/Session.cs | 11 ++++++ server/DAL/User.cs | 1 + server/Entrypoint.cs | 3 +- server/Libraries/Square/INI/Instance.cs | 13 +++++++ server/Libraries/Square/INI/Section.cs | 16 ++++++++ .../Square/INI/SectionRules.cs} | 5 +-- server/Libraries/Square/INI/SettingsFile.cs | 34 +++++++++++++++++ server/Libraries/Square/Square.csproj | 5 +++ server/Socks/ActiveConnection.cs | 19 ---------- server/Socks/MasterConnection.cs | 13 +++++++ ...ndingConnection.cs => PlayerConnection.cs} | 4 +- server/Socks/PoolManager.cs | 37 ------------------- server/What/INIFile.cs | 8 ++++ server/What/What.csproj | 7 ++++ 20 files changed, 146 insertions(+), 68 deletions(-) create mode 100644 ClassLibrary1/Class1.cs create mode 100644 ClassLibrary1/ClassLibrary1.csproj create mode 100644 server/Libraries/Square/INI/Instance.cs create mode 100644 server/Libraries/Square/INI/Section.cs rename server/{DAL/Server.cs => Libraries/Square/INI/SectionRules.cs} (60%) create mode 100644 server/Libraries/Square/INI/SettingsFile.cs delete mode 100644 server/Socks/ActiveConnection.cs create mode 100644 server/Socks/MasterConnection.cs rename server/Socks/{PendingConnection.cs => PlayerConnection.cs} (97%) delete mode 100644 server/Socks/PoolManager.cs create mode 100644 server/What/INIFile.cs create mode 100644 server/What/What.csproj diff --git a/ClassLibrary1/Class1.cs b/ClassLibrary1/Class1.cs new file mode 100644 index 0000000..174f12f --- /dev/null +++ b/ClassLibrary1/Class1.cs @@ -0,0 +1,8 @@ +using System; + +namespace ClassLibrary1 +{ + public class Class1 + { + } +} diff --git a/ClassLibrary1/ClassLibrary1.csproj b/ClassLibrary1/ClassLibrary1.csproj new file mode 100644 index 0000000..954020d --- /dev/null +++ b/ClassLibrary1/ClassLibrary1.csproj @@ -0,0 +1,7 @@ + + + + netstandard1.4 + + + \ No newline at end of file diff --git a/server/CircleScape.csproj b/server/CircleScape.csproj index 3ad683c..6176eaa 100644 --- a/server/CircleScape.csproj +++ b/server/CircleScape.csproj @@ -71,7 +71,9 @@ + + @@ -80,11 +82,10 @@ 201706040437361_Initial.cs + - - - + @@ -92,8 +93,8 @@ Designer - Designer App.config + Designer Designer diff --git a/server/CircleScape.sln b/server/CircleScape.sln index e55c872..1289dc0 100644 --- a/server/CircleScape.sln +++ b/server/CircleScape.sln @@ -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 diff --git a/server/DAL/Origin.cs b/server/DAL/Origin.cs index 31f3453..47726f7 100644 --- a/server/DAL/Origin.cs +++ b/server/DAL/Origin.cs @@ -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(); + } + } } } diff --git a/server/DAL/ScapeDb.cs b/server/DAL/ScapeDb.cs index 7433be0..1f5a0c0 100644 --- a/server/DAL/ScapeDb.cs +++ b/server/DAL/ScapeDb.cs @@ -18,6 +18,7 @@ namespace CircleScape.DAL { public DbSet Users { get; set; } public DbSet Origins { get; set; } + public DbSet Sessions { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { diff --git a/server/DAL/Session.cs b/server/DAL/Session.cs index d487e42..6e39df3 100644 --- a/server/DAL/Session.cs +++ b/server/DAL/Session.cs @@ -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; } } } diff --git a/server/DAL/User.cs b/server/DAL/User.cs index f94f5a6..6a53c3b 100644 --- a/server/DAL/User.cs +++ b/server/DAL/User.cs @@ -20,5 +20,6 @@ namespace CircleScape.DAL { public DateTime? LastLogin { get; set; } public virtual ICollection Origins { get; set; } + public virtual Session Session { get; set; } } } diff --git a/server/Entrypoint.cs b/server/Entrypoint.cs index e02d8d7..57ccdfc 100644 --- a/server/Entrypoint.cs +++ b/server/Entrypoint.cs @@ -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(6770, PoolManager.Pending); + var server = new Kneesocks.Server(6770, PoolManager.Pending); server.Start(); /*while(true) { diff --git a/server/Libraries/Square/INI/Instance.cs b/server/Libraries/Square/INI/Instance.cs new file mode 100644 index 0000000..ebe0e8b --- /dev/null +++ b/server/Libraries/Square/INI/Instance.cs @@ -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 Data { get; set; } + + + } +} diff --git a/server/Libraries/Square/INI/Section.cs b/server/Libraries/Square/INI/Section.cs new file mode 100644 index 0000000..aabdd7f --- /dev/null +++ b/server/Libraries/Square/INI/Section.cs @@ -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 Instances; + + public IEnumerator GetEnumerator() { + return Instances.GetEnumerator(); + } + } +} diff --git a/server/DAL/Server.cs b/server/Libraries/Square/INI/SectionRules.cs similarity index 60% rename from server/DAL/Server.cs rename to server/Libraries/Square/INI/SectionRules.cs index 13f7415..35ac38b 100644 --- a/server/DAL/Server.cs +++ b/server/Libraries/Square/INI/SectionRules.cs @@ -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 { } } diff --git a/server/Libraries/Square/INI/SettingsFile.cs b/server/Libraries/Square/INI/SettingsFile.cs new file mode 100644 index 0000000..62b1e54 --- /dev/null +++ b/server/Libraries/Square/INI/SettingsFile.cs @@ -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 Sections + = new Dictionary(StringComparer.OrdinalIgnoreCase); + + public SettingsFile(string path) { + var lines = File.ReadAllLines(path); + + string currentSection = null; + foreach(var line in lines) { + + } + } + + public SettingsFile(string path, List rules) { + + } + + public Section this[string section] { + get { + if(Sections.ContainsKey(section)) + return Sections[section]; + else return null; + } + } + } +} diff --git a/server/Libraries/Square/Square.csproj b/server/Libraries/Square/Square.csproj index 5a2bcd5..8c25c5a 100644 --- a/server/Libraries/Square/Square.csproj +++ b/server/Libraries/Square/Square.csproj @@ -44,11 +44,16 @@ + + + + +