This commit is contained in:
2023-11-02 14:41:32 -07:00
parent 3dd4034a84
commit 03bd20fc8c
16 changed files with 142 additions and 143 deletions

View File

@ -35,8 +35,8 @@ public class InboundController : ControllerBase
{
public bool Success { get; set; }
public long HeaderID { get; set; }
public List<string> Errors { get; set; }
public List<string> Warnings { get; set; }
public List<string>? Errors { get; set; }
public List<string>? Warnings { get; set; }
}
// this is the main endpoint, it accepts a JSON message that contains both the header and data records together
@ -86,7 +86,7 @@ public class InboundController : ControllerBase
else
r.Errors.Add("Invalid json");
if (r.Errors.Count == 0)
if (r.Errors.Count == 0 && jsonbody is not null)
{
try
{
@ -147,14 +147,14 @@ public class InboundController : ControllerBase
if (string.IsNullOrWhiteSpace(_AppSettings.InboundApiAllowedIPList))
return true;
System.Net.IPAddress remoteIP = HttpContext.Connection.RemoteIpAddress;
byte[] remoteIPBytes = remoteIP.GetAddressBytes();
System.Net.IPAddress? remoteIP = HttpContext.Connection.RemoteIpAddress;
byte[]? remoteIPBytes = remoteIP?.GetAddressBytes();
string[] allowedIPs = _AppSettings.InboundApiAllowedIPList.Split(';');
foreach (string ip in allowedIPs)
{
System.Net.IPAddress parsedIP;
if (System.Net.IPAddress.TryParse(ip, out parsedIP))
System.Net.IPAddress? parsedIP;
if (remoteIPBytes is not null && System.Net.IPAddress.TryParse(ip, out parsedIP))
{
if (parsedIP.GetAddressBytes().SequenceEqual(remoteIPBytes))
return true;