Initial Commit

master
Harald Wolff 2019-09-02 07:22:55 +02:00
commit 53a9f198b5
10 changed files with 1188 additions and 0 deletions

405
.gitignore vendored 100644
View File

@ -0,0 +1,405 @@
# globs
Makefile.in
*.userprefs
*.usertasks
config.make
config.status
aclocal.m4
install-sh
autom4te.cache/
*.tar.gz
tarballs/
test-results/
# Mac bundle stuff
*.dmg
*.app
# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# content below from: https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/

6
.gitmodules vendored 100644
View File

@ -0,0 +1,6 @@
[submodule "ln.types"]
path = ln.types
url = https://schwann.lnvpn.de/LupusNobilis/ln.types.git
[submodule "ln.logging"]
path = ln.logging
url = https://schwann.lnvpn.de/LupusNobilis/ln.logging.git

17
Program.cs 100644
View File

@ -0,0 +1,17 @@
using System;
using ln.types.odb.ng;
using ln.provider.data.phone;
using ln.provider.data;
using ln.logging;
namespace ln.provider
{
class MainClass
{
public static void Main(string[] args)
{
ProviderApplication providerApplication = new ProviderApplication();
providerApplication.Start(args);
}
}
}

View File

@ -0,0 +1,26 @@
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("ln.provider")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("${AuthorCopyright}")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

View File

@ -0,0 +1,178 @@
using System;
using ln.application;
using ln.application.service;
using System.Threading;
using ln.http.resources;
using System.IO;
using ln.types.rpc;
using ln.types.odb.ng;
using ln.types.odb.ng.storage;
using System.Security.Cryptography;
using System.Linq;
using ln.types;
namespace ln.provider
{
public class ProviderApplication : Application
{
public String ServerString { get; private set; }
public String WWWPath { get; private set; } = "www";
public ResourceApplication WWWApplication { get; private set; }
public RPCContainer RPCContainer { get; private set; }
public ProviderApplication()
{
ServerString = "ln.provider(0.1)";
RPCContainer = new RPCContainer();
if (Directory.Exists("../../www"))
WWWPath = "../../www";
ServiceDefinition coreRPCService = new ServiceDefinition("ln.provider.CoreService");
coreRPCService.AutoStart = true;
ServiceContainer.Add(
coreRPCService
);
}
public override void PrepareStart()
{
DirectoryResource www = new DirectoryResource(new string[] { "../../www", "www" });
www.DefaultResource = www.GetResource("index.html");
ApplicationWebSocket applicationWebSocket = new ApplicationWebSocket(null, "socket", RPCContainer);
www.InjectResource(applicationWebSocket);
WWWApplication = new ResourceApplication();
WWWApplication.RootResource = www;
}
public override AuthenticatedUser AuthenticateUser(string username, object prove)
{
CoreService coreService = ServiceContainer[typeof(CoreService)].ServiceBase as CoreService;
String[] tokens = prove.ToString().Split(':');
int token = int.Parse(tokens[0]);
AuthenticatedUser authenticatedUser = coreService.Authenticate(username, token, tokens[1]);
return authenticatedUser;
}
}
public class CoreService : ApplicationServiceBase
{
public ProviderApplication Application => (ProviderApplication)base.CurrentApplicationInterface;
public IStorageContainer CoreStorageContainer { get; private set; }
public Session CoreStorageSession { get; private set; }
public Mapper CoreStorageMapper { get; private set; }
public CoreService()
:base(nameof(CoreService))
{
}
public override void ServiceMain(IApplicationInterface applicationInterface)
{
CoreStorageContainer = new FSStorageContainer("/var/cache/ln.provider");
CoreStorageContainer.Open();
CoreStorageSession = new Session(CoreStorageContainer);
CoreStorageMapper = new Mapper(CoreStorageSession);
CoreStorageMapper.EnsureIndex<AuthenticatedUser>("ID");
CoreStorageMapper.EnsureIndex<AuthenticatedUser>("Name");
Application.HttpServer.DefaultApplication = Application.WWWApplication;
Application.RPCContainer.Add("core",new RPC(Application));
while (!StopRequested)
{
lock (this)
{
Monitor.Wait(this);
}
}
CoreStorageMapper = null;
CoreStorageSession.Dispose();
CoreStorageSession = null;
CoreStorageContainer.Dispose();
CoreStorageContainer = null;
}
public AuthenticatedUser Authenticate(string username,int token,string secretHash)
{
AuthenticatedUser authenticatedUser = CoreStorageMapper.Load<AuthenticatedUser>(Query.Equals<AuthenticatedUser>("Name", username)).FirstOrDefault();
if (authenticatedUser != null)
{
if (token <= authenticatedUser.Token)
return null;
authenticatedUser.Token = token;
CoreStorageMapper.Save<AuthenticatedUser>(authenticatedUser);
byte[] secretHashBytes = Extensions.BytesFromHexString(secretHash);
SHA256 sha256 = SHA256.Create();
sha256.TransformBlock(token.GetBytes(), 0, 4, null, 0);
sha256.TransformFinalBlock(authenticatedUser.SecretHash, 0, authenticatedUser.SecretHash.Length);
if (sha256.Hash.AreEqual(secretHashBytes))
return authenticatedUser;
return null;
}
return null;
}
class RPC
{
ProviderApplication providerApplication;
public RPC(ProviderApplication providerApplication)
{
this.providerApplication = providerApplication;
}
public String GetServerString()
{
return providerApplication.ServerString;
}
public void Shutdown()
{
ThreadPool.QueueUserWorkItem((state) => providerApplication.Stop());
}
public bool Authenticate(string username,string secretHash)
{
return false;
}
public Guid GetApplicationContext(string contextID)
{
Guid id;
if (string.Empty.Equals(contextID))
id = Guid.Empty;
else
id = Guid.Parse(contextID);
ApplicationContext applicationContext = providerApplication.GetApplicationContext(id);
ApplicationContext.SetCurrentContext(applicationContext);
return applicationContext.ContextID;
}
}
}
}

