NetworkResurrector.Agent project

master
Tudor Stanciu 2021-12-05 22:22:14 +02:00
parent 6d20d8ac99
commit 35a7b19db1
11 changed files with 211 additions and 4 deletions

View File

@ -1,7 +1,7 @@
<Project>
<Import Project="dependencies.props" />
<PropertyGroup>
<Version>1.0.2.0</Version>
<Version>1.0.2</Version>
<Authors>Tudor Stanciu</Authors>
<Company>STA</Company>
<PackageTags>NetworkResurrector</PackageTags>

View File

@ -50,6 +50,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{C5096F61-731
release.sh = release.sh
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "agent", "agent", "{C04663A1-E0CD-41D6-A8D7-FADDF9DA8302}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetworkResurrector.Agent", "src\agent\NetworkResurrector.Agent\NetworkResurrector.Agent.csproj", "{C8C4CA6F-39E2-46FE-89E2-0A81D2F4161E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -96,6 +100,10 @@ Global
{509767A7-D11C-4143-8D45-01E62DFC2C74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{509767A7-D11C-4143-8D45-01E62DFC2C74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{509767A7-D11C-4143-8D45-01E62DFC2C74}.Release|Any CPU.Build.0 = Release|Any CPU
{C8C4CA6F-39E2-46FE-89E2-0A81D2F4161E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8C4CA6F-39E2-46FE-89E2-0A81D2F4161E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8C4CA6F-39E2-46FE-89E2-0A81D2F4161E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8C4CA6F-39E2-46FE-89E2-0A81D2F4161E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -115,6 +123,8 @@ Global
{509767A7-D11C-4143-8D45-01E62DFC2C74} = {43C78941-52E6-4AB8-9170-CC7C006E4784}
{DF5CBFF4-B348-4D4C-A6D4-B65BA1D64CEF} = {FDDE879C-E0A3-4BF1-945F-7FEA324C8EBA}
{C5096F61-7319-453B-AA28-7A1A854A6220} = {DF5CBFF4-B348-4D4C-A6D4-B65BA1D64CEF}
{C04663A1-E0CD-41D6-A8D7-FADDF9DA8302} = {B0C5F0C1-0BF8-4651-AAFC-BE01F516D7B8}
{C8C4CA6F-39E2-46FE-89E2-0A81D2F4161E} = {C04663A1-E0CD-41D6-A8D7-FADDF9DA8302}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {351D76E9-FE02-4C30-A464-7B29AFC64BC7}

View File

@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<ReleaseNotes>
<Note>
<Version>1.0.0.0</Version>
<Version>1.0.0</Version>
<Content>
Simple .net core 3.1 console application that serve as an REST API through witch a user can execute wake or shutdown commands on machines from his network.
Has been added Wake on LAN support and "wake" route in the API controller.
</Content>
</Note>
<Note>
<Version>1.0.1.0</Version>
<Version>1.0.1</Version>
<Content>
Has been added "ping" and "shutdown" support. Routes with same names have also been added to the controller.
</Content>
</Note>
<Note>
<Version>1.0.2.0</Version>
<Version>1.0.2</Version>
<Content>
Replaced Swagger and MediatR implementations with inhouse nuget packages.
Integration with local Identity Server.

View File

@ -0,0 +1,39 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace NetworkResurrector.Agent.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
})
.ToArray();
}
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace NetworkResurrector.Agent
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}

View File

@ -0,0 +1,31 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:58125",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"NetworkResurrector.Agent": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,56 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace NetworkResurrector.Agent
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "NetworkResurrector.Agent", Version = "v1" });
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "NetworkResurrector.Agent v1"));
}
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}

View File

@ -0,0 +1,15 @@
using System;
namespace NetworkResurrector.Agent
{
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string Summary { get; set; }
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}