Skip to content

Commit

Permalink
Merge pull request #68 from datalust/dev
Browse files Browse the repository at this point in the history
2.1.0 Release
  • Loading branch information
nblumhardt authored Feb 5, 2024
2 parents e3a777a + 7472517 commit 5e046f3
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 97 deletions.
52 changes: 26 additions & 26 deletions Build.ps1
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
$ErrorActionPreference = 'Stop'

$framework = 'netcoreapp3.1'
$framework = 'net8.0'

function Clean-Output
{
Write-Output "Cleaning output"
if(Test-Path ./artifacts) { rm ./artifacts -Force -Recurse }
if(Test-Path ./artifacts) { rm ./artifacts -Force -Recurse }
}

function Restore-Packages
{
Write-Output "Restoring packages"
& dotnet restore
& dotnet restore
}

function Execute-Tests
{
Write-Output "Testing native platform version"
& dotnet test ./test/Seq.Forwarder.Tests/Seq.Forwarder.Tests.csproj -c Release /p:Configuration=Release /p:Platform=x64 /p:VersionPrefix=$version
if($LASTEXITCODE -ne 0) { exit 3 }
if($LASTEXITCODE -ne 0) { throw "failed" }
}

function Create-ArtifactDir
{
Write-Output "Creating artifacts directory"
mkdir ./artifacts
mkdir ./artifacts
}

function Publish-Archives($version)
{
$rids = @("linux-x64", "osx-x64", "win-x64")
foreach ($rid in $rids) {
$rids = @("linux-x64", "osx-x64", "linux-arm64", "osx-arm64", "win-x64")
foreach ($rid in $rids) {
Write-Output "Publishing archive for $rid"
& dotnet publish src/Seq.Forwarder/Seq.Forwarder.csproj -c Release -f $framework -r $rid /p:VersionPrefix=$version /p:SeqForwarderRid=$rid
if($LASTEXITCODE -ne 0) { exit 4 }
& dotnet publish src/Seq.Forwarder/Seq.Forwarder.csproj -c Release --self-contained -f $framework -r $rid /p:VersionPrefix=$version /p:SeqForwarderRid=$rid
if($LASTEXITCODE -ne 0) { throw "failed" }

# Make sure the archive contains a reasonable root filename
mv ./src/Seq.Forwarder/bin/Release/$framework/$rid/publish/ ./src/Seq.Forwarder/bin/Release/$framework/$rid/seqfwd-$version-$rid/
# Make sure the archive contains a reasonable root filename
mv ./src/Seq.Forwarder/bin/Release/$framework/$rid/publish/ ./src/Seq.Forwarder/bin/Release/$framework/$rid/seqfwd-$version-$rid/

if ($rid.StartsWith("win-")) {
& ./build/7-zip/7za.exe a -tzip ./artifacts/seqfwd-$version-$rid.zip ./src/Seq.Forwarder/bin/Release/$framework/$rid/seqfwd-$version-$rid/
if($LASTEXITCODE -ne 0) { exit 5 }
} else {
& ./build/7-zip/7za.exe a -ttar seqfwd-$version-$rid.tar ./src/Seq.Forwarder/bin/Release/$framework/$rid/seqfwd-$version-$rid/
if($LASTEXITCODE -ne 0) { exit 5 }
if ($rid.StartsWith("win-")) {
& ./build/7-zip/7za.exe a -tzip ./artifacts/seqfwd-$version-$rid.zip ./src/Seq.Forwarder/bin/Release/$framework/$rid/seqfwd-$version-$rid/
if($LASTEXITCODE -ne 0) { throw "failed" }
} else {
& ./build/7-zip/7za.exe a -ttar seqfwd-$version-$rid.tar ./src/Seq.Forwarder/bin/Release/$framework/$rid/seqfwd-$version-$rid/
if($LASTEXITCODE -ne 0) { throw "failed" }

# Back to the original directory name
mv ./src/Seq.Forwarder/bin/Release/$framework/$rid/seqfwd-$version-$rid/ ./src/Seq.Forwarder/bin/Release/$framework/$rid/publish/
& ./build/7-zip/7za.exe a -tgzip ./artifacts/seqfwd-$version-$rid.tar.gz seqfwd-$version-$rid.tar
if($LASTEXITCODE -ne 0) { exit 6 }
# Back to the original directory name
mv ./src/Seq.Forwarder/bin/Release/$framework/$rid/seqfwd-$version-$rid/ ./src/Seq.Forwarder/bin/Release/$framework/$rid/publish/
& ./build/7-zip/7za.exe a -tgzip ./artifacts/seqfwd-$version-$rid.tar.gz seqfwd-$version-$rid.tar
if($LASTEXITCODE -ne 0) { throw "failed" }

rm seqfwd-$version-$rid.tar
}
}
rm seqfwd-$version-$rid.tar
}
}
}