83
ln.provider.csproj 100644
View File

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{356E62A1-5F8C-495A-B125-4E6C6F0BBB46}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ln.provider</RootNamespace>
<AssemblyName>ln.provider</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ExternalConsole>true</ExternalConsole>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ExternalConsole>true</ExternalConsole>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ProviderApplication.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ln.types\ln.types.csproj">
<Project>{8D9AB9A5-E513-4BA7-A450-534F6456BF28}</Project>
<Name>ln.types</Name>
</ProjectReference>
<ProjectReference Include="..\ln.provider.data.phone\ln.provider.data.phone.csproj">
<Project>{99A2827F-B0B6-4AB0-A988-E3EE4605EB43}</Project>
<Name>ln.provider.data.phone</Name>
</ProjectReference>
<ProjectReference Include="..\ln.logging\ln.logging.csproj">
<Project>{D471A566-9FB6-41B2-A777-3C32874ECD0E}</Project>
<Name>ln.logging</Name>
</ProjectReference>
<ProjectReference Include="..\ln.provider.data\ln.provider.data.csproj">
<Project>{13E13CA1-AFC2-4AAB-A378-2349C10F9F45}</Project>
<Name>ln.provider.data</Name>
</ProjectReference>
<ProjectReference Include="..\ln.http.resources\ln.http.resources.csproj">
<Project>{F9086FE4-8925-42FF-A59C-607341604293}</Project>
<Name>ln.http.resources</Name>
</ProjectReference>
<ProjectReference Include="..\ln.http\ln.http.csproj">
<Project>{CEEEEB41-3059-46A2-A871-2ADE22C013D9}</Project>
<Name>ln.http</Name>
</ProjectReference>
<ProjectReference Include="..\ln.application\ln.application.csproj">
<Project>{44AA3A50-7214-47F2-9D60-6FF34C0FE6D3}</Project>
<Name>ln.application</Name>
</ProjectReference>
<ProjectReference Include="..\ln.json\ln.json.csproj">
<Project>{D9342117-3249-4D8B-87C9-51A50676B158}</Project>
<Name>ln.json</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="www\" />
</ItemGroup>
<ItemGroup>
<None Include="www\index.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="www\style.css" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

71
ln.provider.sln 100644
View File

