Skip to content

Conversation

@joshoxe
Copy link
Collaborator

@joshoxe joshoxe commented May 23, 2021

No description provided.

@joshoxe joshoxe linked an issue May 23, 2021 that may be closed by this pull request
joshoxe added 8 commits May 23, 2021 12:00
* LoggerElements are now initialised using IOptions
* Attributes now must be specified under a JSON section in the config

Task: #9
* Fixes a lot of the configuration not being deserialized correctly
* Removes a lot of code duplication from validation

Task: #9
Copy link
Member

@lewishazell lewishazell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ready. I'm happy to check server linking if need be.

Looks good!

using Microsoft.Extensions.Options;

namespace cmpctircd.Validation {
public class ConfigurationOptionsValidator : AbstractValidator<IOptions<ConfigurationOptions>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NICE

services.AddOptions<ServerOptions>().Bind(configuration);
services.AddOptions<LoggerOptions>().Bind(configuration);
//services.AddOptions<ConfigurationOptions>().Bind(configuration);
services.Configure<ConfigurationOptions>(configuration);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly how I imagined this working, I like!

try {
// Restrict the commands which non-registered (i.e. pre PONG, pre USER/NICK) users can execute
if ((client.State.Equals(ClientState.PreAuth) || (ircd.Config.Advanced.ResolveHostnames && client.ResolvingHost)) && !registrationCommands.Contains(packet.ToUpper())) {
if ((client.State.Equals(ClientState.PreAuth) || (ircd.Config.Value.Advanced.ResolveHostnames && client.ResolvingHost)) && !registrationCommands.Contains(packet.ToUpper())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might be able to inject specific configs info PacketManager soon anyway. No problem with this.

HashAlgorithm algorithm;
if(!_algorithms.TryGetValue(ircop.Algorithm, out algorithm))
algorithm = _algorithms[ircop.Algorithm] = (ircop.Algorithm.GetConstructor(Type.EmptyTypes)?.Invoke(new object[0]) as HashAlgorithm) ?? throw new IrcErrNoOperHostException(client);
if(!_algorithms.TryGetValue(ircop.AlgorithmType, out algorithm))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about this part. We'll figure something out.

We should test server linking is still working.

@joshoxe joshoxe marked this pull request as ready for review December 8, 2021 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decouple configuration

3 participants