Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ircd 59 decouple configuration #8

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0009ed6
IRCD-59 - Refactor configuration to use IConfiguration and appsetting…
joshoxe May 9, 2021
eeba837
IRCD-59 - Properly parse socket IP address from config
joshoxe May 9, 2021
8ac66ae
IRCD-59 - Add config comments
joshoxe May 9, 2021
264bd4e
IRCD-59 - Remove defunct converters
joshoxe May 9, 2021
8897c3a
IRCD-59 - Remove references to converters
joshoxe May 9, 2021
ef13af5
IRCD-59 - Add LoggerElement validator and validate configuration in IRCd
joshoxe May 12, 2021
e1a6dd1
IRCD-59 - Add mode configuration validation
joshoxe May 16, 2021
a3cc2f2
IRCD-59 - Add operator configuration validation
joshoxe May 16, 2021
2c7a163
IRCD-59 - Add server configuration validation
joshoxe May 16, 2021
f29a4bf
IRCD-59 - Add socket configuration validator
joshoxe May 16, 2021
309ab68
Merge branch 'master' into feature/IRCD-59-decouple-configuration
joshoxe May 16, 2021
d7b2663
IRCD-59 - Remove unused package
joshoxe May 16, 2021
7c48e29
IRCD-59 - Add port range validation
joshoxe May 20, 2021
98113d9
IRCD-59 - Make max mode length name 1
joshoxe May 20, 2021
ff68313
IRCD-59 - Move validator function calls to list
joshoxe May 20, 2021
c3476a8
IRCD-59 - Change list to array
joshoxe May 20, 2021
8a86589
Merge branch 'master' into feature/IRCD-59-decouple-configuration
joshoxe May 23, 2021
7a61ddd
Configuration: Move SocketOptions to Options/ subfolders
joshoxe May 23, 2021
d8ce3af
Configuration: Fix logger configuration initialisation
joshoxe May 23, 2021
1c0c415
Configuration: Add ServerOptions
joshoxe May 23, 2021
b6a55be
Configuration: Clean up SocketOptions
joshoxe May 23, 2021
e6b953e
Configuration: Convert new IConfiguration to IOptions
joshoxe May 23, 2021
318208d
Configuration: Fix renamind bugs
joshoxe May 23, 2021
1776909
Merge branch 'master' into feature/IRCD-59-decouple-configuration
joshoxe May 23, 2021
02cfd34
Configuration: Remove unused code
joshoxe May 23, 2021
8743ed3
Merge branch 'feature/IRCD-59-decouple-configuration' of https://gith…
joshoxe May 23, 2021
60b974d
Configuration: Add correct assembly for cryptography types
joshoxe May 23, 2021
033dbc8
Configuration: Fix broken OPER command by requiring an operChan chann…
joshoxe Dec 8, 2021
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ obj/
bin/
.vs
.vscode/*
/cmpctircd.sln.DotSettings.user
/cmpctircd.v3.ncrunchsolution
/_NCrunch_cmpctircd
91 changes: 0 additions & 91 deletions cmpctircd/App.config

This file was deleted.

9 changes: 5 additions & 4 deletions cmpctircd/Client/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using cmpctircd.Modes;
using System.Net;
using System.IO;
using Microsoft.Extensions.Configuration;

namespace cmpctircd
{
Expand Down Expand Up @@ -43,7 +44,7 @@ public IDictionary<string, UserMode> Modes {
public string NickIfSet() => string.IsNullOrEmpty(Nick) ? "*" : Nick;

public Client(IRCd ircd, TcpClient tc, SocketListener sl, Stream stream, string UID = null, Server OriginServer = null, bool RemoteClient = false) : base(ircd, tc, sl, stream) {
if(ircd.Config.Advanced.ResolveHostnames)
if(ircd.Config.Value.Advanced.ResolveHostnames)
ResolvingHost = true;

this.UID = UID;
Expand Down Expand Up @@ -94,7 +95,7 @@ public override void BeginTasks() {
// Check for PING/PONG events due
CheckTimeout();

if(IRCd.Config.Advanced.ResolveHostnames)
if(IRCd.Config.Value.Advanced.ResolveHostnames)
Resolve();
} catch(Exception e) {
IRCd.Log.Debug($"Failed to access client: {e.ToString()}");
Expand Down Expand Up @@ -169,7 +170,7 @@ public void Resolve() {
IRCd.DNSCache[ip] = DNSHost;
}

if (IRCd.Config.Advanced.ResolveHostnames) {
if (IRCd.Config.Value.Advanced.ResolveHostnames) {
// If the IRCd resolves all hostnames, then we will have
// delayed calling SendWelcome until DNS resolution was complete
SendWelcome();
Expand Down Expand Up @@ -252,7 +253,7 @@ public void SendLusers() {
users += list.Count();
// Count all of the users with the user mode +i (invisible)
invisible += list.Where(client => client.Modes["i"].Enabled).Count();
// Count all of the users with usermode +o (IRC Operators)
// Count all of the users with usermode +o (IRC Opers)
ircops += list.Where(client => client.Modes["o"].Enabled).Count();
}
users -= invisible;
Expand Down
36 changes: 0 additions & 36 deletions cmpctircd/Configuration/AdvancedElement.cs

This file was deleted.

29 changes: 0 additions & 29 deletions cmpctircd/Configuration/CloakElement.cs

This file was deleted.

95 changes: 0 additions & 95 deletions cmpctircd/Configuration/CmpctConfigurationSection.cs

This file was deleted.

26 changes: 0 additions & 26 deletions cmpctircd/Configuration/ListConverter.cs

This file was deleted.

47 changes: 13 additions & 34 deletions cmpctircd/Configuration/LoggerElement.cs
Original file line number Diff line number Diff line change
@@ -1,36 +1,15 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Configuration;

namespace cmpctircd.Configuration {
public class LoggerElement : ConfigurationElement {
private readonly Dictionary<string, string> _attributes = new Dictionary<string, string>();

// Guid, due to a lack of other unique properties for this element type.
public Guid InstanceGuid {
get;
} = Guid.NewGuid();

public IReadOnlyDictionary<string, string> Attributes {
get { return new ReadOnlyDictionary<string, string>(_attributes); }
}

[ConfigurationProperty("type", IsRequired = true)]
public LoggerType Type {
get { return (LoggerType) this["type"]; }
set { this["type"] = value; }
}

[ConfigurationProperty("level", IsRequired = true)]
public LogType Level {
get { return (LogType) this["level"]; }
set { this["level"] = value; }
}

protected override bool OnDeserializeUnrecognizedAttribute(string name, string value) {
_attributes.Add(name, value);
return true;
}
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace cmpctircd.Configuration
{
public class LoggerElement
{
public LoggerType Type { get; set; }
public LogType Level { get; set; }
public Dictionary<string, string> Attributes { get; set; } = new Dictionary<string, string>();
}
}
}
Loading