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

Commit

Permalink
Remove useHttpPut (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbialkowski-r7 authored Nov 30, 2020
1 parent 7fe0607 commit ec66e4a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 63 deletions.
56 changes: 8 additions & 48 deletions src/LogentriesCore/AsyncLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ public AsyncLogger()
private String m_Location = "";
private bool m_ImmediateFlush = false;
public bool m_Debug = false;
private bool m_UseHttpPut = false;
private bool m_UseSsl = false;

// Properties for defining location of DataHub instance if one is used.
Expand Down Expand Up @@ -219,16 +218,6 @@ public bool getDebug()
return m_Debug;
}

public void setUseHttpPut(bool useHttpPut)
{
m_UseHttpPut = useHttpPut;
}

public bool getUseHttpPut()
{
return m_UseHttpPut;
}

public void setUseSsl(bool useSsl)
{
m_UseSsl = useSsl;
Expand Down Expand Up @@ -356,7 +345,7 @@ protected virtual void Run()

// If m_UseDataHub == true (logs are sent to DataHub instance) then m_Token is not
// appended to the message.
string finalLine = ((!m_UseHttpPut && !m_UseDataHub) ? this.m_Token + line : line) + '\n';
string finalLine = ((!m_UseDataHub) ? this.m_Token + line : line) + '\n';

// Add prefixes: LogID and HostName if they are defined.
if (!isPrefixEmpty)
Expand Down Expand Up @@ -411,16 +400,10 @@ protected virtual void OpenConnection()
// Create LeClient instance providing all needed parameters. If DataHub-related properties
// have not been overridden by log4net or NLog configurators, then DataHub is not used,
// because m_UseDataHub == false by default.
LeClient = new LeClient(m_UseHttpPut, m_UseSsl, m_UseDataHub, m_DataHubAddr, m_DataHubPort);
LeClient = new LeClient(m_UseSsl, m_UseDataHub, m_DataHubAddr, m_DataHubPort);
}

LeClient.Connect();

if (m_UseHttpPut)
{
var header = String.Format("PUT /{0}/hosts/{1}/?realtime=1 HTTP/1.1\r\n\r\n", m_AccountKey, m_Location);
LeClient.Write(ASCII.GetBytes(header), 0, header.Length);
}
}
catch (Exception ex)
{
Expand Down Expand Up @@ -539,40 +522,17 @@ private string retrieveSetting(String name)
*/
public virtual bool LoadCredentials()
{
if (!m_UseHttpPut)
{
if (GetIsValidGuid(m_Token))
return true;

var configToken = retrieveSetting(LegacyConfigTokenName) ?? retrieveSetting(ConfigTokenName);

if (!String.IsNullOrEmpty(configToken) && GetIsValidGuid(configToken))
{
m_Token = configToken;
return true;
}
WriteDebugMessages(InvalidTokenMessage);
return false;
}

if (m_AccountKey != "" && GetIsValidGuid(m_AccountKey) && m_Location != "")
if (GetIsValidGuid(m_Token))
return true;

var configAccountKey = retrieveSetting(LegacyConfigAccountKeyName) ?? retrieveSetting(ConfigAccountKeyName);
var configToken = retrieveSetting(LegacyConfigTokenName) ?? retrieveSetting(ConfigTokenName);

if (!String.IsNullOrEmpty(configAccountKey) && GetIsValidGuid(configAccountKey))
if (!String.IsNullOrEmpty(configToken) && GetIsValidGuid(configToken))
{
m_AccountKey = configAccountKey;

var configLocation = retrieveSetting(LegacyConfigLocationName) ?? retrieveSetting(ConfigLocationName);

if (!String.IsNullOrEmpty(configLocation))
{
m_Location = configLocation;
return true;
}
m_Token = configToken;
return true;
}
WriteDebugMessages(InvalidHttpPutCredentialsMessage);
WriteDebugMessages(InvalidTokenMessage);
return false;
}

Expand Down
12 changes: 3 additions & 9 deletions src/LogentriesCore/LeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@ class LeClient
// 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.
protected const int LeApiHttpPort = 80;

// 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 data.logentries.com server; otherwise - with
// defined server on defined port.
public LeClient(bool useHttpPut, bool useSsl, bool useDataHub, String serverAddr, int port)
public LeClient(bool useSsl, bool useDataHub, String serverAddr, int port)
{

// Override port number and server address to send logs to DataHub instance.
Expand All @@ -41,9 +35,9 @@ public LeClient(bool useHttpPut, bool useSsl, bool useDataHub, String serverAddr
m_UseSsl = useSsl;

if (!m_UseSsl)
m_TcpPort = useHttpPut ? LeApiHttpPort : LeApiTokenPort;
m_TcpPort = LeApiTokenPort;
else
m_TcpPort = useHttpPut ? LeApiHttpsPort : LeApiTokenTlsPort;
m_TcpPort = LeApiTokenTlsPort;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/LogentriesCore/LogentriesCore.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<package >
<metadata>
<id>logentries.core</id>
<version>2.8.3</version>
<version>3.0.0</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>
<releaseNotes>Remove legacy ingestion option</releaseNotes>
<copyright>Copyright © 2020</copyright>
<tags>logentries logging dotnet core</tags>
</metadata>
Expand Down
4 changes: 2 additions & 2 deletions src/LogentriesLog4net/LogentriesLog4net.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<package >
<metadata>
<id>logentries.log4net</id>
<version>2.8.3</version>
<version>3.0.0</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>
<releaseNotes>Remove legacy ingestion option</releaseNotes>
<copyright>Copyright © 2020</copyright>
<tags>logentries logging dotnet log4net</tags>
</metadata>
Expand Down
4 changes: 2 additions & 2 deletions src/LogentriesNLog/LogentriesNLog.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<package >
<metadata>
<id>logentries.nlog</id>
<version>2.8.3</version>
<version>3.0.0</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>
<releaseNotes>Remove legacy ingestion option</releaseNotes>
<copyright>Copyright © 2020</copyright>
<tags>logentries logging dotnet nlog</tags>
</metadata>
Expand Down

0 comments on commit ec66e4a

Please sign in to comment.