Skip to content

Commit

Permalink
Add live control gateway service
Browse files Browse the repository at this point in the history
  • Loading branch information
LucHeart committed Sep 27, 2023
1 parent 8bcf696 commit f8b1ef0
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 1 deletion.
2 changes: 1 addition & 1 deletion API/APIGlobals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public static class APIGlobals
"103.21.244.0/22", "103.22.200.0/22", "103.31.4.0/22", "104.16.0.0/13", "104.24.0.0/14", "108.162.192.0/18",
"131.0.72.0/22", "141.101.64.0/18", "162.158.0.0/15", "172.64.0.0/13", "173.245.48.0/20", "188.114.96.0/20",
"190.93.240.0/20", "197.234.240.0/22", "198.41.128.0/17", "2400:cb00::/32", "2606:4700::/32", "2803:f800::/32",
"2405:b500::/32", "2405:8100::/32", "2c0f:f248::/32", "2a06:98c0::/29"
"2405:b500::/32", "2405:8100::/32", "2c0f:f248::/32", "2a06:98c0::/29", "172.18.0.0/16"
};
}
4 changes: 4 additions & 0 deletions LiveControlGateway.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:7.0-alpine
WORKDIR /app
COPY publish .
ENTRYPOINT ["dotnet", "ShockLink.LiveControlGateway.dll"]
26 changes: 26 additions & 0 deletions LiveControlGateway/LiveControlGateway.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>ShockLink.LiveControlGateway</AssemblyName>
<RootNamespace>ShockLink.LiveControlGateway</RootNamespace>
<Company>OpenShock</Company>
<AssemblyVersion>1.5.0</AssemblyVersion>
<FileVersion>1.5.0</FileVersion>
</PropertyGroup>

<ItemGroup>
<Protobuf Include="Protos\greet.proto" GrpcServices="Server"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.49.0"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj" />
</ItemGroup>

</Project>
19 changes: 19 additions & 0 deletions LiveControlGateway/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using LiveControlGateway.Services;

var builder = WebApplication.CreateBuilder(args);

// Additional configuration is required to successfully run gRPC on macOS.
// For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682

// Add services to the container.
builder.Services.AddGrpc();

var app = builder.Build();

// Configure the HTTP request pipeline.
app.MapGrpcService<GreeterService>();
app.MapGet("/",
() =>
"Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");

app.Run();
14 changes: 14 additions & 0 deletions LiveControlGateway/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"profiles": {
"OpenShock": {
"commandName": "Project",
"dotnetRunMessages": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production",
"SHOCKLINK__DB": "Host=docker-node;Port=1337;Database=root;Username=root;Password=root;Search Path=shocklink",
"SHOCKLINK__REDIS__HOST":"docker-node",
"SHOCKLINK__REDIS__PASSWORD": ""
}
}
}
}
21 changes: 21 additions & 0 deletions LiveControlGateway/Protos/greet.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
syntax = "proto3";

option csharp_namespace = "LiveControlGateway";

package greet;

// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply);
}

// The request message containing the user's name.
message HelloRequest {
string name = 1;
}

// The response message containing the greetings.
message HelloReply {
string message = 1;
}
22 changes: 22 additions & 0 deletions LiveControlGateway/Services/GreeterService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Grpc.Core;
using LiveControlGateway;

namespace LiveControlGateway.Services;

public class GreeterService : Greeter.GreeterBase
{
private readonly ILogger<GreeterService> _logger;

public GreeterService(ILogger<GreeterService> logger)
{
_logger = logger;
}

public override Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context)
{
return Task.FromResult(new HelloReply
{
Message = "Hello " + request.Name
});
}
}
8 changes: 8 additions & 0 deletions LiveControlGateway/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
14 changes: 14 additions & 0 deletions LiveControlGateway/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"Kestrel": {
"EndpointDefaults": {
"Protocols": "Http2"
}
}
}
6 changes: 6 additions & 0 deletions ShockLink.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API", "API\API.csproj", "{1
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{61A32805-02D5-44BA-A0E5-0B46C99896DD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveControlGateway", "LiveControlGateway\LiveControlGateway.csproj", "{83BB2593-B344-42DB-8C61-D1A331054279}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -18,5 +20,9 @@ Global
{61A32805-02D5-44BA-A0E5-0B46C99896DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61A32805-02D5-44BA-A0E5-0B46C99896DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{61A32805-02D5-44BA-A0E5-0B46C99896DD}.Release|Any CPU.Build.0 = Release|Any CPU
{83BB2593-B344-42DB-8C61-D1A331054279}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{83BB2593-B344-42DB-8C61-D1A331054279}.Debug|Any CPU.Build.0 = Debug|Any CPU
{83BB2593-B344-42DB-8C61-D1A331054279}.Release|Any CPU.ActiveCfg = Release|Any CPU
{83BB2593-B344-42DB-8C61-D1A331054279}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

0 comments on commit f8b1ef0

Please sign in to comment.