Skip to content

Commit

Permalink
✔ Fixed Redundant Console Output.
Browse files Browse the repository at this point in the history
✔ Fixed Embedded Resource Updatability.
✔ Bumped All Projects To NETStandard 2.1.
  • Loading branch information
Texnomic committed May 31, 2020
1 parent 9f1c387 commit 86b63a1
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 0 additions & 5 deletions Texnomic.SecureDNS.Terminal/CLI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
using Texnomic.DNS.Servers;
using Texnomic.SecureDNS.Terminal.Options;

using Console = Colorful.Console;

namespace Texnomic.SecureDNS.Terminal
{
public class CLI : IHostedService, IDisposable
Expand All @@ -26,9 +24,6 @@ public CLI(IOptionsMonitor<TerminalOptions> TerminalOptions, ProxyServer ProxySe

public async Task StartAsync(CancellationToken CancellationToken)
{
Server.Started += (Sender, Args) => Console.WriteLine(" Server Started.\n\r");
Server.Stopped += (Sender, Args) => Console.WriteLine("\n\r Server Stopped.");

await Server.StartAsync(CancellationToken);
}

Expand Down
24 changes: 20 additions & 4 deletions Texnomic.SecureDNS.Terminal/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Colorful;
Expand All @@ -24,7 +25,6 @@
using Texnomic.SecureDNS.Protocols;
using Texnomic.SecureDNS.Terminal.Enums;
using Texnomic.SecureDNS.Terminal.Options;
using Texnomic.SecureDNS.Terminal.Properties;

using Console = Colorful.Console;
using Protocol = Texnomic.SecureDNS.Terminal.Enums.Protocol;
Expand Down Expand Up @@ -54,10 +54,26 @@ public static async Task Main(string[] Arguments)
await HostBuilder.RunConsoleAsync();
}

private static byte[] ReadResource(string Name)
{
var MainAssembly = Assembly.GetExecutingAssembly();

var ResourceName = MainAssembly.GetManifestResourceNames()
.Single(Resource => Resource.EndsWith(Name));

using var Stream = MainAssembly.GetManifestResourceStream(ResourceName);

var Buffer = new byte[Stream.Length];

Stream.Read(Buffer);

return Buffer;
}

private static void BuildHost()
{
if(!File.Exists("AppSettings.json"))
File.WriteAllBytes("AppSettings.json", Resources.AppSettings);
File.WriteAllBytes("AppSettings.json", ReadResource("AppSettings.json"));

HostBuilder = new HostBuilder()
.ConfigureAppConfiguration(ConfigureApp)
Expand All @@ -84,7 +100,7 @@ private static void Splash()
{
Console.Title = "Texnomic SecureDNS";

var Speed = new Figlet(FigletFont.Load(Resources.Speed));
var Speed = new Figlet(FigletFont.Load(ReadResource("Speed.flf")));

Console.WriteWithGradient(Speed.ToAscii(" Texnomic").ConcreteValue.ToArray(), System.Drawing.Color.Yellow, System.Drawing.Color.Fuchsia, 14);

Expand All @@ -99,7 +115,7 @@ private static void ConfigureApp(HostBuilderContext HostBuilderContext, IConfigu
}
private static void ConfigureLogging(HostBuilderContext HostBuilderContext, ILoggingBuilder Logging)
{
Logging.AddConsole();
//Logging.AddConsole();
}
private static void ConfigureLogger(HostBuilderContext HostBuilderContext, LoggerConfiguration LoggerConfiguration)
{
Expand Down
20 changes: 0 additions & 20 deletions Texnomic.SecureDNS.Terminal/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions Texnomic.SecureDNS.Terminal/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="AppSettings" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\AppSettings.json;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="Speed" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Fonts\Speed.flf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
14 changes: 12 additions & 2 deletions Texnomic.SecureDNS.Terminal/Texnomic.SecureDNS.Terminal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
<PackageId>Texnomic SecureDNS Terminal</PackageId>
</PropertyGroup>

<ItemGroup>
<None Remove="AppSettings.json" />
<None Remove="Fonts\Speed.flf" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="AppSettings.json" />
<EmbeddedResource Include="Fonts\Speed.flf" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Colorful.Console" Version="1.2.10" />
<PackageReference Include="Destructurama.Attributed" Version="2.0.0" />
Expand Down Expand Up @@ -73,9 +83,9 @@
</ItemGroup>

<ItemGroup>
<None Update="AppSettings.json">
<Resource Include="AppSettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</Resource>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Texnomic.Sodium/Texnomic.Sodium.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 86b63a1

Please sign in to comment.