Push-Location $PSScriptRoot
Expand Down
8 changes: 4 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: 2.0.{build}
version: 2.1.{build}
skip_tags: true
image: Visual Studio 2019
image: Visual Studio 2022

artifacts:
- path: artifacts/seqfwd-*.zip
- path: artifacts/seqfwd-*.tar.gz

build_script:
- ps: ./Build.ps1 -shortver "$($env:APPVEYOR_BUILD_VERSION)"
- pwsh: ./Build.ps1 -shortver "$($env:APPVEYOR_BUILD_VERSION)"

deploy:
- provider: GitHub
Expand All @@ -17,4 +17,4 @@ deploy:
tag: v$(appveyor_build_version)
on:
branch: main


20 changes: 10 additions & 10 deletions seq-forwarder.sln
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "data", "data", "{CAE68175-E
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
Release|Any CPU = Release|Any CPU
Debug|Any CPU = Debug|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{206FCC39-00A9-4C3D-998F-E0D3538E4786}.Debug|x64.ActiveCfg = Debug|x64
{206FCC39-00A9-4C3D-998F-E0D3538E4786}.Debug|x64.Build.0 = Debug|x64
{206FCC39-00A9-4C3D-998F-E0D3538E4786}.Release|x64.ActiveCfg = Release|x64
{206FCC39-00A9-4C3D-998F-E0D3538E4786}.Release|x64.Build.0 = Release|x64
{88984363-1BD7-4E60-99B9-7D07666990B8}.Debug|x64.ActiveCfg = Debug|x64
{88984363-1BD7-4E60-99B9-7D07666990B8}.Debug|x64.Build.0 = Debug|x64
{88984363-1BD7-4E60-99B9-7D07666990B8}.Release|x64.ActiveCfg = Release|x64
{88984363-1BD7-4E60-99B9-7D07666990B8}.Release|x64.Build.0 = Release|x64
{206FCC39-00A9-4C3D-998F-E0D3538E4786}.Release|Any CPU.ActiveCfg = Release|Any CPU
{206FCC39-00A9-4C3D-998F-E0D3538E4786}.Release|Any CPU.Build.0 = Release|Any CPU
{206FCC39-00A9-4C3D-998F-E0D3538E4786}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{206FCC39-00A9-4C3D-998F-E0D3538E4786}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88984363-1BD7-4E60-99B9-7D07666990B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88984363-1BD7-4E60-99B9-7D07666990B8}.Release|Any CPU.Build.0 = Release|Any CPU
{88984363-1BD7-4E60-99B9-7D07666990B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88984363-1BD7-4E60-99B9-7D07666990B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions seq-forwarder.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IO/@EntryIndexedValue">IO</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IP/@EntryIndexedValue">IP</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=apikey/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=binpath/@EntryIndexedValue">True</s:Boolean>
Expand Down
5 changes: 2 additions & 3 deletions src/Seq.Forwarder/Cli/Commands/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class RunCommand : Command

public RunCommand()
{
Options.Add("nologo", v => _noLogo = true);
Options.Add("nologo", _ => _noLogo = true);
_storagePath = Enable<StoragePathFeature>();
_listenUri = Enable<ListenUriFeature>();
}
Expand Down Expand Up @@ -149,8 +149,7 @@ static Logger CreateLogger(
if (!string.IsNullOrWhiteSpace(internalLogServerUri))
loggerConfiguration.WriteTo.Seq(
internalLogServerUri,
apiKey: internalLogServerApiKey,
compact: true);
apiKey: internalLogServerApiKey);

return loggerConfiguration.CreateLogger();
}
Expand Down
13 changes: 0 additions & 13 deletions src/Seq.Forwarder/Cli/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -669,22 +669,9 @@ public OptionException (string message, string optionName, Exception innerExcept
this.option = optionName;
}

protected OptionException (SerializationInfo info, StreamingContext context)
: base (info, context)
{
this.option = info.GetString ("OptionName");
}

public string OptionName {
get {return this.option;}
}

[SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
public override void GetObjectData (SerializationInfo info, StreamingContext context)
{
base.GetObjectData (info, context);
info.AddValue ("OptionName", option);
}
}

public delegate void OptionAction<TKey, TValue> (TKey key, TValue value);
Expand Down
2 changes: 1 addition & 1 deletion src/Seq.Forwarder/Config/SeqForwarderConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static void Write(string filename, SeqForwarderConfig data)

