Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
LOG-15585 Replace legacy ingestion endpoint (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbialkowski-r7 authored Nov 30, 2020
1 parent 1523fd5 commit 7fe0607
Show file tree
Hide file tree
Showing 15 changed files with 150 additions and 49 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.vs/


## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

Expand Down Expand Up @@ -125,7 +128,7 @@ publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
Expand Down Expand Up @@ -181,3 +184,4 @@ UpgradeLog*.htm

# Microsoft Fakes
FakesAssemblies/

32 changes: 15 additions & 17 deletions src/LogentriesCore/LeClient.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
using System;
using System.IO;
using System.Linq;
using System.Net.Security;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;

namespace LogentriesCore.Net
{
class LeClient
{
// Logentries API server address.
protected const String LeApiUrl = "api.logentries.com";
// Logentries API server address.
protected const String LeIngestionHost = "data.logentries.com";

// Port number for token logging on Logentries API server.
// Port number for token logging on Logentries API server.
protected const int LeApiTokenPort = 10000;

// Port number for TLS encrypted token logging on Logentries API server
// Port number for TLS encrypted token logging on Logentries API server
protected const int LeApiTokenTlsPort = 20000;

// Port number for HTTP PUT logging on Logentries API server.
// Port number for HTTP PUT logging on Logentries API server.
protected const int LeApiHttpPort = 80;

// Port number for SSL HTTP PUT logging on Logentries API server.
// Port number for SSL HTTP PUT logging on Logentries API server.
protected const int LeApiHttpsPort = 443;

// Creates LeClient instance. If do not define useServerUrl and/or useOverrideProt during call
// LeClient will be configured to work with api.logentries.com server; otherwise - with
// LeClient will be configured to work with data.logentries.com server; otherwise - with
// defined server on defined port.
public LeClient(bool useHttpPut, bool useSsl, bool useDataHub, String serverAddr, int port)
{

// Override port number and server address to send logs to DataHub instance.
if (useDataHub)
{
Expand All @@ -47,15 +44,15 @@ public LeClient(bool useHttpPut, bool useSsl, bool useDataHub, String serverAddr
m_TcpPort = useHttpPut ? LeApiHttpPort : LeApiTokenPort;
else
m_TcpPort = useHttpPut ? LeApiHttpsPort : LeApiTokenTlsPort;
}
}
}

private bool m_UseSsl = false;
private int m_TcpPort;
private TcpClient m_Client = null;
private Stream m_Stream = null;
private SslStream m_SslStream = null;
private String m_ServerAddr = LeApiUrl; // By default m_ServerAddr points to api.logentries.com if useDataHub is not set to true.
private String m_ServerAddr = LeIngestionHost; // By default m_ServerAddr points to data.logentries.com if useDataHub is not set to true.

private Stream ActiveStream
{
Expand All @@ -82,7 +79,7 @@ public void SetSocketKeepAliveValues(TcpClient tcpc, int KeepAliveTime, int Keep

// .net 1.1 type
//int SIO_KEEPALIVE_VALS = -1744830460; //(or 0x98000004)
//socket.IOControl(SIO_KEEPALIVE_VALS, inOptionValues, null);
//socket.IOControl(SIO_KEEPALIVE_VALS, inOptionValues, null);

// .net 3.5 type
tcpc.Client.IOControl(IOControlCode.KeepAliveValues, inOptionValues, null);
Expand All @@ -95,15 +92,15 @@ public void Connect()

// on Azure sockets will be closed after some minutes idle.
// which for some reason messes up this library causing it to lose data.

// turn on keepalive, to keep the sockets open.
// I don't really understand why this helps the problem, since the socket already has NoDelay set
// so data should be sent immediately. And indeed it does appear to be sent promptly when it works.
m_Client.Client.SetSocketOption( SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);

// set timeouts to 10 seconds idle before keepalive, 1 second between repeats,
// set timeouts to 10 seconds idle before keepalive, 1 second between repeats,
SetSocketKeepAliveValues(m_Client, 10 *1000, 1000);

m_Stream = m_Client.GetStream();

if (m_UseSsl)
Expand Down Expand Up @@ -139,3 +136,4 @@ public void Close()
}
}
}

27 changes: 19 additions & 8 deletions src/LogentriesCore/LogentriesCore.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NuGet.Build.Packaging.0.2.5-dev.8\build\NuGet.Build.Packaging.props" Condition="Exists('..\packages\NuGet.Build.Packaging.0.2.5-dev.8\build\NuGet.Build.Packaging.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -12,6 +13,20 @@
<AssemblyName>LogentriesCore</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<PackageId>logentries.core</PackageId>
<PackageVersion>2.8.3</PackageVersion>
<Authors>Logentries</Authors>
<Copyright>Copyright © 2020</Copyright>
<NeutralLanguage>en</NeutralLanguage>
<PackageLicenseUrl>https://github.com/rapid7/le_dotnet/blob/master/LICENSE.txt</PackageLicenseUrl>
<Owners>Logentries</Owners>
<PackageProjectUrl>https://github.com/rapid7/le_dotnet/</PackageProjectUrl>
<PackageReleaseNotes>Switch ingestion endpoint from legacy deprecated one.</PackageReleaseNotes>
<Summary>Logentries logging core library for dotnet support.</Summary>
<PackageTags>logentries;logging;dotnet;</PackageTags>
<Title>LogentriesCore</Title>
<Description>Logentries logging core library for dotnet support.</Description>
<PackOnBuild>true</PackOnBuild>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -53,17 +68,13 @@
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>if $(ConfigurationName) == Release (
COPY "$(TargetPath)" "%25NUGET_PROJECTS%25$(ProjectName)\2.6.0\lib\net40\" /Y
nuget pack %25NUGET_PROJECTS%25$(ProjectName)\2.6.0\logentries.core.nuspec /o %25NUGET_PROJECTS%25$(ProjectName)\2.6.0\
)</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
<Import Project="..\packages\NuGet.Build.Packaging.0.2.5-dev.8\build\NuGet.Build.Packaging.targets" Condition="Exists('..\packages\NuGet.Build.Packaging.0.2.5-dev.8\build\NuGet.Build.Packaging.targets')" />
</Project>

21 changes: 21 additions & 0 deletions src/LogentriesCore/LogentriesCore.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>logentries.core</id>
<version>2.8.3</version>
<title>logentries.core</title>
<authors>Logentries</authors>
<owners>Logentries</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<projectUrl>https://github.com/rapid7/le_dotnet/</projectUrl>
<description>Logentries logging library core</description>
<releaseNotes>Switch ingestion endpoint from legacy deprecated one.</releaseNotes>
<copyright>Copyright © 2020</copyright>
<tags>logentries logging dotnet core</tags>
</metadata>
<files>
<file src="bin\Release\LogentriesCore.dll" target="lib"></file>
</files>
</package>

6 changes: 3 additions & 3 deletions src/LogentriesCore/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("LogentriesCore")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("Logentries logging core library for dotnet support.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("Logentries")]
[assembly: AssemblyProduct("LogentriesCore")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
1 change: 1 addition & 0 deletions src/LogentriesCore/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.1.0" targetFramework="net40" />
<package id="NuGet.Build.Packaging" version="0.2.5-dev.8" targetFramework="net40" developmentDependency="true" />
</packages>
27 changes: 19 additions & 8 deletions src/LogentriesLog4net/LogentriesLog4net.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NuGet.Build.Packaging.0.2.5-dev.8\build\NuGet.Build.Packaging.props" Condition="Exists('..\packages\NuGet.Build.Packaging.0.2.5-dev.8\build\NuGet.Build.Packaging.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -12,6 +13,20 @@
<AssemblyName>LogentriesLog4net</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<PackOnBuild>true</PackOnBuild>
<PackageId>logentries.log4net</PackageId>
<PackageVersion>2.8.3</PackageVersion>
<Authors>Logentries</Authors>
<Copyright>Copyright © 2020</Copyright>
<NeutralLanguage>en</NeutralLanguage>
<PackageLicenseUrl>https://github.com/rapid7/le_dotnet/blob/master/LICENSE.txt</PackageLicenseUrl>
<Owners>Logentries</Owners>
<PackageProjectUrl>https://github.com/rapid7/le_dotnet/</PackageProjectUrl>
<PackageReleaseNotes>Switch ingestion endpoint from legacy deprecated one.</PackageReleaseNotes>
<Summary>Logentries logging library for log4net support.</Summary>
<PackageTags>logentries;logging;dotnet;log4net;</PackageTags>
<Title>LogentriesLog4net</Title>
<Description>Logentries logging library for log4net support.</Description>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -57,17 +72,13 @@
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>if $(ConfigurationName) == Release (
COPY "$(TargetPath)" "%25NUGET_PROJECTS%25$(ProjectName)\2.5.0\lib\net40\" /Y
nuget pack %25NUGET_PROJECTS%25$(ProjectName)\2.5.0\logentries.log4net.nuspec /o %25NUGET_PROJECTS%25$(ProjectName)\2.5.0\
)</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
<Import Project="..\packages\NuGet.Build.Packaging.0.2.5-dev.8\build\NuGet.Build.Packaging.targets" Condition="Exists('..\packages\NuGet.Build.Packaging.0.2.5-dev.8\build\NuGet.Build.Packaging.targets')" />
</Project>

21 changes: 21 additions & 0 deletions src/LogentriesLog4net/LogentriesLog4net.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>logentries.log4net</id>
<version>2.8.3</version>
<title>logentries.log4net</title>
<authors>Logentries</authors>
<owners>Logentries</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<projectUrl>https://github.com/rapid7/le_dotnet/</projectUrl>
<description>Logentries logging library for log4net support.</description>
<releaseNotes>Switch ingestion endpoint from legacy deprecated one.</releaseNotes>
<copyright>Copyright © 2020</copyright>
<tags>logentries logging dotnet log4net</tags>
</metadata>
<files>
<file src="bin\Release\LogentriesLog4net.dll" target="lib"></file>
</files>
</package>

4 changes: 2 additions & 2 deletions src/LogentriesLog4net/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("LogentriesLog4net")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("Logentries logging library for log4net support")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("Logentries")]
[assembly: AssemblyProduct("LogentriesLog4net")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
Expand Down
1 change: 1 addition & 0 deletions src/LogentriesLog4net/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.3" targetFramework="net40" />
<package id="NuGet.Build.Packaging" version="0.2.5-dev.8" targetFramework="net40" developmentDependency="true" />
</packages>
27 changes: 19 additions & 8 deletions src/LogentriesNLog/LogentriesNLog.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NuGet.Build.Packaging.0.2.5-dev.8\build\NuGet.Build.Packaging.props" Condition="Exists('..\packages\NuGet.Build.Packaging.0.2.5-dev.8\build\NuGet.Build.Packaging.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -12,6 +13,20 @@
<AssemblyName>LogentriesNLog</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<PackOnBuild>true</PackOnBuild>
<PackageId>logentries.nlog</PackageId>
<PackageVersion>2.8.3</PackageVersion>
<Authors>Logentries</Authors>
<Copyright>Copyright © 2020</Copyright>
<NeutralLanguage>en</NeutralLanguage>
<PackageLicenseUrl>https://github.com/rapid7/le_dotnet/blob/master/LICENSE.txt</PackageLicenseUrl>
<Owners>Logentries</Owners>
<PackageProjectUrl>https://github.com/rapid7/le_dotnet/</PackageProjectUrl>
<PackageReleaseNotes>Switch ingestion endpoint from legacy deprecated one.</PackageReleaseNotes>
<Summary>Logentries logging library for NLog support.</Summary>
<PackageTags>logentries;logging;dotnet;nlog;</PackageTags>
<Title>LogentriesNLog</Title>
<Description>Logentries logging library for NLog support.</Description>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -57,17 +72,13 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>if $(ConfigurationName) == Release (
COPY "$(TargetPath)" "%25NUGET_PROJECTS%25$(ProjectName)\2.3.0\lib\net40\" /Y
nuget pack %25NUGET_PROJECTS%25$(ProjectName)\2.3.0\logentries.nlog.nuspec /o %25NUGET_PROJECTS%25$(ProjectName)\2.3.0\
)</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
<Import Project="..\packages\NuGet.Build.Packaging.0.2.5-dev.8\build\NuGet.Build.Packaging.targets" Condition="Exists('..\packages\NuGet.Build.Packaging.0.2.5-dev.8\build\NuGet.Build.Packaging.targets')" />
</Project>

21 changes: 21 additions & 0 deletions src/LogentriesNLog/LogentriesNLog.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>logentries.nlog</id>
<version>2.8.3</version>
<title>logentries.nlog</title>
<authors>Logentries</authors>
<owners>Logentries</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<projectUrl>https://github.com/rapid7/le_dotnet/</projectUrl>
<description>Logentries logging library support for NLog</description>
<releaseNotes>Switch ingestion endpoint from legacy deprecated one.</releaseNotes>
<copyright>Copyright © 2020</copyright>
<tags>logentries logging dotnet nlog</tags>
</metadata>
<files>
<file src="bin\Release\LogentriesNLog.dll" target="lib"></file>
</files>
</package>

4 changes: 2 additions & 2 deletions src/LogentriesNLog/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("LogentriesNLog")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("Logentries logging library for NLog support")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("Logentries")]
[assembly: AssemblyProduct("LogentriesNLog")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
Expand Down
1 change: 1 addition & 0 deletions src/LogentriesNLog/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NLog" version="3.2.1" targetFramework="net40" />
<package id="NuGet.Build.Packaging" version="0.2.5-dev.8" targetFramework="net40" developmentDependency="true" />
</packages>
Binary file removed src/le_dotnet - Shortcut.lnk
Binary file not shown.

0 comments on commit 7fe0607

Please sign in to comment.