Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,27 @@ private static void CopyAttributes(RadiusPacket? source, RadiusPacket? target)

private void AddProxyStateAttribute(RadiusPacket source, RadiusPacket target)
{
if (!source.Attributes.TryGetValue(ProxyStateAttribute, out var proxyStateAttribute)) return;
if (target.Attributes.ContainsKey(ProxyStateAttribute)) return;
var value = proxyStateAttribute.Values.FirstOrDefault();
if (value != null)
if (!source.Attributes.TryGetValue(ProxyStateAttribute, out var proxyStateAttribute))
{

_logger.LogDebug("Source Attribute '{attrname:l}' is empty", ProxyStateAttribute);
return;
}
if (target.Attributes.ContainsKey(ProxyStateAttribute))
{
_logger.LogDebug("Target already contains attribute '{attrname:l}'", ProxyStateAttribute);
return;
}
var value = proxyStateAttribute.Values;
if (value is { Count: > 0 })
{
_logger.LogDebug("Added/replaced attribute '{attrname:l}' to reply", ProxyStateAttribute);
target.AddAttributeValue(ProxyStateAttribute, value);
}
else
{
_logger.LogDebug("Attribute '{attrname:l}' is empty", ProxyStateAttribute);
}
}

private static void AddMessageAuthenticatorIfMissing(RadiusPacket packet)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections;
using System.Net;
using System.Text;
using Multifactor.Radius.Adapter.v2.Application.Core.Enum;
Expand Down Expand Up @@ -210,10 +211,22 @@ private static byte[] GetAttributeValueBytes(object value)
contentBytes = BitConverter.GetBytes(val);
Array.Reverse(contentBytes);
return contentBytes;
case long val:
contentBytes = BitConverter.GetBytes(val);
Array.Reverse(contentBytes);
return contentBytes;
case ulong val:
contentBytes = BitConverter.GetBytes(val);
Array.Reverse(contentBytes);
return contentBytes;
case byte[] val:
return val;
case IPAddress val:
return val.GetAddressBytes();
case IEnumerable val:
return val.Cast<object>()
.SelectMany(GetAttributeValueBytes)
.ToArray();
default:
throw new NotImplementedException();
}
Expand Down