Conversation
| var errorMessage = FlattenException(ex); | ||
| StartupLogger.Error(ex, "Unable to start: {Message:l}", errorMessage); | ||
| if(ex is InvalidConfigurationException) | ||
| StartupLogger.Error(null, "Unable to start: {Message:l}", ex.Message); |
There was a problem hiding this comment.
Почему не прокинута переменная ex?
| services.AddSingleton(appVars); | ||
| } | ||
|
|
||
| private static void AddLdapBindNameFormation(IServiceCollection services) |
There was a problem hiding this comment.
Предлагаю эти вещи раскидать по модулям, чтобы сделать честными фичами и избавиться от DI hell
| _logger.LogWarning(ex, "Error while processing packet from '{client:l}'", udpPacket.RemoteEndPoint.Address); | ||
| } | ||
| } | ||
| _udpClient = udpClient ?? throw new ArgumentNullException(nameof(udpClient)); |
There was a problem hiding this comment.
Проверки на null излишни, если аллокацией занимается Service Provider
|
|
||
| namespace Multifactor.Radius.Adapter.v2.Server; | ||
|
|
||
| public class AdapterServer : IDisposable | ||
| public class AdapterServer : IAsyncDisposable |
| @@ -1,47 +1,63 @@ | |||
| using Microsoft.Extensions.Hosting; | |||
| using Microsoft.Extensions.Logging; | |||
| using Multifactor.Core.Ldap.LangFeatures; | |||
|
|
|||
| namespace Multifactor.Radius.Adapter.v2.Server; | |||
|
|
|||
| public class ServerHost : IHostedService | |||
|
|
||
| namespace Multifactor.Radius.Adapter.v2.Application.Features.Ldap.Ports; | ||
|
|
||
| public interface ILdapAdapter |
There was a problem hiding this comment.
Это не порт, а толстый неудобный интерфейс. А еще в папке Features/Ldap не нашел собственно фичи. Есть только этот интерфейс имодели
|
|
||
| namespace Multifactor.Radius.Adapter.v2.Infrastructure.Configurations.Models; | ||
|
|
||
| public class ConfigurationFile |
There was a problem hiding this comment.
Только не файл, потому что можно читать ото всюду
| } | ||
| catch (Exception ex) | ||
| { | ||
| Console.WriteLine($"\n=== Ошибка при Get<ConfigurationFile>(): {ex.Message} ==="); |
| try | ||
| { | ||
| var config = builder.Get<ConfigurationFile>(); | ||
| config.FileName = Path.GetFileNameWithoutExtension(filePath); |
There was a problem hiding this comment.
нет проверки на null, добавить
|
|
||
| public static class ConfigurationBuilderExtensions | ||
| { | ||
| public static IConfigurationBuilder AddLegacyXmlConfig( |
| @@ -0,0 +1,45 @@ | |||
| namespace Multifactor.Radius.Adapter.v2.Infrastructure.Adapters.Multifactor.Http; | |||
|
|
|||
| public class ActivityContext | |||
There was a problem hiding this comment.
по хорошему стоит от него отказаться в пользу OpenTelemtry
| RadiusAdapterConfigurationFile.ConfigName); | ||
| } | ||
| var level = rootConfiguration.LoggingLevel; | ||
| var skip = string.IsNullOrWhiteSpace(level); |
| // { | ||
| // throw new InvalidConfigurationException( | ||
| // string.Concat("'{prop}' element not found. Config name: '{0}'", "rootConfiguration.ConfigurationName")); | ||
| // } |
There was a problem hiding this comment.
комменты можно дропнуть
| RadiusAdapterConfigurationDescription.Property(x => x.AppSettings.LoggingFormat), | ||
| RadiusAdapterConfigurationDescription.Property(x => x.AppSettings.FileLogOutputTemplate)); | ||
| // Log.Logger.Warning( | ||
| // "The {LoggingFormat:l} parameter cannot be used together with the template. The {FileLogOutputTemplate:l} parameter will be ignored.", |
There was a problem hiding this comment.
комменты можно дропнуть
| // if (!Directory.Exists(dir)) | ||
| // { | ||
| // Directory.CreateDirectory(dir); | ||
| // } |
There was a problem hiding this comment.
комменты можно дропнуть
| { | ||
| contentBytes = RadiusPasswordProtector.Encrypt(sharedSecret, authenticator, contentBytes); | ||
| } | ||
| else if (attributeDefinition.Code == 80) // Message-Authenticator |
| { | ||
| _radiusDictionary = radiusDictionary ?? throw new ArgumentNullException(nameof(radiusDictionary)); | ||
| _cryptoProvider = cryptoProvider ?? throw new ArgumentNullException(nameof(cryptoProvider)); | ||
| // _attributeSerializer = attributeSerializer ?? throw new ArgumentNullException(nameof(attributeSerializer)); |
There was a problem hiding this comment.
комменты можно дропнуть
| private readonly IRadiusDictionary _radiusDictionary; | ||
| private readonly ILogger<RadiusAttributeParser> _logger; | ||
| const int VendorSpecific = 26; | ||
| const int MessageAuthenticator = 80; |
There was a problem hiding this comment.
снова те же константы
| byte vendorType = contentBytes[4]; | ||
| byte vendorLength = contentBytes[5]; | ||
|
|
||
| if (vendorLength < 2 || 2 + vendorLength - 2 > contentBytes.Length) |
There was a problem hiding this comment.
???? 2 + vendorLength - 2 ???? = просто vendorLength > contentBytes.Length
| var content = ParseContentBytes( | ||
| vendorContentBytes, | ||
| vendorAttribute.Type, | ||
| 26, |
What's new: