From d270f1835bec9516f29a64d9540b2c6c9f02df4a Mon Sep 17 00:00:00 2001 From: Harald Wolff Date: Tue, 7 May 2019 10:21:50 +0200 Subject: [PATCH] WIP --- Program.cs | 22 +++++-------------- hotspot/HotspotManager.cs | 25 +++++++++++++++++++++ hotspot/HotspotNetwork.cs | 2 +- hotspot/HotspotSession.cs | 2 +- session/SessionManager.cs | 46 +++++++++++++++++++++++++++++++++++++++ skyspot.csproj | 6 ++++- 6 files changed, 83 insertions(+), 20 deletions(-) diff --git a/Program.cs b/Program.cs index 865968c..053a1ce 100644 --- a/Program.cs +++ b/Program.cs @@ -19,6 +19,7 @@ using ln.types.net; using ln.http; using ln.http.resources; using skyspot.http; +using skyspot.session; namespace skyspot { @@ -26,29 +27,16 @@ namespace skyspot { public static void Main(string[] args) { - DHCPServer dhcpServer = new DHCPServer(); - //dhcpServer.EnsureInterface(IPv4.Parse("10.118.200.2")); - //dhcpServer.EnsurePool("default", IPv4.Parse("10.118.200.50"), IPv4.Parse("10.118.200.99")); - - //foreach (DHCPServerInterface serverInterface in dhcpServer.Interfaces) - //{ - // if (serverInterface.Pool == null) - // { - // serverInterface.Pool = dhcpServer.IPPools[0]; - // dhcpServer.Commit(serverInterface); - // } - //} - - dhcpServer.Start(); - HTTPServer httpServer = new HTTPServer(); httpServer.AddEndpoint(new IPEndPoint(IPAddress.Any, 80)); ResourceApplication app = new SkySpotApplication(); httpServer.DefaultApplication = app; - DHCP httpDHCP = new DHCP(null,dhcpServer); - (app.RootResource as DirectoryResource).InjectResource(httpDHCP); + //DHCP httpDHCP = new DHCP(null,dhcpServer); + //(app.RootResource as DirectoryResource).InjectResource(httpDHCP); + + SessionManager sessionManager = new SessionManager(); httpServer.Start(); diff --git a/hotspot/HotspotManager.cs b/hotspot/HotspotManager.cs index 57b5938..2d04537 100644 --- a/hotspot/HotspotManager.cs +++ b/hotspot/HotspotManager.cs @@ -8,12 +8,37 @@ // * // **/ using System; +using ln.types.odb; +using ln.types.odb.mapped; +using ln.types.btree; +using ln.types.net; +using System.Collections.Generic; +using System.IO; namespace skyspot.hotspot { public class HotspotManager { + public string BasePath { get; private set; } = "/var/cache/ln.skyspot"; + + ODB odb; + public ODBCollection hotspotNetworks { get; private set; } + + + Dictionary runtimes = new Dictionary(); + public HotspotManager() { + odb = new ODB(BasePath); + hotspotNetworks = odb.GetCollection(); + } + + + class HotspotRuntime + { + public BTree currentSessions { get; } = new BTree(); + + } + } } diff --git a/hotspot/HotspotNetwork.cs b/hotspot/HotspotNetwork.cs index 95efaf2..dfbda13 100644 --- a/hotspot/HotspotNetwork.cs +++ b/hotspot/HotspotNetwork.cs @@ -10,7 +10,7 @@ using System; using ln.types.odb.attributes; using ln.types.net; -namespace skyspot.session +namespace skyspot.hotspot { public class HotspotNetwork { diff --git a/hotspot/HotspotSession.cs b/hotspot/HotspotSession.cs index 3afe493..358585c 100644 --- a/hotspot/HotspotSession.cs +++ b/hotspot/HotspotSession.cs @@ -2,7 +2,7 @@ using ln.types.net; using skyspot.users; using ln.types.odb.attributes; -namespace skyspot.session +namespace skyspot.hotspot { public class HotspotSession { diff --git a/session/SessionManager.cs b/session/SessionManager.cs index 32b17f2..9df40b4 100644 --- a/session/SessionManager.cs +++ b/session/SessionManager.cs @@ -8,12 +8,58 @@ // * // **/ using System; +using System.Collections.Generic; +using ln.types.net; +using ln.types.btree; +using ln.radius; +using System.Net; +using ln.logging; +using ln.types.odb; +using ln.types.odb.mapped; namespace skyspot.session { public class SessionManager { + byte[] defaultSecret = new byte[] { 0x41, 0x42, 0x43 }; + RadiusServer radiusServer; + public SessionManager() { + InitializeRadius(); } + + public void Start() + { + } + + + private void InitializeRadius() + { + radiusServer = new RadiusServer(new IPEndPoint(IPAddress.Any,1812)); + radiusServer.LookupSecret = LookupRadiusSecret; + radiusServer.MessageReceived = RadiusMessageReceived; + } + + byte[] LookupRadiusSecret(IPEndPoint remoteEndpoint) + { + return defaultSecret; + } + void RadiusMessageReceived(RadiusServer radiusServer, RadiusMessage radiusMessage) + { + Logging.Log(LogLevel.INFO, "Radius Message received: {0}", radiusMessage); + switch ( radiusMessage.Code) + { + case RadiusCode.AccessRequest: + AccessRequest(radiusServer, radiusMessage); + break; + } + } + + void AccessRequest(RadiusServer radiusServer, RadiusMessage radiusMessage) + { + + } + + } } diff --git a/skyspot.csproj b/skyspot.csproj index 064be72..9efc709 100644 --- a/skyspot.csproj +++ b/skyspot.csproj @@ -37,13 +37,16 @@ - + + + + @@ -81,6 +84,7 @@ +