var dir = Path.GetDirectoryName(filename);
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
Directory.CreateDirectory(dir!);

var content = JsonConvert.SerializeObject(data, Formatting.Indented, SerializerSettings);
File.WriteAllText(filename, content);
Expand Down
2 changes: 2 additions & 0 deletions src/Seq.Forwarder/Config/SeqForwarderOutputConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using Newtonsoft.Json;
using Seq.Forwarder.Cryptography;

Expand All @@ -24,6 +25,7 @@ public class SeqForwarderOutputConfig
public string ServerUrl { get; set; } = "http://localhost:5341";
public ulong EventBodyLimitBytes { get; set; } = 256 * 1024;
public ulong RawPayloadLimitBytes { get; set; } = 10 * 1024 * 1024;
public uint? PooledConnectionLifetimeMilliseconds { get; set; } = null;

const string ProtectedDataPrefix = "pd.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ public string Unprotect(string @protected)

public string Protect(string value)
{
var salt = new byte[16];
using (var cp = new RNGCryptoServiceProvider())
cp.GetBytes(salt);

var salt = RandomNumberGenerator.GetBytes(16);
var bytes = ProtectedData.Protect(Encoding.UTF8.GetBytes(value), salt, DataProtectionScope.LocalMachine);
return $"{Convert.ToBase64String(bytes)}${Convert.ToBase64String(salt)}";
}
Expand Down
6 changes: 3 additions & 3 deletions src/Seq.Forwarder/Schema/EventSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ public static bool FromClefFormat(in int lineNumber, JObject compactFormat, [May
if (withFormat.Count() == renderingsArray.Count)
{
// ReSharper disable once PossibleMultipleEnumeration
Dictionary<string, Dictionary<string, string>>? renderingsByProperty = withFormat
.Zip(renderingsArray, (p, j) => new { p.PropertyName, p.Format, Rendering = j.Value<string>() })
var renderingsByProperty = withFormat
.Zip(renderingsArray, (p, j) => new { p.PropertyName, Format = p.Format!, Rendering = j.Value<string>() })
.GroupBy(p => p.PropertyName)
.ToDictionary(g => g.Key, g => g.ToDictionaryDistinct(p => p.Format, p => p.Rendering));

Expand Down Expand Up @@ -152,7 +152,7 @@ public static bool FromClefFormat(in int lineNumber, JObject compactFormat, [May
{
if (eventTypeToken.Type == JTokenType.Integer)
{
result.Add("EventType", uint.Parse(eventTypeToken.Value<string>()));
result.Add("EventType", uint.Parse(eventTypeToken.Value<string>()!));
}
else if (eventTypeToken.Type == JTokenType.String)
{
Expand Down
29 changes: 15 additions & 14 deletions src/Seq.Forwarder/Seq.Forwarder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,48 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>CA1416</NoWarn>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Authors>Datalust Pty Ltd, Contributors</Authors>
<Company>Datalust Pty Ltd</Company>
<AssemblyTitle>Seq Forwarder</AssemblyTitle>
<Description>Seq HTTP Log Forwarder</Description>
<Copyright>Copyright © Datalust Pty Ltd and Contributors</Copyright>
<AssemblyName>seqfwd</AssemblyName>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<Nullable>Enable</Nullable>
</PropertyGroup>

<PropertyGroup Condition=" '$(SeqForwarderRid)' == 'win-x64' Or ('$(SeqForwarderRid)' == '' And '$([MSBuild]::IsOsPlatform(`WINDOWS`))' == 'true')">
<IsWindows>true</IsWindows>
<DefineConstants>$(DefineConstants);WINDOWS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(SeqForwarderRid)' == 'linux-x64' Or ('$(SeqForwarderRid)' == '' And '$([MSBuild]::IsOsPlatform(`LINUX`))' == 'true')">
<PropertyGroup Condition=" '$(SeqForwarderRid)' == 'linux-x64' Or '$(SeqForwarderRid)' == 'linux-arm64' Or ('$(SeqForwarderRid)' == '' And '$([MSBuild]::IsOsPlatform(`LINUX`))' == 'true')">
<IsLinux>true</IsLinux>
<IsUnix>true</IsUnix>
<DefineConstants>$(DefineConstants);LINUX;UNIX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(SeqForwarderRid)' == 'osx-x64' Or ('$(SeqForwarderRid)' == '' And '$([MSBuild]::IsOsPlatform(`OSX`))' == 'true')">
<PropertyGroup Condition=" '$(SeqForwarderRid)' == 'osx-x64' Or '$(SeqForwarderRid)' == 'osx-arm64' Or ('$(SeqForwarderRid)' == '' And '$([MSBuild]::IsOsPlatform(`OSX`))' == 'true')">
<IsMacOS>true</IsMacOS>
<IsUnix>true</IsUnix>
<DefineConstants>$(DefineConstants);MACOS;UNIX</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="autofac" Version="5.2.0" />
<PackageReference Include="autofac.extensions.dependencyinjection" Version="6.0.0" />
<PackageReference Include="autofac" Version="8.0.0" />
<PackageReference Include="autofac.extensions.dependencyinjection" Version="9.0.0" />
<PackageReference Include="lightningdb" Version="0.10.0" />
<PackageReference Include="newtonsoft.json" Version="12.0.3" />
<PackageReference Include="serilog" Version="2.9.0" />
<PackageReference Include="serilog.aspnetcore" Version="3.4.0" />
<PackageReference Include="serilog.formatting.compact" Version="1.1.0" />
<PackageReference Include="serilog.sinks.console" Version="3.1.1" />
<PackageReference Include="serilog.sinks.file" Version="4.1.0" />
<PackageReference Include="serilog.sinks.seq" Version="4.0.0" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="4.7.0" />
<PackageReference Include="newtonsoft.json" Version="13.0.3" />
<PackageReference Include="serilog" Version="3.1.1" />
<PackageReference Include="serilog.aspnetcore" Version="8.0.1" />
<PackageReference Include="serilog.formatting.compact" Version="2.0.0" />
<PackageReference Include="serilog.sinks.console" Version="5.0.1" />
<PackageReference Include="serilog.sinks.file" Version="5.0.0" />
<PackageReference Include="serilog.sinks.seq" Version="6.0.0" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(IsWindows)' == 'true' ">
Expand Down
23 changes: 21 additions & 2 deletions src/Seq.Forwarder/SeqForwarderModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using System;
using System.Net.Http;
using System.Threading;
using Autofac;
using Seq.Forwarder.Config;
using Seq.Forwarder.Cryptography;
Expand Down Expand Up @@ -45,14 +46,32 @@ protected override void Load(ContainerBuilder builder)

builder.Register(c =>
{
var baseUri = c.Resolve<SeqForwarderOutputConfig>().ServerUrl;
var outputConfig = c.Resolve<SeqForwarderOutputConfig>();
var baseUri = outputConfig.ServerUrl;
if (string.IsNullOrWhiteSpace(baseUri))
throw new ArgumentException("The destination Seq server URL must be configured in SeqForwarder.json.");

if (!baseUri.EndsWith("/"))
baseUri += "/";

return new HttpClient { BaseAddress = new Uri(baseUri) };
// additional configuration options that require the use of SocketsHttpHandler should be added to
// this expression, using an "or" operator.

var hasSocketHandlerOption =
(outputConfig.PooledConnectionLifetimeMilliseconds.HasValue);

if (hasSocketHandlerOption)
{
var httpMessageHandler = new SocketsHttpHandler()
{
PooledConnectionLifetime = (outputConfig.PooledConnectionLifetimeMilliseconds.HasValue) ? TimeSpan.FromMilliseconds(outputConfig.PooledConnectionLifetimeMilliseconds.Value) : Timeout.InfiniteTimeSpan,
};

return new HttpClient(httpMessageHandler) { BaseAddress = new Uri(baseUri) };
}

return new HttpClient() { BaseAddress = new Uri(baseUri) };

}).SingleInstance();

builder.RegisterInstance(StringDataProtector.CreatePlatformDefault());
Expand Down
6 changes: 3 additions & 3 deletions src/Seq.Forwarder/Util/CaptiveProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ public static int Run(
if (!string.IsNullOrEmpty(workingDirectory))
startInfo.WorkingDirectory = workingDirectory;

using var process = Process.Start(startInfo);
using var process = Process.Start(startInfo)!;
using var outputComplete = new ManualResetEvent(false);
using var errorComplete = new ManualResetEvent(false);
// ReSharper disable AccessToDisposedClosure

process.OutputDataReceived += (o, e) =>
process.OutputDataReceived += (_, e) =>
{
if (e.Data == null)
outputComplete.Set();
Expand All @@ -62,7 +62,7 @@ public static int Run(
};
process.BeginOutputReadLine();

process.ErrorDataReceived += (o, e) =>
process.ErrorDataReceived += (_, e) =>
{
if (e.Data == null)
errorComplete.Set();
Expand Down
Loading

0 comments on commit 5e046f3

Please sign in to comment.