master
Harald Wolff 2019-05-07 10:21:50 +02:00
parent 8e31b7125f
commit d270f1835b
6 changed files with 83 additions and 20 deletions

View File

@ -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();

View File

@ -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<HotspotNetwork> hotspotNetworks { get; private set; }
Dictionary<HotspotNetwork, HotspotRuntime> runtimes = new Dictionary<HotspotNetwork, HotspotRuntime>();
public HotspotManager()
{
odb = new ODB(BasePath);
hotspotNetworks = odb.GetCollection<HotspotNetwork>();
}
class HotspotRuntime
{
public BTree<MAC, HotspotSession> currentSessions { get; } = new BTree<MAC, HotspotSession>();
}
}
}

View File

@ -10,7 +10,7 @@
using System;
using ln.types.odb.attributes;
using ln.types.net;
namespace skyspot.session
namespace skyspot.hotspot
{
public class HotspotNetwork
{

View File

@ -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
{

View File

@ -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)
{
}
}
}

View File

@ -37,13 +37,16 @@
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="session\HotspotSession.cs" />
<Compile Include="users\HotspotUser.cs" />
<Compile Include="users\RegistrationType.cs" />
<Compile Include="users\TrafficProfile.cs" />
<Compile Include="session\HotspotVolume.cs" />
<Compile Include="http\DHCP.cs" />
<Compile Include="http\SkySpotApplication.cs" />
<Compile Include="session\SessionManager.cs" />
<Compile Include="hotspot\HotspotNetwork.cs" />
<Compile Include="hotspot\HotspotSession.cs" />
<Compile Include="hotspot\HotspotManager.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ln.http\ln.http.csproj">
@ -81,6 +84,7 @@
<Folder Include="www\dist\" />
<Folder Include="www\system\" />
<Folder Include="www\js\" />
<Folder Include="hotspot\" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />