diff --git a/cmpctircd/Cloak.cs b/cmpctircd/Cloak.cs deleted file mode 100644 index 9397acf..0000000 --- a/cmpctircd/Cloak.cs +++ /dev/null @@ -1,242 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Net; -using System.Security.Cryptography; - -namespace cmpctircd -{ - public static class Cloak { - - /// - /// This function will return a suitable cloak for the user - /// depending on if they have a DNS host or IP. Will throw - /// an exception if it can't deduce the user's IP address family. - /// - /// The user's DNS host string - /// The user's IPAddress IP - /// The config cloak key - /// A cloak string - static public string GetCloak(String host, IPAddress ip, string key, bool full) { - bool hostIsIp = host == null ? true : false; - string cloak; - - if(!hostIsIp && !full) { - // DNS Host - cloak = CmpctCloakDNS(host, key); - } else { - switch(ip.AddressFamily) { - case System.Net.Sockets.AddressFamily.InterNetworkV6: - // IPv6 - cloak = InspCloakIPv6(ip, key, full); - break; - - case System.Net.Sockets.AddressFamily.InterNetwork: - // IPv4 - cloak = InspCloakIPv4(ip, key, full); - break; - - default: - throw new NotSupportedException($"Unknown IP address type: {ip.AddressFamily}!"); - } - } - - return cloak; - } - - /// - /// This returns the the last x domain parts of a host string (x set in config) - /// or a set amount if the domain parts are lower than x. - /// This is to retrieve a suffix for the cloak and ensure important parts are hidden. - /// - /// DNS host string to truncate - /// A truncated DNS host string - static public string GetTruncatedHost(string host) { - string truncHost; - List dotPositions = new List(); - var dotCount = host.Count(s => s == '.'); - var dotSplit = host.Split('.'); - - // Count dot positions - for(int i = 0; i < host.Length; i++) { - if(host[i] == '.') { - dotPositions.Add(i); - } - } - - switch(dotCount) { - case 0: - // No dots in the host string, return no suffix - truncHost = ""; - break; - - case 1: - //One dot in the host string, only return the last part. - truncHost = $".{dotSplit[1]}"; - break; - - case 2: - // Two dots - check that ClockDomainParts is low enough to not reveal - // the entire host string, or else return the last two parts. - if(IRCd.CloakDomainParts < 2) { - truncHost = host.Substring(dotPositions[dotCount - IRCd.CloakDomainParts]); - } else { - truncHost = host.Substring(dotPositions[dotCount - 2]); - } - break; - - default: - // Return the domain parts given in the config - truncHost = host.Substring(dotPositions[dotCount - IRCd.CloakDomainParts]); - break; - } - - return truncHost; - } - - /// - /// Returns a cloak string from a DNS host string - /// - /// DNS host string - /// Config cloak key - /// Cloak string - static public string CmpctCloakDNS(string host, string key) { - var prefix = IRCd.CloakPrefix; - var suffix = GetTruncatedHost(host); - var hash = InspCloakHost((char)1, key, host, 6); - - return $"{prefix}-{hash}{suffix}"; - } - - /// - /// This is a copy of InspIRCd's undocumented IPv4 cloaking code. - /// Due to how InspIRCd take the user's IP address as an integer - /// casted to an array of chars, this code needs to take the - /// address bytes and encode them to retrieve a comparable string. - /// The suffix consists of the first two bytes of the IP address - /// reversed, followed by ".IP". - /// - /// The cloak is formatted as "prefix-seg1.seg2.suffix" - /// - /// The user's IPv4 address (An IPAddress) - /// The cloaking key, set in the config - /// A fully formated cloak string - static public string InspCloakIPv4(IPAddress address, string key, bool full) { - var cloak = new StringBuilder(); - var utf8 = new UTF8Encoding(); - var addrBytes = address.GetAddressBytes(); - var string_ip = utf8.GetString(addrBytes); - var suffix = $".{addrBytes[1]}.{addrBytes[0]}.IP"; - - // The cloak string - // Prefix - cloak.Append($"{IRCd.CloakPrefix}-"); - // Segment 1 (Full IP hashed) - cloak.Append(InspCloakHost((char)10, key, string_ip, 3)); - cloak.Append("."); - // Remove the last byte - string_ip = string_ip.Substring(0, 3); - // Segment 2 (First 3 bytes of IP hashed) - cloak.Append(InspCloakHost((char)11, key, string_ip, 3)); - - // If full mode is selected, remove further bytes and cloak entire IP - if(full) { - cloak.Append("."); - string_ip = string_ip.Substring(0, 2); - cloak.Append(InspCloakHost((char)13, key, string_ip, 6)); - suffix = ".IP"; - } - - // Suffix - cloak.Append(suffix); - - return cloak.ToString(); - } - - - /// - /// This is a copy of InspIRCd's undocumented IPv6 cloaking code. - /// Due to how InspIRCd take the user's IP address as an integer - /// casted to an array of chars, this code needs to take the - /// address bytes and encode them to retrieve a comparable string. - /// The suffix consists of the first two bytes of the IP address - /// reversed, followed by ".IP". - /// - /// The cloak is formatted as "prefix-seg1.seg2.seg3.suffix" - /// - /// The user's IPv4 address (An IPAddress) - /// The cloaking key, set in the config - /// A fully formated cloak string - static public string InspCloakIPv6(IPAddress address, string key, bool full) { - var cloak = new StringBuilder(); - var utf8 = new UTF8Encoding(); - var addrBytes = address.GetAddressBytes(); - var addrParts = address.ToString().Split(':'); - var string_ip = utf8.GetString(addrBytes); - var suffix = $".{addrParts[1]}.{addrParts[0]}.IP"; - - // The cloak string - // Prefix - cloak.Append($"{IRCd.CloakPrefix}-"); - // Segment 1 (Full IP hashed) - cloak.Append(InspCloakHost((char)10, key, string_ip, 6)); - cloak.Append("."); - // Remove the last 6 chars - string_ip = string_ip.Substring(0, 8); - // Segment 2 (First 5 chars of IP hashed) - cloak.Append(InspCloakHost((char)11, key, string_ip, 4)); - // Remove further 2 chars - string_ip = string_ip.Substring(0, 6); - cloak.Append("."); - // Segment 3 (First 3 chars of IP hashed) - cloak.Append(InspCloakHost((char)12, key, string_ip, 4)); - - // If full mode is selected, remove further bytes and cloak entire IP - if(full) { - cloak.Append("."); - string_ip = string_ip.Substring(0, 4); - cloak.Append(InspCloakHost((char)13, key, string_ip, 6)); - suffix = ".IP"; - } - - // Suffix - cloak.Append(suffix); - - return cloak.ToString(); - } - - /// - /// This code is a copy of InspIRCd's undocumented host cloaking algorithm. - /// The hash is given an input which consists of: - /// a (char) ID, a key, a null character, and the full host. - /// - /// After hashing, it is cut down to the given length and each byte is cut down to fit base32 (0..31) - /// in order to cut off any overflow & invalid characters - /// - /// A unique ID for the host - /// A key set in the configuration - /// The host itself - /// The length for the output, max = 16 - /// Returns a hashed string - static public string InspCloakHost(char id, string key, string host, int length) { - string base32 = "0123456789abcdefghijklmnopqrstuv"; - string cloak_s = ""; - - using(MD5 hasher = MD5.Create()) { - string input = id + key + "\0" + host; - StringBuilder str = new StringBuilder(); - var cloak = hasher.ComputeHash(Encoding.UTF8.GetBytes(input)); - - for(int i = 0; i < length; i++) { - // In order to avoid character overflow, AND with 0x1F (31) will ensure each character is only ever <= 31 - str.Append(base32[cloak[i] & 0x1F]); - } - - cloak_s = str.ToString(); - } - - return cloak_s; - } - } -} \ No newline at end of file diff --git a/cmpctircd/Cloak/Cloak.cs b/cmpctircd/Cloak/Cloak.cs new file mode 100644 index 0000000..d889ce7 --- /dev/null +++ b/cmpctircd/Cloak/Cloak.cs @@ -0,0 +1,15 @@ +namespace cmpctircd.Cloak +{ + /// + /// abstract class. + /// + public abstract class Cloak + { + /// + /// Gets a cloak string. + /// + /// The client's cloaking parameters. + /// A cloak string. + public abstract string GetCloakString(CloakOptions cloakOptions); + } +} diff --git a/cmpctircd/Cloak/CloakOptions.cs b/cmpctircd/Cloak/CloakOptions.cs new file mode 100644 index 0000000..a81feb2 --- /dev/null +++ b/cmpctircd/Cloak/CloakOptions.cs @@ -0,0 +1,46 @@ +using System.Net; + +namespace cmpctircd.Cloak +{ + /// + /// A class containing cloaking parameters from the client. + /// Use this instead of excess method arguments. + /// + public class CloakOptions + { + /// + /// Initializes a new instance of the class. + /// + /// The client's DNS host. + /// The client's IP Address. + /// The server's cloak key. + /// Full cloaking config option. + public CloakOptions(string host, IPAddress ip, string key, bool full) + { + Host = host; + Ip = ip; + Key = key; + Full = full; + } + + /// + /// Gets client's DNS host. + /// + public string Host { get; private set; } + + /// + /// Gets client's IP Address. + /// + public IPAddress Ip { get; private set; } + + /// + /// Gets server's cloak key. + /// + public string Key { get; private set; } + + /// + /// Gets a value indicating whether full cloaking should occur. + /// + public bool Full { get; private set; } + } +} \ No newline at end of file diff --git a/cmpctircd/Cloak/Cloaking.cs b/cmpctircd/Cloak/Cloaking.cs new file mode 100644 index 0000000..85a564d --- /dev/null +++ b/cmpctircd/Cloak/Cloaking.cs @@ -0,0 +1,124 @@ +namespace cmpctircd.Cloak +{ + using System; + using System.Net; + using System.Net.Sockets; + using System.Security.Cryptography; + using System.Text; + using cmpctircd.Cloak.Service; + + /// + /// Generates cloak strings using factories. + /// + public static class Cloaking + { + /// + /// Generate a cloak compatible with InspIRCd. + /// + /// The client's cloaking parameters. + /// A cloak string. + public static string GenerateInspCloak(CloakOptions cloakOptions) + { + Cloak cloak = GetInspCloakFromService(cloakOptions); + return cloak.GetCloakString(cloakOptions); + } + + + /// + /// This code is a copy of InspIRCd's undocumented host cloaking algorithm. + /// The hash is given an input which consists of: + /// a (char) ID, a key, a null character, and the full host. + /// + /// After hashing, it is cut down to the given length and each byte is cut down to fit base32 (0..31) + /// in order to cut off any overflow & invalid characters + /// + /// A unique ID for the host + /// A key set in the configuration + /// The host itself + /// The length for the output, max = 16 + /// Returns a hashed string + public static string InspCloakHost(char id, string key, string host, int length) { + string base32 = "0123456789abcdefghijklmnopqrstuv"; + string cloakString = ""; + + using (MD5 hasher = MD5.Create()) { + string input = id + key + "\0" + host; + StringBuilder str = new StringBuilder(); + var cloak = hasher.ComputeHash(Encoding.UTF8.GetBytes(input)); + + for (int i = 0; i < length; i++) { + // In order to avoid character overflow, AND with 0x1F (31) will ensure each character is only ever <= 31 + str.Append(base32[cloak[i] & 0x1F]); + } + + cloakString = str.ToString(); + } + + return cloakString; + } + + /// + /// Generate a `Cloak` based on the client's IP version. + /// + /// The client's cloaking parameters. + /// A Cloak object. + private static Cloak GetInspCloakFromService(CloakOptions cloakOptions) + { + CloakService service = null; + string cloakVersion = GetCloakVersion(cloakOptions); + + switch (cloakVersion) + { + case "DNS": + service = new InspDnsService(); + break; + case "IPv4": + service = new InspIPv4Service(); + break; + case "IPv6": + service = new InspIPv6Service(); + break; + } + + return service.GetCloak(); + } + + /// + /// Get the client's cloak version - either DNS, IPv4 or IPv6. + /// + /// The client's cloaking parameters. + /// A cloak version string + private static string GetCloakVersion(CloakOptions cloakOptions) + { + bool hostIsIp = cloakOptions.Host == null; + string cloakVersion; + + if (!hostIsIp && !cloakOptions.Full) { + // DNS Host + cloakVersion = "DNS"; + } else { + cloakVersion = GetIpVersion(cloakOptions.Ip, cloakOptions.Key, cloakOptions.Full); + } + + return cloakVersion; + } + + /// + /// Get the client's IP version - IPv4 or IPv6. + /// + /// Client's IP Address. + /// The server cloaking key. + /// Full cloaking config option. + /// A IP version string + private static string GetIpVersion(IPAddress ip, string key, bool full) { + string cloak = ip.AddressFamily switch + { + AddressFamily.InterNetworkV6 => "IPv6", + AddressFamily.InterNetwork => "IPv4", + _ => throw new NotSupportedException($"Unknown IP address type: {ip.AddressFamily}!"), + }; + + return cloak; + } + } +} diff --git a/cmpctircd/Cloak/InspIRCd/InspDNSCloak.cs b/cmpctircd/Cloak/InspIRCd/InspDNSCloak.cs new file mode 100644 index 0000000..675f64e --- /dev/null +++ b/cmpctircd/Cloak/InspIRCd/InspDNSCloak.cs @@ -0,0 +1,99 @@ +namespace cmpctircd.Cloak +{ + using System.Collections.Generic; + using System.Linq; + + /// + /// DNS Cloak compatible with InspIRCd. + /// + public class InspDNSCloak : Cloak + { + /// + /// This returns the the last x domain parts of a host string (x set in config) + /// or a set amount if the domain parts are lower than x. + /// This is to retrieve a suffix for the cloak and ensure important parts are hidden. + /// + /// DNS host string to truncate + /// A truncated DNS host string + public static string GetTruncatedHost(string host) { + string truncHost; + var dotCount = CountDotsInHost(host); + var hostSplit = host.Split('.'); + List dotPositions = CountDotPositionsInHost(host); + + switch (dotCount) { + case 0: + // No dots in the host string, return no suffix + truncHost = ""; + break; + + case 1: + // One dot in the host string, only return the last part. + truncHost = $".{hostSplit[1]}"; + break; + + case 2: + // Two dots - check that ClockDomainParts is low enough to not reveal + // the entire host string, or else return the last two parts. + truncHost = IRCd.CloakDomainParts < 2 + ? host.Substring(dotPositions[dotCount - IRCd.CloakDomainParts]) + : host.Substring(dotPositions[dotCount - 2]); + + break; + + default: + // Return the domain parts given in the config + truncHost = host.Substring(dotPositions[dotCount - IRCd.CloakDomainParts]); + break; + } + + return truncHost; + } + + /// + /// Counts the positions of dots in a DNS host string. + /// + /// DNS host string. + /// A list of dot positions. + private static List CountDotPositionsInHost(string host) + { + List dotPositions = new List(); + int i; + // Count dot positions + for (i = 0; i < host.Length; i++) + { + if (host[i] == '.') + { + dotPositions.Add(i); + } + } + + return dotPositions; + } + + /// + /// Counts the amount of dots in a DNS host string. + /// + /// DNS host string. + /// The number of dots found. + private static int CountDotsInHost(string host) + { + var dotCount = host.Count(s => s == '.'); + return dotCount; + } + + /// + /// Gets a cloak string for DNS hosts compatible with InspIRCd. + /// + /// The client's cloaking parameters. + /// A cloak string. + public override string GetCloakString(CloakOptions cloakOptions) + { + var prefix = IRCd.CloakPrefix; + var suffix = GetTruncatedHost(cloakOptions.Host); + var hash = Cloaking.InspCloakHost((char)1, cloakOptions.Key, cloakOptions.Host, 6); + + return $"{prefix}-{hash}{suffix}"; + } + } +} diff --git a/cmpctircd/Cloak/InspIRCd/InspIPv4Cloak.cs b/cmpctircd/Cloak/InspIRCd/InspIPv4Cloak.cs new file mode 100644 index 0000000..2cbacf0 --- /dev/null +++ b/cmpctircd/Cloak/InspIRCd/InspIPv4Cloak.cs @@ -0,0 +1,72 @@ +namespace cmpctircd.Cloak +{ + using System.Text; + + /// + /// IPv4 Cloak compatible with InspIRCd. + /// + public class InspIPv4Cloak : Cloak + { + + /// + /// This is a copy of InspIRCd's undocumented IPv4 cloaking code. + /// Due to how InspIRCd take the user's IP address as an integer + /// casted to an array of chars, this code needs to take the + /// address bytes and encode them to retrieve a comparable string. + /// The suffix consists of the first two bytes of the IP address + /// reversed, followed by ".IP". + /// + /// The cloak is formatted as "prefix-seg1.seg2.suffix" + /// + /// The user's IPv4 address (An IPAddress) + /// The cloaking key, set in the config + /// A fully formatted cloak string + public override string GetCloakString(CloakOptions cloakOptions) + { + var cloak = new StringBuilder(); + var utf8 = new UTF8Encoding(); + var addrBytes = cloakOptions.Ip.GetAddressBytes(); + var stringIp = utf8.GetString(addrBytes); + var suffix = $".{addrBytes[1]}.{addrBytes[0]}.IP"; + + // Prefix + cloak.Append($"{IRCd.CloakPrefix}-"); + + CloakFirstSegment(cloakOptions, cloak, stringIp); + cloak.Append("."); + + CloakSecondSegment(cloakOptions, stringIp, cloak); + + // If full mode is selected, cloak entire IP + if (cloakOptions.Full) + { + CloakFullIp(cloakOptions, cloak, stringIp); + suffix = ".IP"; + } + + cloak.Append(suffix); + + return cloak.ToString(); + } + + private static void CloakFullIp(CloakOptions cloakOptions, StringBuilder cloak, string stringIp) + { + cloak.Append("."); + stringIp = stringIp.Substring(0, 2); + cloak.Append(Cloaking.InspCloakHost((char) 13, cloakOptions.Key, stringIp, 6)); + } + + private static void CloakSecondSegment(CloakOptions cloakOptions, string stringIp, StringBuilder cloak) + { + // Segment 2 (First 3 bytes of IP hashed) + stringIp = stringIp.Substring(0, 3); + cloak.Append(Cloaking.InspCloakHost((char) 11, cloakOptions.Key, stringIp, 3)); + } + + private static void CloakFirstSegment(CloakOptions cloakOptions, StringBuilder cloak, string stringIp) + { + // Segment 1 (Full IP hashed) + cloak.Append(Cloaking.InspCloakHost((char) 10, cloakOptions.Key, stringIp, 3)); + } + } +} diff --git a/cmpctircd/Cloak/InspIRCd/InspIPv6Cloak.cs b/cmpctircd/Cloak/InspIRCd/InspIPv6Cloak.cs new file mode 100644 index 0000000..23a9eb4 --- /dev/null +++ b/cmpctircd/Cloak/InspIRCd/InspIPv6Cloak.cs @@ -0,0 +1,90 @@ +using System.Net; +using System.Text; + +namespace cmpctircd.Cloak +{ + /// + /// IPv6 Cloak compatible with InspIRCd. + /// + public class InspIPv6Cloak : Cloak + { + + /// + /// This is a copy of InspIRCd's undocumented IPv6 cloaking code. + /// Due to how InspIRCd take the user's IP address as an integer + /// casted to an array of chars, this code needs to take the + /// address bytes and encode them to retrieve a comparable string. + /// The suffix consists of the first two bytes of the IP address + /// reversed, followed by ".IP". + /// + /// The cloak is formatted as "prefix-seg1.seg2.seg3.suffix" + /// + /// The user's IPv4 address (An IPAddress) + /// The cloaking key, set in the config + /// A fully formated cloak string + public override string GetCloakString(CloakOptions cloakOptions) + { + var cloak = new StringBuilder(); + var addrParts = cloakOptions.Ip.ToString().Split(':'); + var stringIp = EncodeIpAddressBytes(cloakOptions.Ip); + var suffix = $".{addrParts[1]}.{addrParts[0]}.IP"; + + + cloak.Append($"{IRCd.CloakPrefix}-"); + + CloakFirstSegment(cloakOptions, cloak, stringIp); + + CloakSecondSegment(cloakOptions, cloak, stringIp); + + cloak.Append("."); + CloakThirdSegment(cloakOptions, cloak, stringIp); + + // If full mode is selected, cloak entire IP + if (cloakOptions.Full) + { + CloakFullIp(cloakOptions, cloak, stringIp); + suffix = ".IP"; + } + + cloak.Append(suffix); + + return cloak.ToString(); + } + + private static string EncodeIpAddressBytes(IPAddress ip) + { + var utf8 = new UTF8Encoding(); + var addressBytes = ip.GetAddressBytes(); + + return utf8.GetString(addressBytes); + } + + private static void CloakFullIp(CloakOptions cloakOptions, StringBuilder cloak, string string_ip) + { + cloak.Append("."); + string_ip = string_ip.Substring(0, 4); + cloak.Append(Cloaking.InspCloakHost((char) 13, cloakOptions.Key, string_ip, 6)); + } + + private static void CloakThirdSegment(CloakOptions cloakOptions, StringBuilder cloak, string string_ip) + { + // Segment 3 (First 3 chars of IP hashed) + string_ip = string_ip.Substring(0, 6); + cloak.Append(Cloaking.InspCloakHost((char) 12, cloakOptions.Key, string_ip, 4)); + } + + private static void CloakSecondSegment(CloakOptions cloakOptions, StringBuilder cloak, string string_ip) + { + // Segment 2 (First 5 chars of IP hashed) + string_ip = string_ip.Substring(0, 8); + cloak.Append(Cloaking.InspCloakHost((char) 11, cloakOptions.Key, string_ip, 4)); + } + + private static void CloakFirstSegment(CloakOptions cloakOptions, StringBuilder cloak, string string_ip) + { + // Segment 1 (Full IP hashed) + cloak.Append(Cloaking.InspCloakHost((char) 10, cloakOptions.Key, string_ip, 6)); + cloak.Append("."); + } + } +} diff --git a/cmpctircd/Cloak/Service/CloakService.cs b/cmpctircd/Cloak/Service/CloakService.cs new file mode 100644 index 0000000..3c2d766 --- /dev/null +++ b/cmpctircd/Cloak/Service/CloakService.cs @@ -0,0 +1,14 @@ +namespace cmpctircd.Cloak +{ + /// + /// CloakService abstract class. + /// + public abstract class CloakService + { + /// + /// Gets a Cloak. + /// + /// A Cloak. + public abstract Cloak GetCloak(); + } +} \ No newline at end of file diff --git a/cmpctircd/Cloak/Service/InspIRCd/InspDNSService.cs b/cmpctircd/Cloak/Service/InspIRCd/InspDNSService.cs new file mode 100644 index 0000000..7e903df --- /dev/null +++ b/cmpctircd/Cloak/Service/InspIRCd/InspDNSService.cs @@ -0,0 +1,17 @@ +namespace cmpctircd.Cloak.Service +{ + /// + /// A service to return DNS Cloaks compatible with InspIRCd. + /// + public class InspDnsService : CloakService + { + /// + /// Gets an InspDNSCloak. + /// + /// InspDNSCloak. + public override Cloak GetCloak() + { + return new InspDNSCloak(); + } + } +} diff --git a/cmpctircd/Cloak/Service/InspIRCd/InspIPv4Service.cs b/cmpctircd/Cloak/Service/InspIRCd/InspIPv4Service.cs new file mode 100644 index 0000000..65fbc83 --- /dev/null +++ b/cmpctircd/Cloak/Service/InspIRCd/InspIPv4Service.cs @@ -0,0 +1,16 @@ +namespace cmpctircd.Cloak.Service +{ + /// + /// A service to return IPv4 Cloaks compatible with InspIRCd. + /// + public class InspIPv4Service : CloakService + { + /// + /// Gets an InspIPv4Cloak. + /// + /// InspIPv4Cloak. + public override Cloak GetCloak() { + return new InspIPv4Cloak(); + } + } +} diff --git a/cmpctircd/Cloak/Service/InspIRCd/InspIPv6Service.cs b/cmpctircd/Cloak/Service/InspIRCd/InspIPv6Service.cs new file mode 100644 index 0000000..06fb758 --- /dev/null +++ b/cmpctircd/Cloak/Service/InspIRCd/InspIPv6Service.cs @@ -0,0 +1,17 @@ +namespace cmpctircd.Cloak.Service +{ + /// + /// A service to return IPv6 Cloaks compatible with InspIRCd. + /// + public class InspIPv6Service : CloakService + { + /// + /// Gets an InspIPv6Cloak. + /// + /// InspIPv6Cloak. + public override Cloak GetCloak() + { + return new InspIPv6Cloak(); + } + } +} diff --git a/cmpctircd/Modes/User/Cloak.cs b/cmpctircd/Modes/User/Cloak.cs index 3228390..02abbcd 100644 --- a/cmpctircd/Modes/User/Cloak.cs +++ b/cmpctircd/Modes/User/Cloak.cs @@ -1,3 +1,5 @@ +using cmpctircd.Cloak; + namespace cmpctircd.Modes { public class CloakMode : UserMode { @@ -16,7 +18,7 @@ override public bool Grant(string args, bool forceSet = false, bool announce = f if (Enabled) return false; - Subject.Cloak = Cloak.GetCloak(Subject.DNSHost, Subject.IP, Subject.IRCd.CloakKey, Subject.IRCd.CloakFull); + Subject.Cloak = Cloaking.GenerateInspCloak(new CloakOptions(Subject.DNSHost, Subject.IP, Subject.IRCd.CloakKey, Subject.IRCd.CloakFull)); Enabled = true; Subject.Write($":{Subject.IRCd.Host} {IrcNumeric.RPL_HOSTHIDDEN.Printable()} {Subject.Nick} {Subject.Cloak} :is now your displayed host"); diff --git a/cmpctircd/Server/LinkProtocols/InspIRCd20.cs b/cmpctircd/Server/LinkProtocols/InspIRCd20.cs index 91107ca..f943f53 100644 --- a/cmpctircd/Server/LinkProtocols/InspIRCd20.cs +++ b/cmpctircd/Server/LinkProtocols/InspIRCd20.cs @@ -1,6 +1,7 @@ using System; using System.Text; using System.Linq; +using cmpctircd.Cloak; namespace cmpctircd { @@ -43,7 +44,7 @@ public void SendCapab() { // https://www.anope.org/doxy/2.0/d6/dd0/inspircd20_8cpp_source.html // TODO: Make sure we actually do m_services_account, m_hidechans // TODO: Readd m_services_account.so below! - Server.Write($"CAPAB MODULES :m_cloaking.so={IRCd.CloakPrefix}-{Cloak.InspCloakHost((char) 3, Server.IRCd.CloakKey, "*", 8)}.IP"); + Server.Write($"CAPAB MODULES :m_cloaking.so={IRCd.CloakPrefix}-{Cloaking.InspCloakHost((char) 3, Server.IRCd.CloakKey, "*", 8)}.IP"); Server.Write($"CAPAB MODSUPPORT m_services_account.so"); // TODO: this is a requirement for services, not insp (obviously) Server.Write($"CAPAB USERMODES hidechans");