@ -0,0 +1,71 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.provider", "ln.provider.csproj", "{356E62A1-5F8C-495A-B125-4E6C6F0BBB46}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.provider.data.phone", "..\ln.provider.data.phone\ln.provider.data.phone.csproj", "{99A2827F-B0B6-4AB0-A988-E3EE4605EB43}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.types", "..\ln.types\ln.types.csproj", "{8D9AB9A5-E513-4BA7-A450-534F6456BF28}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.logging", "..\ln.logging\ln.logging.csproj", "{D471A566-9FB6-41B2-A777-3C32874ECD0E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.provider.data", "..\ln.provider.data\ln.provider.data.csproj", "{13E13CA1-AFC2-4AAB-A378-2349C10F9F45}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.json", "..\ln.json\ln.json.csproj", "{D9342117-3249-4D8B-87C9-51A50676B158}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.http", "..\ln.http\ln.http.csproj", "{CEEEEB41-3059-46A2-A871-2ADE22C013D9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.http.resources", "..\ln.http.resources\ln.http.resources.csproj", "{F9086FE4-8925-42FF-A59C-607341604293}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.application", "..\ln.application\ln.application.csproj", "{44AA3A50-7214-47F2-9D60-6FF34C0FE6D3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.templates", "..\ln.templates\ln.templates.csproj", "{AD0267BB-F08C-4BE1-A88D-010D49041761}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{356E62A1-5F8C-495A-B125-4E6C6F0BBB46}.Debug|x86.ActiveCfg = Debug|x86
{356E62A1-5F8C-495A-B125-4E6C6F0BBB46}.Debug|x86.Build.0 = Debug|x86
{356E62A1-5F8C-495A-B125-4E6C6F0BBB46}.Release|x86.ActiveCfg = Release|x86
{356E62A1-5F8C-495A-B125-4E6C6F0BBB46}.Release|x86.Build.0 = Release|x86
{99A2827F-B0B6-4AB0-A988-E3EE4605EB43}.Debug|x86.ActiveCfg = Debug|Any CPU
{99A2827F-B0B6-4AB0-A988-E3EE4605EB43}.Debug|x86.Build.0 = Debug|Any CPU
{99A2827F-B0B6-4AB0-A988-E3EE4605EB43}.Release|x86.ActiveCfg = Release|Any CPU
{99A2827F-B0B6-4AB0-A988-E3EE4605EB43}.Release|x86.Build.0 = Release|Any CPU
{8D9AB9A5-E513-4BA7-A450-534F6456BF28}.Debug|x86.ActiveCfg = Debug|Any CPU
{8D9AB9A5-E513-4BA7-A450-534F6456BF28}.Debug|x86.Build.0 = Debug|Any CPU
{8D9AB9A5-E513-4BA7-A450-534F6456BF28}.Release|x86.ActiveCfg = Release|Any CPU
{8D9AB9A5-E513-4BA7-A450-534F6456BF28}.Release|x86.Build.0 = Release|Any CPU
{D471A566-9FB6-41B2-A777-3C32874ECD0E}.Debug|x86.ActiveCfg = Debug|Any CPU
{D471A566-9FB6-41B2-A777-3C32874ECD0E}.Debug|x86.Build.0 = Debug|Any CPU
{D471A566-9FB6-41B2-A777-3C32874ECD0E}.Release|x86.ActiveCfg = Release|Any CPU
{D471A566-9FB6-41B2-A777-3C32874ECD0E}.Release|x86.Build.0 = Release|Any CPU
{13E13CA1-AFC2-4AAB-A378-2349C10F9F45}.Debug|x86.ActiveCfg = Debug|Any CPU
{13E13CA1-AFC2-4AAB-A378-2349C10F9F45}.Debug|x86.Build.0 = Debug|Any CPU
{13E13CA1-AFC2-4AAB-A378-2349C10F9F45}.Release|x86.ActiveCfg = Release|Any CPU
{13E13CA1-AFC2-4AAB-A378-2349C10F9F45}.Release|x86.Build.0 = Release|Any CPU
{D9342117-3249-4D8B-87C9-51A50676B158}.Debug|x86.ActiveCfg = Debug|Any CPU
{D9342117-3249-4D8B-87C9-51A50676B158}.Debug|x86.Build.0 = Debug|Any CPU
{D9342117-3249-4D8B-87C9-51A50676B158}.Release|x86.ActiveCfg = Release|Any CPU
{D9342117-3249-4D8B-87C9-51A50676B158}.Release|x86.Build.0 = Release|Any CPU
{CEEEEB41-3059-46A2-A871-2ADE22C013D9}.Debug|x86.ActiveCfg = Debug|Any CPU
{CEEEEB41-3059-46A2-A871-2ADE22C013D9}.Debug|x86.Build.0 = Debug|Any CPU
{CEEEEB41-3059-46A2-A871-2ADE22C013D9}.Release|x86.ActiveCfg = Release|Any CPU
{CEEEEB41-3059-46A2-A871-2ADE22C013D9}.Release|x86.Build.0 = Release|Any CPU
{F9086FE4-8925-42FF-A59C-607341604293}.Debug|x86.ActiveCfg = Debug|Any CPU
{F9086FE4-8925-42FF-A59C-607341604293}.Debug|x86.Build.0 = Debug|Any CPU
{F9086FE4-8925-42FF-A59C-607341604293}.Release|x86.ActiveCfg = Release|Any CPU
{F9086FE4-8925-42FF-A59C-607341604293}.Release|x86.Build.0 = Release|Any CPU
{44AA3A50-7214-47F2-9D60-6FF34C0FE6D3}.Debug|x86.ActiveCfg = Debug|Any CPU
{44AA3A50-7214-47F2-9D60-6FF34C0FE6D3}.Debug|x86.Build.0 = Debug|Any CPU
{44AA3A50-7214-47F2-9D60-6FF34C0FE6D3}.Release|x86.ActiveCfg = Release|Any CPU
{44AA3A50-7214-47F2-9D60-6FF34C0FE6D3}.Release|x86.Build.0 = Release|Any CPU
{AD0267BB-F08C-4BE1-A88D-010D49041761}.Debug|x86.ActiveCfg = Debug|Any CPU
{AD0267BB-F08C-4BE1-A88D-010D49041761}.Debug|x86.Build.0 = Debug|Any CPU
{AD0267BB-F08C-4BE1-A88D-010D49041761}.Release|x86.ActiveCfg = Release|Any CPU
{AD0267BB-F08C-4BE1-A88D-010D49041761}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

39
www/index.html 100644
View File

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>ln.provider</title>
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="vue.js"></script>
<script type="text/javascript" src="ln.application.js"></script>
</head>
<body>
<script type="text/javascript">
LN();
</script>
<div id="app">
<h1>{{ serverString }}</h1>
</div>
<script type="text/javascript">
var providerCore = {
serverString: "",
}
LN().rpc("core","GetServerString",[],function(result,error){
document.title = result;
providerCore.serverString = result;
});
var app = new Vue({
el: "#app",
data: providerCore,
});
</script>
</body>
</html>

View File

@ -0,0 +1,336 @@
var LN = (function(){
var appInterface;
var defaultOptions = {
url: null,
};
class LNInterface {
constructor(opt){
var self = this;
this.options = {}
Object.assign(this.options,opt);
if (this.options.url == null)
this.options.url = this.constructURL();
this.rpcCallbacks = [];
this.rpcNextID = 1;
this.websocket = new WebSocket(this.options.url);
this.websocket.onerror = function(e){
alert("WebSocket caught error: " + e.date);
}
this.websocket.onmessage = function(e){
var j = JSON.parse(e.data);
if (j.state){
updateState(j.state);
} else if (j.id)
{
for (var n=0;n<self.rpcCallbacks.length;n++)
{
if (self.rpcCallbacks[n].id == j.id)
{
if (j.error)
{
console.log("RPCResult with error received: " + JSON.stringify(j.error));
}
self.rpcCallbacks[n].cbfn(j.result,j.error);
self.rpcCallbacks.splice(n,1);
return;
}
}
}
}
}
rpc(module,method,parameters,cbfn){
var rpcCall = {
module: module,
method: method,
parameters: parameters,
id: this.rpcNextID++,
};
if (this.websocket.readyState != 1)
{
setTimeout(function(){
LN().rpc(module,method,parameters,cbfn);
},250);
} else {
this.rpcCallbacks.push( { id: rpcCall.id, cbfn: cbfn } );
this.websocket.send(
JSON.stringify(rpcCall)
);
}
}
constructURL(){
var pageURI = window.location;
var scheme = pageURI.scheme == "https" ? "wss:" : "ws:";
var host = pageURI.host;
return scheme + "//" + host + "/socket";
}
}
return function(options){
if (!appInterface)
appInterface = new LNInterface(options);
return appInterface;
};
})();
/*
Object.values = function(o) {
var values = [];
for(var property in o) {
values.push(o[property]);
}
return values;
}
function encodeID( t )
{
return ("" + t).replace( /[\.\/]/g, "_");
}
var lagDetector = null;
function updateState(state)
{
try
{
if (lagDetector)
clearTimeout(lagDetector);
$("#ServerTime").text("ServerTime: " + moment(state.currentTime).format());
lagDetector = setTimeout(function(){
$("#ServerTime").text("Server lag detected");
}, 2000);
} catch (e)
{
$("#ServerTime").text("Server state unexpected!");
}
}
function SKYAPI(baseurl){
this.baseurl = baseurl;
this.refresh = []
this.websocket = new WebSocket("ws://localhost:8080/socket");
this.websocket.onerror = function(e){
alert("WebSocket Error: " + e);
}
this.websocket.onmessage = function(e){
var j = JSON.parse(e.data);
if (j.state){
updateState(j.state);
}
}
this.setBaseURL = function(url){ this.baseurl = url; }
this.addRefresh = function( rh, seconds = null ){ this.refresh.push( { interval: seconds ? seconds : 5, refresh: rh } ); }
this.get = function(page, json, handler = null){ return this.__request("GET", page, json, handler); }
this.post = function(page, json, handler = null){ return this.__request("POST", page, json, handler); }
this.put = function(page, json, handler = null){ return this.__request("PUT", page, json, handler); }
this.__request = function(method, page, json, handler = null){
if (page[0] == '/')
page = page.substr(1);
var x = new XMLHttpRequest();
if (handler != null)
{
x.onload = function(){
var responseText = x.responseText;
if (json && !content)
handler( JSON.parse( responseText ) );
else
handler( responseText );
}
}
x.open(method, this.baseurl + page);
if (json)
x.send(JSON.stringify(json));
else
x.send();
}
this.getJson = function(page, handler){
var j = function(t){
handler(JSON.parse(t));
};
return this.get( page, null, j );
}
this.call = function(endpoint,method,parameters = [], receiver = null){
var x = new XMLHttpRequest();
x.open("POST", this.baseurl + endpoint, (receiver != null));
x.setRequestHeader("content-type","application/json");
if (receiver)
{
x.onload = function(){ var r = JSON.parse(this.responseText).Result; receiver(r); }
x.onerror = function(){ receiver(false); }
}
var methodCall = {
"MethodName": method,
"Parameters": parameters
}
x.send(JSON.stringify(methodCall));
if (!receiver)
{
var result = JSON.parse(x.responseText);
if (result.Exception != null)
throw result.Exception;
return result.Result;
}
return x;
}
this.loadPage = function (page) {
if (page[0] == '/')
page = page.substr(1);
var x = new XMLHttpRequest();
x.open("GET", this.baseurl + page);
x.setRequestHeader("x-template-unframed","unframed");
x.onload = function()
{
$("#content").empty();
$("#content").append(this.responseText);
history.pushState(null, page, skyapi().baseurl + page);
}
this.refresh = []
x.send();
return false;
}
this.fireOnLoad = function(element){
if (element.onload != null)
{
element.onload();
}
for (var n=0;n<element.children.length;n++)
this.fireOnLoad(element.children[n]);
}
this.__refresh_index = 0;
this.UIRefresh = function(){
this.__refresh_index++;
for (var n=0;n<this.refresh.length;n++)
{
var r = this.refresh[n];
if ((this.__refresh_index % r.interval)==0)
r.refresh();
}
}
setInterval( function(){ skyapi().UIRefresh(); }, 1000 );
}
function showStatistics(stats)
{
try
{
$("#ServerTime").text("ServerTime: " + stats.ServerTime);
$("#indHttpServer").attr("state",stats.States.HttpServer);
$("#indManager").attr("state",stats.States.Manager);
$("#indCrawler").attr("state",stats.States.Crawler);
$("#indChecks").attr("state",stats.States.Checks);
$("#indDispatcher").attr("state",stats.States.Dispatcher);
$("#indHttpServer").attr("title",stats.States.HttpServer);
$("#indManager").attr("title",stats.States.Manager);
$("#indCrawler").attr("title",stats.States.Crawler);
$("#indChecks").attr("title",stats.States.Checks);
$("#indDispatcher").attr("title",stats.States.Dispatcher);
} catch (e)
{
$("#ServerTime").text("Server unreachable");
$("#indHttpServer").attr("state",3);
$("#indManager").attr("state",0);
$("#indCrawler").attr("state",0);
$("#indChecks").attr("state",0);
$("#indDispatcher").attr("state",0);
$("#indHttpServer").attr("title","UNKNOWN");
$("#indManager").attr("title","UNKNOWN");
$("#indCrawler").attr("title","UNKNOWN");
$("#indChecks").attr("title","UNKNOWN");
$("#indDispatcher").attr("title","UNKNOWN");
}
}
function updateStatistics()
{
try
{
var request = skyapi().call("api/management","GetStatistics",[],showStatistics);
} catch (e)
{
showStatistics(false);
}
}
var __skyapi = new SKYAPI("/");
function skyapi()
{
return __skyapi;
}
function ScaleSI(value)
{
if (value > 1000000000)
return ((value / 1000000000) | 0) + "G";
if (value > 1000000)
return ((value / 1000000) | 0) + "M";
if (value > 1000)
return ((value / 1000) | 0) + "k";
return value;
}
*/

27
www/style.css 100644
View File

@ -0,0 +1,27 @@
body, html {
position: absolute;
width: 100%;
height: 100%;
padding: 0px;
margin: 0px;
overflow: hidden;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
}
h1 {
font-size: 125%;
}
div.app {
position: absolute;
padding: 0px;
margin: 0px;
}