first commit
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
</assembly>
|
||||
@@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<RootNamespace>BlubbFish.IoT.Pocsag.BosServerHTTP</RootNamespace>
|
||||
<ApplicationManifest>Adminrights.manifest</ApplicationManifest>
|
||||
<Version>1.1.0</Version>
|
||||
<Description>1.1.0 Rewrite to linux
|
||||
1.0.0 Init</Description>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Utils\Bot-Utils\Bot-Utils\Bot-Utils.csproj" />
|
||||
<ProjectReference Include="..\..\Utils\ConnectorDataMqtt\ConnectorDataMqtt\ConnectorDataMqtt.csproj" />
|
||||
<ProjectReference Include="..\..\Utils\Utils-IoT\Utils-IoT\Utils-IoT.csproj" />
|
||||
<ProjectReference Include="..\..\Utils\Utils\Utils\Utils.csproj" />
|
||||
<ProjectReference Include="..\BosServerDatatypes\BosServerDatatypes.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="config-example\settings.conf">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
|
||||
using BlubbFish.IoT.Pocsag.BosServerDatatypes.Mqtt;
|
||||
using BlubbFish.Utils;
|
||||
using BlubbFish.Utils.IoT.Bots;
|
||||
using BlubbFish.Utils.IoT.Connector;
|
||||
using BlubbFish.Utils.IoT.Events;
|
||||
|
||||
namespace BlubbFish.IoT.Pocsag.BosServerHTTP {
|
||||
class Program : AWebserverDataBackend {
|
||||
private readonly Dictionary<String, String> bosconf;
|
||||
|
||||
static void Main(String[] args) => new Program(args, true, "bshttp", null, null);
|
||||
|
||||
public Program(String[] args, Boolean fileLogging, String configSearchPath, ABackend backend, Dictionary<String, String> settings) : base(args, fileLogging, configSearchPath, backend, settings) {
|
||||
this.databackend.MessageSending += this.Backend_MessageSending;
|
||||
this.bosconf = InIReader.GetInstance("settings").GetSection("bosserverhttp");
|
||||
|
||||
this.StartDataBackend();
|
||||
this.StartListen();
|
||||
|
||||
this.SendMqtt(new Message("Anwendung BosServerHTTP Version " + Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion + " gestartet."));
|
||||
this.WaitForShutdown();
|
||||
this.SendMqtt(new Message("Anwendung BosServerHTTP wurde beendet... Ob das so soll?"));
|
||||
|
||||
this.Dispose();
|
||||
}
|
||||
|
||||
protected override Boolean SendWebserverResponse(HttpListenerContext cont) {
|
||||
try {
|
||||
Console.WriteLine("<= HTTP " + cont.Request.Url.PathAndQuery);
|
||||
if(cont.Request.Url.LocalPath.ToLower() == "/telegramin/" + this.bosconf["path"] + "/input.xml") {
|
||||
Dictionary<String, String> post = cont.Request.GetPostParams();
|
||||
if(post.ContainsKey("function") && post.ContainsKey("flags") && post.ContainsKey("message") && post.ContainsKey("type") && post.ContainsKey("address")) {
|
||||
Console.WriteLine("=> HTTP 200 - Ok");
|
||||
this.SendMqtt(new PocsagHttp(post["function"], post["flags"], post["message"], post["type"], post["address"]));
|
||||
cont.Response.StatusCode = 200;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Helper.WriteError("=> HTTP SendWebserverResponse(): 500 - " + e.Message + "\n\n" + e.StackTrace);
|
||||
cont.Response.StatusCode = 500;
|
||||
return false;
|
||||
}
|
||||
Helper.WriteError("=> HTTP 404 - " + cont.Request.Url.PathAndQuery + " not found!");
|
||||
cont.Response.StatusCode = 404;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void Backend_MessageIncomming(Object sender, BackendEvent message) {
|
||||
}
|
||||
|
||||
private void Backend_MessageSending(Object sender, BackendEvent e) {
|
||||
try {
|
||||
Console.WriteLine("=> MQTT [" + e.From.ToString() + "]: " + e.Message);
|
||||
} catch(Exception ex) {
|
||||
Helper.WriteError("Backend_MessageSending(): " + ex.Message + "\n\n" + ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
private void SendMqtt(AMqttMessage msg) {
|
||||
try {
|
||||
((Utils.IoT.Connector.Data.Mqtt)this.databackend).Send(this.bosconf["topic"] + "/" + msg.Datatype, msg.ToJson());
|
||||
} catch(Exception e) {
|
||||
Helper.WriteError("SendMqtt(): " + e.Message + "\n\n" + e.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
[logging]
|
||||
path=/var/log/bshttp.log
|
||||
debug=true
|
||||
|
||||
[webserver]
|
||||
prefix=http://+:8080/
|
||||
|
||||
[backend]
|
||||
type=Mqtt
|
||||
backendtype=Data
|
||||
server=ilocalhost
|
||||
|
||||
[bosserverhttp]
|
||||
path=upload
|
||||
topic=bosmon
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
CSPROJFILE="BosServerHTTP.csproj"
|
||||
VMAJOR=$(grep -e "<Version>" ../$CSPROJFILE | cut -d'>' -f 2 | cut -d'<' -f 1 | cut -d'.' -f 1)
|
||||
VMINOR=$(grep -e "<Version>" ../$CSPROJFILE | cut -d'>' -f 2 | cut -d'<' -f 1 | cut -d'.' -f 2)
|
||||
VBUILD=$(grep -e "<Version>" ../$CSPROJFILE | cut -d'>' -f 2 | cut -d'<' -f 1 | cut -d'.' -f 3)
|
||||
|
||||
mkdir -p ../deb
|
||||
mkdir -p ../Builds
|
||||
|
||||
export NAME=bshttp
|
||||
export MAINAINER="BlubbFish <dev@blubbfish.net>"
|
||||
export VERSION="$VMAJOR.$VMINOR-$VBUILD"
|
||||
export DESCRIPTION="bshttp recieves web reqests and post them in mqtt"
|
||||
export DEPENDENCIES="dotnet-runtime-8.0 (>= 8.0.0)"
|
||||
export LOGFILE="/var/log/bshttp.log"
|
||||
|
||||
export EXEPATH=BosServerHTTP.dll
|
||||
export RUNNER=/usr/share/dotnet/dotnet
|
||||
export COPYEXEC="../bin/Release/netcoreapp3.1/*.dll ../bin/Release/netcoreapp3.1/BosServerHTTP.deps.json ../bin/Release/netcoreapp3.1/BosServerHTTP.runtimeconfig.json"
|
||||
|
||||
export COPYCONFIG="../bin/Release/netcoreapp3.1/config-example/*.conf"
|
||||
export CONFIGREPLACEASK=settings.conf
|
||||
|
||||
cd ../deb
|
||||
export PLATFORM=armhf
|
||||
curl -s https://git.blubbfish.net/vs_utils/CI-Scripts/raw/branch/master/deb/control-build.sh | bash
|
||||
curl -s https://git.blubbfish.net/vs_utils/CI-Scripts/raw/branch/master/deb/pre-post-build.sh | bash
|
||||
curl -s https://git.blubbfish.net/vs_utils/CI-Scripts/raw/branch/master/deb/service-build.sh | bash
|
||||
curl -s https://git.blubbfish.net/vs_utils/CI-Scripts/raw/branch/master/deb/logrotate-build.sh | bash
|
||||
curl -s https://git.blubbfish.net/vs_utils/CI-Scripts/raw/branch/master/deb/build-deb.sh | bash
|
||||
|
||||
export PLATFORM=amd64
|
||||
curl -s https://git.blubbfish.net/vs_utils/CI-Scripts/raw/branch/master/deb/control-build.sh | bash
|
||||
curl -s https://git.blubbfish.net/vs_utils/CI-Scripts/raw/branch/master/deb/build-deb.sh | bash
|
||||
|
||||
cd ..
|
||||
rm deb -rf
|
||||
|
||||
cp Builds/* ../../Builds/
|
||||
rm Builds -rf
|
||||
Reference in New Issue
Block a user