├── .gitignore ├── .travis.yml ├── IrcD.Net.sln ├── IrcD.Net ├── Channel │ ├── ChannelInfo.cs │ ├── ChannelType.cs │ ├── NormalChannel.cs │ └── UserPerChannelInfo.cs ├── Commands │ ├── Admin.cs │ ├── Arguments │ │ ├── AwayArgument.cs │ │ ├── CommandArgument.cs │ │ ├── InviteArgument.cs │ │ ├── JoinArgument.cs │ │ ├── KickArgument.cs │ │ ├── KillArgument.cs │ │ ├── KnockArgument.cs │ │ ├── ModeArgument.cs │ │ ├── NickArgument.cs │ │ ├── NoticeArgument.cs │ │ ├── PartArgument.cs │ │ ├── PingArgument.cs │ │ ├── PongArgument.cs │ │ ├── PrivateMessageArgument.cs │ │ ├── QuitArgument.cs │ │ └── TopicArgument.cs │ ├── Away.cs │ ├── Capabilities.cs │ ├── CommandBase.cs │ ├── CommandList.cs │ ├── Connect.cs │ ├── Die.cs │ ├── Error.cs │ ├── Info.cs │ ├── Invite.cs │ ├── IsOn.cs │ ├── Join.cs │ ├── Kick.cs │ ├── Kill.cs │ ├── Knock.cs │ ├── Language.cs │ ├── Links.cs │ ├── List.cs │ ├── ListUsers.cs │ ├── MessageOfTheDay.cs │ ├── Mode.cs │ ├── Names.cs │ ├── Nick.cs │ ├── Notice.cs │ ├── Oper.cs │ ├── Part.cs │ ├── Pass.cs │ ├── Ping.cs │ ├── Pong.cs │ ├── PrivateMessage.cs │ ├── Quit.cs │ ├── Rehash.cs │ ├── Restart.cs │ ├── Server.cs │ ├── ServerQuit.cs │ ├── Service.cs │ ├── ServiceList.cs │ ├── ServiceQuery.cs │ ├── Silence.cs │ ├── Stats.cs │ ├── Summon.cs │ ├── Time.cs │ ├── Topic.cs │ ├── Trace.cs │ ├── User.cs │ ├── UserHost.cs │ ├── Version.cs │ ├── Wallops.cs │ ├── Who.cs │ ├── WhoIs.cs │ └── WhoWas.cs ├── Core │ ├── InfoBase.cs │ ├── IrcDaemon.cs │ ├── ServerInfo.cs │ ├── ServerOptions.cs │ ├── ServerStats.cs │ ├── UserInfo.cs │ └── Utils │ │ ├── AlreadyCalledException.cs │ │ ├── CheckParamCountAttribute.cs │ │ ├── CheckRegisteredAttribute.cs │ │ ├── IrcCaseMapping.cs │ │ ├── IrcMode.cs │ │ ├── OperHost.cs │ │ ├── P10Numerics.cs │ │ └── RehashEventArgs.cs ├── IrcD.Net.csproj ├── Modes │ ├── ChannelMode.cs │ ├── ChannelModeList.cs │ ├── ChannelModes │ │ ├── IParameter.cs │ │ ├── ModeBan.cs │ │ ├── ModeBanException.cs │ │ ├── ModeColorless.cs │ │ ├── ModeInvite.cs │ │ ├── ModeInviteException.cs │ │ ├── ModeKey.cs │ │ ├── ModeLimit.cs │ │ ├── ModeModerated.cs │ │ ├── ModeNoExternal.cs │ │ ├── ModePrivate.cs │ │ ├── ModeSecret.cs │ │ ├── ModeTopic.cs │ │ └── ModeTranslate.cs │ ├── ChannelRank.cs │ ├── ChannelRanks │ │ ├── ModeAdmin.cs │ │ ├── ModeHalfOp.cs │ │ ├── ModeNoRank.cs │ │ ├── ModeOp.cs │ │ ├── ModeOwner.cs │ │ └── ModeVoice.cs │ ├── Mode.cs │ ├── ModeFactory.cs │ ├── ModeList.cs │ ├── RankList.cs │ ├── UserMode.cs │ ├── UserModeList.cs │ └── UserModes │ │ ├── ModeAway.cs │ │ ├── ModeInvisible.cs │ │ ├── ModeLocalOperator.cs │ │ ├── ModeOperator.cs │ │ ├── ModeRestricted.cs │ │ └── ModeWallops.cs ├── ServerReplies │ ├── ReplyCode.cs │ └── ServerReplies.cs ├── Tools │ ├── DateTimeUtils.cs │ ├── EnumDescription.cs │ ├── EnumExtension.cs │ ├── Enumerable.cs │ ├── EnumerableIndex.cs │ ├── IrcConstants.cs │ ├── Languages.cs │ ├── Logger.cs │ ├── WildCard.cs │ └── WildcardMatch.cs ├── app.config └── docs │ ├── CAP - Client capabilities negotiation.txt │ ├── CTCP-Update.txt │ ├── CTCP.txt │ ├── Channel Types.txt │ ├── DCC.txt │ ├── ISUPPORT - overview.txt │ ├── ISUPPORT.txt │ ├── LANGUAGE_Command.txt │ ├── P10 - Server Protocol.txt │ ├── RFC1459 - IRC.txt │ ├── RFC2810 - IRC - Architecture.txt │ ├── RFC2811 - IRC - Channel Management.txt │ ├── RFC2812 - IRC - Client Protocol.txt │ └── RFC2813 - IRC - Server Protocol.txt ├── IrcD.Server ├── Engine.cs ├── IrcD.Server.csproj ├── Settings.cs └── config.xml ├── IrcD.Test ├── Enumerable.cs ├── IrcD.Test.csproj └── P10Numerics.cs ├── LICENSE └── Readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific files 2 | *.suo 3 | *.user 4 | *.sln.docstates 5 | /.vs 6 | 7 | # Build results 8 | 9 | [Dd]ebug/ 10 | [Rr]elease/ 11 | x64/ 12 | build/ 13 | [Bb]in/ 14 | [Oo]bj/ 15 | 16 | # NuGet Packages 17 | *.nupkg 18 | # The packages folder can be ignored because of Package Restore 19 | **/packages/* 20 | # except build/, which is used as an MSBuild target. 21 | !**/packages/build/ 22 | # Uncomment if necessary however generally it will be regenerated when needed 23 | #!**/packages/repositories.config 24 | 25 | 26 | # OS generated files # 27 | .DS_Store* 28 | ehthumbs.db 29 | Icon? 30 | Thumbs.db 31 | 32 | # ReSharper is a .NET coding add-in 33 | _ReSharper*/ 34 | *.[Rr]e[Ss]harper 35 | 36 | # TeamCity is a build add-in 37 | _TeamCity* 38 | 39 | # DotCover is a Code Coverage Tool 40 | *.dotCover -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: csharp 2 | solution: IrcD.Net.sln 3 | mono: none 4 | dotnet: 2.1.502 5 | script: 6 | - dotnet restore 7 | - dotnet build 8 | -------------------------------------------------------------------------------- /IrcD.Net.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IrcD.Net", "IrcD.Net\IrcD.Net.csproj", "{5CC4A3FD-04E7-4F6A-B6C1-74AB924030A1}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IrcD.Test", "IrcD.Test\IrcD.Test.csproj", "{FE5C36F8-0549-494E-9D1B-32C3623B6225}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IrcD.Server", "IrcD.Server\IrcD.Server.csproj", "{B5BFAA25-4ACC-41F0-8438-98368C6778D6}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {5CC4A3FD-04E7-4F6A-B6C1-74AB924030A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {5CC4A3FD-04E7-4F6A-B6C1-74AB924030A1}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {5CC4A3FD-04E7-4F6A-B6C1-74AB924030A1}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {5CC4A3FD-04E7-4F6A-B6C1-74AB924030A1}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {FE5C36F8-0549-494E-9D1B-32C3623B6225}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {FE5C36F8-0549-494E-9D1B-32C3623B6225}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {FE5C36F8-0549-494E-9D1B-32C3623B6225}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {FE5C36F8-0549-494E-9D1B-32C3623B6225}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {B5BFAA25-4ACC-41F0-8438-98368C6778D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {B5BFAA25-4ACC-41F0-8438-98368C6778D6}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {B5BFAA25-4ACC-41F0-8438-98368C6778D6}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {B5BFAA25-4ACC-41F0-8438-98368C6778D6}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {8FAC6718-2CE3-4F22-BF99-008239729E55} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /IrcD.Net/Channel/ChannelType.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | namespace IrcD.Channel 23 | { 24 | public class ChannelType 25 | { 26 | public ChannelType(char prefix, int maxJoinedAllowed) 27 | { 28 | Prefix = prefix; 29 | MaxJoinedAllowed = maxJoinedAllowed; 30 | } 31 | 32 | public char Prefix { get; } 33 | public int MaxJoinedAllowed { get; set; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /IrcD.Net/Channel/NormalChannel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | namespace IrcD.Channel 23 | { 24 | class NormalChannel : ChannelType 25 | { 26 | public NormalChannel() 27 | : base('#', 10) 28 | { 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /IrcD.Net/Channel/UserPerChannelInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Text; 23 | using IrcD.Core; 24 | using IrcD.Modes; 25 | 26 | namespace IrcD.Channel 27 | { 28 | public class UserPerChannelInfo : InfoBase 29 | { 30 | public UserInfo UserInfo { get; } 31 | public ChannelInfo ChannelInfo { get; } 32 | public RankList Modes { get; } 33 | 34 | public UserPerChannelInfo(UserInfo userInfo, ChannelInfo channelInfo) 35 | : base(userInfo.IrcDaemon) 36 | { 37 | UserInfo = userInfo; 38 | ChannelInfo = channelInfo; 39 | Modes = new RankList(userInfo.IrcDaemon); 40 | } 41 | 42 | 43 | 44 | /// 45 | /// This method just delegates the work to 46 | /// 47 | /// 48 | public override int WriteLine(StringBuilder line) => UserInfo.WriteLine(line); 49 | 50 | public override int WriteLine(StringBuilder line, UserInfo exception) 51 | { 52 | if (UserInfo != exception) 53 | { 54 | return UserInfo.WriteLine(line); 55 | } 56 | 57 | return 0; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Admin.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | 28 | namespace IrcD.Commands 29 | { 30 | public class Admin : CommandBase 31 | { 32 | public Admin(IrcDaemon ircDaemon) 33 | : base(ircDaemon, "ADMIN", "AD") 34 | { } 35 | 36 | [CheckRegistered] 37 | protected override void PrivateHandle(UserInfo info, List args) 38 | { 39 | //ToDo: parse target parameter 40 | 41 | IrcDaemon.Replies.SendAdminMe(info); 42 | IrcDaemon.Replies.SendAdminLocation1(info); 43 | IrcDaemon.Replies.SendAdminLocation2(info); 44 | IrcDaemon.Replies.SendAdminEmail(info); 45 | } 46 | 47 | protected override int PrivateSend(CommandArgument commandArgument) 48 | { 49 | throw new NotImplementedException(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Arguments/AwayArgument.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using IrcD.Core; 23 | 24 | namespace IrcD.Commands.Arguments 25 | { 26 | public class AwayArgument : CommandArgument 27 | { 28 | public AwayArgument(UserInfo sender, InfoBase receiver, string awayMessage) 29 | : base(sender, receiver, "AWAY") 30 | { 31 | AwayMessage = awayMessage; 32 | } 33 | 34 | public string AwayMessage { get; } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Arguments/CommandArgument.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using IrcD.Core; 23 | 24 | namespace IrcD.Commands.Arguments 25 | { 26 | public class CommandArgument 27 | { 28 | public CommandArgument(UserInfo sender, InfoBase receiver, string name) 29 | { 30 | Name = name; 31 | Sender = sender; 32 | Receiver = receiver; 33 | } 34 | 35 | public string Name { get; } 36 | public UserInfo Sender { get; } 37 | public InfoBase Receiver { get; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Arguments/InviteArgument.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using IrcD.Channel; 23 | using IrcD.Core; 24 | 25 | namespace IrcD.Commands.Arguments 26 | { 27 | public class InviteArgument : CommandArgument 28 | { 29 | public InviteArgument(UserInfo sender, InfoBase receiver, UserInfo invited, ChannelInfo channel) 30 | : base(sender, receiver, "INVITE") 31 | { 32 | Invited = invited; 33 | Channel = channel; 34 | } 35 | 36 | public ChannelInfo Channel { get; } 37 | public UserInfo Invited { get; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Arguments/JoinArgument.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using IrcD.Channel; 23 | using IrcD.Core; 24 | 25 | namespace IrcD.Commands.Arguments 26 | { 27 | public class JoinArgument : CommandArgument 28 | { 29 | public JoinArgument(UserInfo sender, InfoBase receiver, ChannelInfo channel) 30 | : base(sender, receiver, "JOIN") 31 | { 32 | Channel = channel; 33 | } 34 | 35 | public ChannelInfo Channel { get; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Arguments/KickArgument.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using IrcD.Channel; 23 | using IrcD.Core; 24 | 25 | namespace IrcD.Commands.Arguments 26 | { 27 | public class KickArgument : CommandArgument 28 | { 29 | public KickArgument(UserInfo sender, InfoBase receiver, ChannelInfo channel, UserInfo user, string message) 30 | : base(sender, receiver, "KICK") 31 | { 32 | 33 | Channel = channel; 34 | User = user; 35 | Message = message; 36 | } 37 | 38 | public ChannelInfo Channel { get; } 39 | public UserInfo User { get; } 40 | public string Message { get; } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Arguments/KillArgument.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using IrcD.Core; 23 | 24 | namespace IrcD.Commands.Arguments 25 | { 26 | public class KillArgument : CommandArgument 27 | { 28 | public KillArgument(UserInfo sender, UserInfo receiver, string message) 29 | : base(sender, receiver, "KILL") 30 | { 31 | Message = message; 32 | } 33 | 34 | public string Message { get; } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Arguments/KnockArgument.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using IrcD.Channel; 23 | using IrcD.Core; 24 | 25 | namespace IrcD.Commands.Arguments 26 | { 27 | public class KnockArgument : CommandArgument 28 | { 29 | public KnockArgument(UserInfo sender, InfoBase receiver, ChannelInfo channel, string message) 30 | : base(sender, receiver, "KNOCK") 31 | { 32 | Channel = channel; 33 | Message = message; 34 | } 35 | 36 | public ChannelInfo Channel { get; } 37 | public string Message { get; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Arguments/ModeArgument.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using IrcD.Core; 23 | 24 | namespace IrcD.Commands.Arguments 25 | { 26 | public class ModeArgument : CommandArgument 27 | { 28 | public ModeArgument(UserInfo sender, InfoBase receiver, string target, string modeString) 29 | : base(sender, receiver, "MODE") 30 | { 31 | 32 | Target = target; 33 | ModeString = modeString; 34 | } 35 | 36 | public string Target { get; } 37 | 38 | public string ModeString { get; } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Arguments/NickArgument.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using IrcD.Core; 23 | 24 | namespace IrcD.Commands.Arguments 25 | { 26 | public class NickArgument : CommandArgument 27 | { 28 | public NickArgument(UserInfo sender, InfoBase receiver, string newNick) 29 | : base(sender, receiver, "NICK") 30 | { 31 | 32 | NewNick = newNick; 33 | } 34 | 35 | public string NewNick { get; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Arguments/NoticeArgument.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using IrcD.Core; 23 | 24 | namespace IrcD.Commands.Arguments 25 | { 26 | public class NoticeArgument : CommandArgument 27 | { 28 | public NoticeArgument(UserInfo sender, InfoBase receiver, string target, string message) 29 | : base(sender, receiver, "NOTICE") 30 | { 31 | Target = target; 32 | Message = message; 33 | } 34 | 35 | public NoticeArgument(InfoBase receiver, string target, string message) 36 | : base(null, receiver, "NOTICE") 37 | { 38 | Target = target; 39 | Message = message; 40 | } 41 | 42 | public string Target { get; } 43 | public string Message { get; } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Arguments/PartArgument.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using IrcD.Channel; 23 | using IrcD.Core; 24 | 25 | namespace IrcD.Commands.Arguments 26 | { 27 | public class PartArgument : CommandArgument 28 | { 29 | public PartArgument(UserInfo sender, InfoBase receiver, ChannelInfo channel, string message) 30 | : base(sender, receiver, "PART") 31 | { 32 | Channel = channel; 33 | Message = message; 34 | } 35 | 36 | public ChannelInfo Channel { get; } 37 | public string Message { get; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Arguments/PingArgument.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using IrcD.Core; 23 | 24 | namespace IrcD.Commands.Arguments 25 | { 26 | public class PingArgument : CommandArgument 27 | { 28 | public PingArgument(InfoBase receiver) 29 | : base(null, receiver, "PING") 30 | { 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Arguments/PongArgument.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using IrcD.Core; 23 | 24 | namespace IrcD.Commands.Arguments 25 | { 26 | public class PongArgument : CommandArgument 27 | { 28 | public PongArgument(InfoBase receiver, string parameter) 29 | : base(null, receiver, "PONG") 30 | { 31 | Parameter = parameter; 32 | } 33 | 34 | public string Parameter { get; } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Arguments/PrivateMessageArgument.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using IrcD.Core; 23 | 24 | namespace IrcD.Commands.Arguments 25 | { 26 | public class PrivateMessageArgument : CommandArgument 27 | { 28 | public PrivateMessageArgument(UserInfo sender, InfoBase receiver, string target, string message) 29 | : base(sender, receiver, "PRIVMSG") 30 | { 31 | Target = target; 32 | Message = message; 33 | } 34 | 35 | public string Target { get; } 36 | public string Message { get; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Arguments/QuitArgument.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using IrcD.Core; 23 | 24 | namespace IrcD.Commands.Arguments 25 | { 26 | public class QuitArgument : CommandArgument 27 | { 28 | public QuitArgument(UserInfo sender, InfoBase receiver, string message) 29 | : base(sender, receiver, "QUIT") 30 | { 31 | Message = message; 32 | } 33 | 34 | public string Message { get; } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Arguments/TopicArgument.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using IrcD.Channel; 23 | using IrcD.Core; 24 | 25 | namespace IrcD.Commands.Arguments 26 | { 27 | public class TopicArgument : CommandArgument 28 | { 29 | public TopicArgument(UserInfo sender, InfoBase receiver, ChannelInfo channel, string newTopic) 30 | : base(sender, receiver, "TOPIC") 31 | { 32 | Channel = channel; 33 | NewTopic = newTopic; 34 | } 35 | 36 | public ChannelInfo Channel { get; } 37 | 38 | public string NewTopic { get; } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Away.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Modes.UserModes; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | 28 | namespace IrcD.Commands 29 | { 30 | public class Away : CommandBase 31 | { 32 | public Away(IrcDaemon ircDaemon) 33 | : base(ircDaemon, "AWAY", "A") 34 | { 35 | if (!ircDaemon.Capabilities.Contains("away-notify")) 36 | { 37 | ircDaemon.Capabilities.Add("away-notify"); 38 | } 39 | } 40 | 41 | [CheckRegistered] 42 | protected override void PrivateHandle(UserInfo info, List args) 43 | { 44 | if (args.Count == 0) 45 | { 46 | info.AwayMessage = null; 47 | info.Modes.RemoveMode(); 48 | IrcDaemon.Replies.SendUnAway(info); 49 | } 50 | else 51 | { 52 | info.AwayMessage = args[0]; 53 | info.Modes.Add(new ModeAway()); 54 | IrcDaemon.Replies.SendNowAway(info); 55 | } 56 | 57 | foreach (var channel in info.Channels) 58 | { 59 | foreach (var user in channel.Users) 60 | { 61 | if (user.Capabilities.Contains("away-notify")) 62 | { 63 | 64 | Send(new AwayArgument(info, user, (args.Count == 0) ? null : args[0])); 65 | } 66 | } 67 | } 68 | } 69 | 70 | protected override int PrivateSend(CommandArgument commandArgument) 71 | { 72 | var arg = GetSaveArgument(commandArgument); 73 | 74 | BuildMessageHeader(arg); 75 | 76 | if (arg.AwayMessage != null) 77 | { 78 | Command.Append(arg.AwayMessage); 79 | } 80 | 81 | return arg.Receiver.WriteLine(Command); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Capabilities.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | 28 | namespace IrcD.Commands 29 | { 30 | public class Capabilities : CommandBase 31 | { 32 | public Capabilities(IrcDaemon ircDaemon) 33 | : base(ircDaemon, "CAP", "") 34 | { } 35 | 36 | [CheckParamCount(1)] 37 | protected override void PrivateHandle(UserInfo info, List args) 38 | { 39 | var subcommand = args[0]; 40 | 41 | switch (subcommand) 42 | { 43 | case "LS": 44 | break; 45 | case "LIST": 46 | break; 47 | case "REQ": 48 | break; 49 | case "ACK": 50 | break; 51 | case "NAK": 52 | break; 53 | case "CLEAR": 54 | break; 55 | case "END": 56 | break; 57 | default: 58 | IrcDaemon.Replies.SendInvalidCapabilitiesCommand(info, subcommand); 59 | break; 60 | } 61 | } 62 | 63 | protected override int PrivateSend(CommandArgument commandArgument) 64 | { 65 | throw new NotImplementedException(); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Connect.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | using IrcD.Modes.UserModes; 28 | 29 | namespace IrcD.Commands 30 | { 31 | public class Connect : CommandBase 32 | { 33 | public Connect(IrcDaemon ircDaemon) 34 | : base(ircDaemon, "CONNECT", "CO") 35 | { } 36 | 37 | [CheckRegistered] 38 | [CheckParamCount(1)] 39 | protected override void PrivateHandle(UserInfo info, List args) 40 | { 41 | if (!info.Modes.Exist() && !info.Modes.Exist()) 42 | { 43 | IrcDaemon.Replies.SendNoPrivileges(info); 44 | return; 45 | } 46 | 47 | if (int.TryParse(args[1], out int port)) 48 | { 49 | IrcDaemon.Connect(args[0], port); 50 | } 51 | 52 | 53 | IrcDaemon.Replies.SendNoSuchServer(info, "Connect failed"); 54 | } 55 | 56 | protected override int PrivateSend(CommandArgument commandArgument) 57 | { 58 | throw new NotImplementedException(); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Die.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | using IrcD.Modes.UserModes; 28 | 29 | namespace IrcD.Commands 30 | { 31 | public class Die : CommandBase 32 | { 33 | public Die(IrcDaemon ircDaemon) 34 | : base(ircDaemon, "DIE", "DIE") 35 | { } 36 | 37 | [CheckRegistered] 38 | protected override void PrivateHandle(UserInfo info, List args) 39 | { 40 | if (!info.Modes.Exist() && !info.Modes.Exist()) 41 | { 42 | IrcDaemon.Replies.SendNoPrivileges(info); 43 | return; 44 | } 45 | 46 | IrcDaemon.Stop(false); 47 | } 48 | 49 | protected override int PrivateSend(CommandArgument commandArgument) 50 | { 51 | throw new NotImplementedException(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Error.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | 27 | namespace IrcD.Commands 28 | { 29 | public class Error : CommandBase 30 | { 31 | public Error(IrcDaemon ircDaemon) 32 | : base(ircDaemon, "ERROR", "Y") 33 | { } 34 | 35 | protected override void PrivateHandle(UserInfo info, List args) 36 | { 37 | 38 | } 39 | 40 | protected override int PrivateSend(CommandArgument commandArgument) 41 | { 42 | throw new NotImplementedException(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Info.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | 27 | namespace IrcD.Commands 28 | { 29 | public class Info : CommandBase 30 | { 31 | public Info(IrcDaemon ircDaemon) 32 | : base(ircDaemon, "INFO", "F") 33 | { } 34 | 35 | protected override void PrivateHandle(UserInfo info, List args) 36 | { 37 | //ToDo: parse target parameter 38 | 39 | IrcDaemon.Replies.SendInfo(info); 40 | IrcDaemon.Replies.SendEndOfInfo(info); 41 | } 42 | 43 | protected override int PrivateSend(CommandArgument commandArgument) 44 | { 45 | throw new NotImplementedException(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/IsOn.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using System.Linq; 25 | using IrcD.Commands.Arguments; 26 | using IrcD.Core; 27 | using IrcD.Core.Utils; 28 | 29 | namespace IrcD.Commands 30 | { 31 | public class IsOn : CommandBase 32 | { 33 | public IsOn(IrcDaemon ircDaemon) 34 | : base(ircDaemon, "ISON", "ISON") 35 | { } 36 | 37 | [CheckRegistered] 38 | [CheckParamCount(1)] 39 | protected override void PrivateHandle(UserInfo info, List args) 40 | { 41 | IrcDaemon.Replies.SendIsOn(info, args.Where(nick => IrcDaemon.Nicks.ContainsKey(nick))); 42 | } 43 | 44 | protected override int PrivateSend(CommandArgument commandArgument) 45 | { 46 | throw new NotImplementedException(); 47 | } 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Kill.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Commands.Arguments; 24 | using IrcD.Core; 25 | using IrcD.Core.Utils; 26 | using IrcD.Modes.UserModes; 27 | 28 | namespace IrcD.Commands 29 | { 30 | public class Kill : CommandBase 31 | { 32 | public Kill(IrcDaemon ircDaemon) 33 | : base(ircDaemon, "KILL", "D") 34 | { } 35 | 36 | [CheckRegistered] 37 | [CheckParamCount(1)] 38 | protected override void PrivateHandle(UserInfo info, List args) 39 | { 40 | if (!info.Modes.Exist() && !info.Modes.Exist()) 41 | { 42 | IrcDaemon.Replies.SendNoPrivileges(info); 43 | return; 44 | } 45 | 46 | if (!IrcDaemon.Nicks.TryGetValue(args[0], out UserInfo killUser)) 47 | { 48 | IrcDaemon.Replies.SendNoSuchNick(info, args[0]); 49 | } 50 | 51 | var message = args.Count > 1 ? args[1] : IrcDaemon.Options.StandardKillMessage; 52 | 53 | Send(new KillArgument(info, killUser, message)); 54 | killUser?.Remove(IrcDaemon.Options.StandardKillMessage); 55 | } 56 | 57 | protected override int PrivateSend(CommandArgument commandArgument) 58 | { 59 | var arg = GetSaveArgument(commandArgument); 60 | 61 | BuildMessageHeader(arg); 62 | Command.Append((arg.Receiver is UserInfo user) ? user.Nick : "nobody"); 63 | Command.Append(" :"); 64 | Command.Append(arg.Message); 65 | 66 | return arg.Receiver.WriteLine(Command); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Knock.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using IrcD.Channel; 25 | using IrcD.Commands.Arguments; 26 | using IrcD.Core; 27 | using IrcD.Core.Utils; 28 | 29 | namespace IrcD.Commands 30 | { 31 | public class Knock : CommandBase 32 | { 33 | public Knock(IrcDaemon ircDaemon) 34 | : base(ircDaemon, "KNOCK", "") 35 | { } 36 | 37 | [CheckRegistered] 38 | [CheckParamCount(1)] 39 | protected override void PrivateHandle(UserInfo info, List args) 40 | { 41 | 42 | if (IrcDaemon.Channels.TryGetValue(args[0], out ChannelInfo chan)) 43 | { 44 | if (!chan.Modes.HandleEvent(this, chan, info, args)) 45 | { 46 | return; 47 | } 48 | 49 | Send(new NoticeArgument(chan, chan.Name, "[KNOCK] by " + info.Usermask + "(" + ((args.Count > 1) ? args[1] : "no reason specified") + ")")); 50 | Send(new NoticeArgument(info, info.Nick, "Knocked on " + chan.Name)); 51 | } 52 | else 53 | { 54 | IrcDaemon.Replies.SendNoSuchChannel(info, args[0]); 55 | } 56 | 57 | } 58 | 59 | protected override int PrivateSend(CommandArgument commandArgument) 60 | { 61 | var arg = GetSaveArgument(commandArgument); 62 | 63 | BuildMessageHeader(arg); 64 | 65 | Command.Append(arg.Channel.Name); 66 | Command.Append(" :"); 67 | Command.Append(arg.Message); 68 | 69 | return arg.Receiver.WriteLine(Command); 70 | } 71 | 72 | public override IEnumerable Support(IrcDaemon ircDaemon) 73 | { 74 | return Enumerable.Repeat("KNOCK", 1); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Language.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using System.Linq; 25 | using IrcD.Commands.Arguments; 26 | using IrcD.Core; 27 | using IrcD.Core.Utils; 28 | 29 | namespace IrcD.Commands 30 | { 31 | class Language : CommandBase 32 | { 33 | public Language(IrcDaemon ircDaemon) 34 | : base(ircDaemon, "LANGUAGE", "") 35 | { } 36 | 37 | [CheckRegistered] 38 | [CheckParamCount(1)] 39 | protected override void PrivateHandle(UserInfo info, List args) 40 | { 41 | info.Languages = args[0].Split(','); 42 | 43 | IrcDaemon.Replies.SendYourLanguageIs(info); 44 | } 45 | 46 | protected override int PrivateSend(CommandArgument commandArgument) 47 | { 48 | throw new NotImplementedException(); 49 | } 50 | 51 | public override IEnumerable Support(IrcDaemon ircDaemon) 52 | { 53 | return Enumerable.Repeat("LANGUAGE=" + ircDaemon.Options.MaxLanguages, 1); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Links.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | 28 | namespace IrcD.Commands 29 | { 30 | public class Links : CommandBase 31 | { 32 | public Links(IrcDaemon ircDaemon) 33 | : base(ircDaemon, "LINKS", "LI") 34 | { } 35 | 36 | [CheckRegistered] 37 | protected override void PrivateHandle(UserInfo info, List args) 38 | { 39 | } 40 | 41 | protected override int PrivateSend(CommandArgument commandArgument) 42 | { 43 | throw new NotImplementedException(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/List.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using System.Linq; 25 | using IrcD.Commands.Arguments; 26 | using IrcD.Core; 27 | using IrcD.Core.Utils; 28 | 29 | namespace IrcD.Commands 30 | { 31 | public class List : CommandBase 32 | { 33 | public List(IrcDaemon ircDaemon) 34 | : base(ircDaemon, "LIST", "LIST") 35 | { } 36 | 37 | [CheckRegistered] 38 | protected override void PrivateHandle(UserInfo info, List args) 39 | { 40 | if (info.IrcDaemon.Options.IrcMode == IrcMode.Rfc1459) 41 | IrcDaemon.Replies.SendListStart(info); 42 | 43 | // TODO: special List commands (if RfcModern) 44 | foreach (var ci in IrcDaemon.Channels.Values.Where(ci => !ci.Modes.IsPrivate() && !ci.Modes.IsSecret())) 45 | { 46 | IrcDaemon.Replies.SendListItem(info, ci); 47 | } 48 | 49 | IrcDaemon.Replies.SendListEnd(info); 50 | } 51 | 52 | protected override int PrivateSend(CommandArgument commandArgument) 53 | { 54 | throw new NotImplementedException(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/ListUsers.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | 28 | namespace IrcD.Commands 29 | { 30 | public class ListUsers : CommandBase 31 | { 32 | public ListUsers(IrcDaemon ircDaemon) 33 | : base(ircDaemon, "LUSERS", "LU") 34 | { } 35 | 36 | [CheckRegistered] 37 | protected override void PrivateHandle(UserInfo info, List args) 38 | { 39 | IrcDaemon.Replies.SendListUserClient(info); 40 | IrcDaemon.Replies.SendListUserOp(info); 41 | IrcDaemon.Replies.SendListUserUnknown(info); 42 | IrcDaemon.Replies.SendListUserChannels(info); 43 | IrcDaemon.Replies.SendListUserMe(info); 44 | } 45 | 46 | protected override int PrivateSend(CommandArgument commandArgument) 47 | { 48 | throw new NotImplementedException(); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/MessageOfTheDay.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | 28 | namespace IrcD.Commands 29 | { 30 | public class MessageOfTheDay : CommandBase 31 | { 32 | public MessageOfTheDay(IrcDaemon ircDaemon) 33 | : base(ircDaemon, "MOTD", "MO") 34 | { } 35 | 36 | [CheckRegistered] 37 | protected override void PrivateHandle(UserInfo info, List args) 38 | { 39 | // TODO: parameter 1 parsing 40 | 41 | if (string.IsNullOrEmpty(IrcDaemon.Options.MessageOfTheDay)) 42 | { 43 | IrcDaemon.Replies.SendNoMotd(info); 44 | } 45 | else 46 | { 47 | IrcDaemon.Replies.SendMotdStart(info); 48 | IrcDaemon.Replies.SendMotd(info); 49 | IrcDaemon.Replies.SendMotdEnd(info); 50 | } 51 | } 52 | 53 | protected override int PrivateSend(CommandArgument commandArgument) 54 | { 55 | throw new NotImplementedException(); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Names.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using System.Linq; 25 | using IrcD.Commands.Arguments; 26 | using IrcD.Core; 27 | using IrcD.Core.Utils; 28 | 29 | namespace IrcD.Commands 30 | { 31 | public class Names : CommandBase 32 | { 33 | public Names(IrcDaemon ircDaemon) 34 | : base(ircDaemon, "NAMES", "E") 35 | { } 36 | 37 | [CheckRegistered] 38 | protected override void PrivateHandle(UserInfo info, List args) 39 | { 40 | if (args.Count < 1) 41 | { 42 | // TODO: list all visible users 43 | return; 44 | } 45 | 46 | //TODO: taget parameter 47 | foreach (var ch in GetSubArgument(args[0]).Where(ch => IrcDaemon.Channels.ContainsKey(ch))) 48 | { 49 | IrcDaemon.Replies.SendNamesReply(info, IrcDaemon.Channels[ch]); 50 | IrcDaemon.Replies.SendEndOfNamesReply(info, IrcDaemon.Channels[ch]); 51 | } 52 | } 53 | 54 | protected override int PrivateSend(CommandArgument commandArgument) 55 | { 56 | throw new NotImplementedException(); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /IrcD.Net/Commands/Part.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | 28 | namespace IrcD.Commands 29 | { 30 | public class Part : CommandBase 31 | { 32 | public Part(IrcDaemon ircDaemon) 33 | : base(ircDaemon, "PART", "L") 34 | { } 35 | 36 | [CheckRegistered] 37 | [CheckParamCount(1)] 38 | protected override void PrivateHandle(UserInfo info, List args) 39 | { 40 | var message = (args.Count > 1) ? args[1] : IrcDaemon.Options.StandardPartMessage; 41 | 42 | 43 | foreach (string channelName in GetSubArgument(args[0])) 44 | { 45 | if (IrcDaemon.Channels.ContainsKey(channelName)) 46 | { 47 | var chan = IrcDaemon.Channels[channelName]; 48 | 49 | if (info.Channels.Contains(chan)) 50 | { 51 | Send(new PartArgument(info, chan, chan, message)); 52 | chan.RemoveUser(info); 53 | } 54 | else 55 | { 56 | IrcDaemon.Replies.SendNotOnChannel(info, channelName); 57 | } 58 | } 59 | else 60 | { 61 | IrcDaemon.Replies.SendNoSuchChannel(info, channelName); 62 | } 63 | } 64 | } 65 | 66 | protected override int PrivateSend(CommandArgument commandArgument) 67 | { 68 | var arg = GetSaveArgument(commandArgument); 69 | 70 | 71 | BuildMessageHeader(arg); 72 | 73 | Command.Append(arg.Channel.Name); 74 | Command.Append(" :"); 75 | Command.Append(arg.Message); 76 | 77 | return arg.Receiver.WriteLine(Command); 78 | 79 | } 80 | } 81 | } 82 | 83 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Pass.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using System.Linq; 25 | using IrcD.Commands.Arguments; 26 | using IrcD.Core; 27 | using IrcD.Core.Utils; 28 | 29 | namespace IrcD.Commands 30 | { 31 | public class Pass : CommandBase 32 | { 33 | public Pass(IrcDaemon ircDaemon) 34 | : base(ircDaemon, "PASS", "PA") 35 | { } 36 | 37 | [CheckParamCount(1)] 38 | protected override void PrivateHandle(UserInfo info, List args) 39 | { 40 | if (info.PassAccepted) 41 | { 42 | IrcDaemon.Replies.SendAlreadyRegistered(info); 43 | return; 44 | } 45 | 46 | if (args[0] == IrcDaemon.Options.ServerPass) 47 | { 48 | info.PassAccepted = true; 49 | return; 50 | } 51 | 52 | if (IrcDaemon.Options.ConnectionPasses.Any(p => p == args[0])) 53 | { 54 | // This is an allowed Server connection 55 | IrcDaemon.ConnectFromServer(info); 56 | return; 57 | } 58 | 59 | IrcDaemon.Replies.SendPasswordMismatch(info); 60 | } 61 | 62 | protected override int PrivateSend(CommandArgument commandArgument) 63 | { 64 | throw new NotImplementedException(); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Ping.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | 28 | namespace IrcD.Commands 29 | { 30 | public class Ping : CommandBase 31 | { 32 | public Ping(IrcDaemon ircDaemon) 33 | : base(ircDaemon, "PING", "G") 34 | { } 35 | 36 | [CheckRegistered] 37 | protected override void PrivateHandle(UserInfo info, List args) 38 | { 39 | Send(new PongArgument(info, args.FirstOrDefault())); 40 | } 41 | 42 | protected override int PrivateSend(CommandArgument commandArgument) 43 | { 44 | var arg = GetSaveArgument(commandArgument); 45 | 46 | 47 | Command.Length = 0; 48 | Command.Append("PING "); 49 | Command.Append(IrcDaemon.ServerPrefix); 50 | 51 | return arg.Receiver.WriteLine(Command); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Pong.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Commands.Arguments; 24 | using IrcD.Core; 25 | 26 | namespace IrcD.Commands 27 | { 28 | public class Pong : CommandBase 29 | { 30 | public Pong(IrcDaemon ircDaemon) 31 | : base(ircDaemon, "PONG", "Z") 32 | { } 33 | 34 | protected override void PrivateHandle(UserInfo info, List args) 35 | { 36 | } 37 | 38 | protected override int PrivateSend(CommandArgument commandArgument) 39 | { 40 | var arg = GetSaveArgument(commandArgument); 41 | 42 | Command.Length = 0; 43 | Command.Append(IrcDaemon.ServerPrefix); 44 | Command.Append(" "); 45 | Command.Append(arg.Name); 46 | Command.Append(" "); 47 | Command.Append(IrcDaemon.ServerPrefix); 48 | Command.Append(" "); 49 | Command.Append(arg.Parameter); 50 | 51 | return arg.Receiver.WriteLine(Command); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Quit.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | 28 | namespace IrcD.Commands 29 | { 30 | public class Quit : CommandBase 31 | { 32 | public Quit(IrcDaemon ircDaemon) 33 | : base(ircDaemon, "QUIT", "Q") 34 | { } 35 | 36 | [CheckRegistered] 37 | protected override void PrivateHandle(UserInfo info, List args) 38 | { 39 | var message = args.Count > 0 ? args.First() : IrcDaemon.Options.StandardQuitMessage; 40 | info.Remove(message); 41 | } 42 | 43 | protected override int PrivateSend(CommandArgument commandArgument) 44 | { 45 | var arg = GetSaveArgument(commandArgument); 46 | BuildMessageHeader(arg); 47 | 48 | Command.Append(arg.Message); 49 | 50 | return arg.Receiver.WriteLine(Command); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Rehash.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | using IrcD.Modes.UserModes; 28 | 29 | namespace IrcD.Commands 30 | { 31 | public class Rehash : CommandBase 32 | { 33 | public Rehash(IrcDaemon ircDaemon) 34 | : base(ircDaemon, "REHASH", "REHASH") 35 | { } 36 | 37 | [CheckRegistered] 38 | protected override void PrivateHandle(UserInfo info, List args) 39 | { 40 | if (info.Modes.Exist() || info.Modes.Exist()) 41 | { 42 | IrcDaemon.OnRehashEvent(this, new RehashEventArgs(IrcDaemon, info)); 43 | } 44 | } 45 | 46 | protected override int PrivateSend(CommandArgument commandArgument) 47 | { 48 | throw new NotImplementedException(); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Restart.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | using IrcD.Modes.UserModes; 28 | 29 | namespace IrcD.Commands 30 | { 31 | public class Restart : CommandBase 32 | { 33 | public Restart(IrcDaemon ircDaemon) 34 | : base(ircDaemon, "RESTART", "RESTART") 35 | { } 36 | 37 | [CheckRegistered] 38 | protected override void PrivateHandle(UserInfo info, List args) 39 | { 40 | if (!info.Modes.Exist() && !info.Modes.Exist()) 41 | { 42 | IrcDaemon.Replies.SendNoPrivileges(info); 43 | return; 44 | } 45 | 46 | IrcDaemon.Stop(true); 47 | } 48 | 49 | protected override int PrivateSend(CommandArgument commandArgument) 50 | { 51 | throw new NotImplementedException(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Server.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | 27 | namespace IrcD.Commands 28 | { 29 | public class Server : CommandBase 30 | { 31 | public Server(IrcDaemon ircDaemon) 32 | : base(ircDaemon, "SERVER", "S") 33 | { } 34 | 35 | protected override void PrivateHandle(UserInfo info, List args) 36 | { 37 | } 38 | 39 | protected override int PrivateSend(CommandArgument commandArgument) 40 | { 41 | throw new NotImplementedException(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/ServerQuit.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | 27 | namespace IrcD.Commands 28 | { 29 | public class ServerQuit : CommandBase 30 | { 31 | public ServerQuit(IrcDaemon ircDaemon) 32 | : base(ircDaemon, "SQUIT", "SQ") 33 | { } 34 | 35 | protected override void PrivateHandle(UserInfo info, List args) 36 | { 37 | } 38 | 39 | protected override int PrivateSend(CommandArgument commandArgument) 40 | { 41 | throw new NotImplementedException(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Service.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | 28 | namespace IrcD.Commands 29 | { 30 | public class Service : CommandBase 31 | { 32 | public Service(IrcDaemon ircDaemon) 33 | : base(ircDaemon, "SERVICE", "") 34 | { } 35 | 36 | [CheckParamCount(6)] 37 | protected override void PrivateHandle(UserInfo info, List args) 38 | { 39 | if (info.Registered) 40 | { 41 | IrcDaemon.Replies.SendAlreadyRegistered(info); 42 | return; 43 | } 44 | 45 | if (!IrcDaemon.ValidNick(args[0])) 46 | { 47 | IrcDaemon.Replies.SendErroneousNickname(info, args[0]); 48 | return; 49 | } 50 | 51 | if (IrcDaemon.Nicks.ContainsKey(args[0])) 52 | { 53 | IrcDaemon.Replies.SendNicknameInUse(info, args[0]); 54 | return; 55 | } 56 | 57 | info.IsService = true; 58 | info.InitNick(args[0]); 59 | info.InitUser("service", "I am a service"); 60 | 61 | IrcDaemon.Nicks.Add(info.Nick, info); 62 | } 63 | 64 | protected override int PrivateSend(CommandArgument commandArgument) 65 | { 66 | throw new NotImplementedException(); 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /IrcD.Net/Commands/ServiceList.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | 27 | namespace IrcD.Commands 28 | { 29 | public class ServiceList : CommandBase 30 | { 31 | public ServiceList(IrcDaemon ircDaemon) 32 | : base(ircDaemon, "SERVLIST", "SERVLIST") 33 | { } 34 | 35 | protected override void PrivateHandle(UserInfo info, List args) 36 | { 37 | } 38 | 39 | protected override int PrivateSend(CommandArgument commandArgument) 40 | { 41 | throw new NotImplementedException(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/ServiceQuery.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | 27 | namespace IrcD.Commands 28 | { 29 | public class ServiceQuery : CommandBase 30 | { 31 | public ServiceQuery(IrcDaemon ircDaemon) 32 | : base(ircDaemon, "SQUERY", "SQUERY") 33 | { } 34 | 35 | protected override void PrivateHandle(UserInfo info, List args) 36 | { 37 | } 38 | 39 | protected override int PrivateSend(CommandArgument commandArgument) 40 | { 41 | throw new NotImplementedException(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Silence.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using System.Linq; 25 | using IrcD.Commands.Arguments; 26 | using IrcD.Core; 27 | 28 | namespace IrcD.Commands 29 | { 30 | public class Silence : CommandBase 31 | { 32 | public Silence(IrcDaemon ircDaemon) 33 | : base(ircDaemon, "SILENCE", "U") 34 | { } 35 | 36 | protected override void PrivateHandle(UserInfo info, List args) 37 | { 38 | } 39 | 40 | protected override int PrivateSend(CommandArgument commandArgument) 41 | { 42 | throw new NotImplementedException(); 43 | } 44 | 45 | public override IEnumerable Support(IrcDaemon ircDaemon) 46 | { 47 | return Enumerable.Repeat("SILENCE=" + ircDaemon.Options.MaxSilence, 1); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Stats.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using System.Linq; 25 | using IrcD.Commands.Arguments; 26 | using IrcD.Core; 27 | using IrcD.Modes.UserModes; 28 | 29 | namespace IrcD.Commands 30 | { 31 | public class Stats : CommandBase 32 | { 33 | public Stats(IrcDaemon ircDaemon) 34 | : base(ircDaemon, "STATS", "R") 35 | { } 36 | 37 | protected override void PrivateHandle(UserInfo info, List args) 38 | { 39 | if (args.Count < 1) 40 | { 41 | IrcDaemon.Replies.SendEndOfStats(info, "-"); 42 | } 43 | 44 | //ToDo: parse target parameter 45 | 46 | if (args[0].Any(l => l == 'l')) 47 | { 48 | IrcDaemon.Replies.SendStatsLinkInfo(info); 49 | } 50 | if (args[0].Any(l => l == 'm')) 51 | { 52 | foreach (var command in IrcDaemon.Commands.OrderBy(c => c.Name)) 53 | { 54 | IrcDaemon.Replies.SendStatsCommands(info, command); 55 | } 56 | } 57 | if (args[0].Any(l => l == 'o')) 58 | { 59 | foreach (var op in IrcDaemon.Nicks 60 | .Select(u => u.Value) 61 | .Where(n => n.Modes.Exist() || n.Modes.Exist()) 62 | .OrderBy(o => o.Nick)) 63 | { 64 | IrcDaemon.Replies.SendStatsOLine(info, op); 65 | } 66 | 67 | } 68 | 69 | if (args[0].Any(l => l == 'u')) 70 | { 71 | IrcDaemon.Replies.SendStatsUptime(info); 72 | } 73 | 74 | IrcDaemon.Replies.SendEndOfStats(info, args[0]); 75 | } 76 | 77 | protected override int PrivateSend(CommandArgument commandArgument) 78 | { 79 | throw new NotImplementedException(); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Summon.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | 28 | namespace IrcD.Commands 29 | { 30 | public class Summon : CommandBase 31 | { 32 | public Summon(IrcDaemon ircDaemon) 33 | : base(ircDaemon, "SUMMON", "") 34 | { } 35 | 36 | [CheckRegistered] 37 | protected override void PrivateHandle(UserInfo info, List args) 38 | { 39 | IrcDaemon.Replies.SendSummonDisabled(info); 40 | } 41 | 42 | protected override int PrivateSend(CommandArgument commandArgument) 43 | { 44 | throw new NotImplementedException(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Time.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | 28 | namespace IrcD.Commands 29 | { 30 | public class Time : CommandBase 31 | { 32 | public Time(IrcDaemon ircDaemon) 33 | : base(ircDaemon, "TIME", "TI") 34 | { } 35 | 36 | [CheckRegistered] 37 | protected override void PrivateHandle(UserInfo info, List args) 38 | { 39 | //ToDo: parse target parameter 40 | 41 | IrcDaemon.Replies.SendTimeReply(info); 42 | } 43 | 44 | protected override int PrivateSend(CommandArgument commandArgument) 45 | { 46 | throw new NotImplementedException(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Topic.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Commands.Arguments; 24 | using IrcD.Core; 25 | using IrcD.Core.Utils; 26 | 27 | namespace IrcD.Commands 28 | { 29 | public class Topic : CommandBase 30 | { 31 | public Topic(IrcDaemon ircDaemon) 32 | : base(ircDaemon, "TOPIC", "T") 33 | { } 34 | 35 | [CheckRegistered] 36 | [CheckParamCount(1)] 37 | protected override void PrivateHandle(UserInfo info, List args) 38 | { 39 | if (!IrcDaemon.Channels.ContainsKey(args[0])) 40 | { 41 | IrcDaemon.Replies.SendNoSuchChannel(info, args[0]); 42 | return; 43 | } 44 | 45 | var chan = IrcDaemon.Channels[args[0]]; 46 | 47 | if (args.Count == 1) 48 | { 49 | if (string.IsNullOrEmpty(chan.Topic)) 50 | { 51 | IrcDaemon.Replies.SendNoTopicReply(info, chan); 52 | } 53 | else 54 | { 55 | IrcDaemon.Replies.SendTopicReply(info, chan); 56 | } 57 | return; 58 | } 59 | 60 | chan.Topic = args[1]; 61 | 62 | // Some Mode might want to handle the command 63 | if (!chan.Modes.HandleEvent(this, chan, info, args)) 64 | { 65 | return; 66 | } 67 | 68 | foreach (var user in chan.Users) 69 | { 70 | Send(new TopicArgument(info, user, chan, chan.Topic)); 71 | } 72 | } 73 | 74 | protected override int PrivateSend(CommandArgument commandArgument) 75 | { 76 | var arg = GetSaveArgument(commandArgument); 77 | 78 | BuildMessageHeader(arg); 79 | 80 | Command.Append(arg.Channel.Name); 81 | Command.Append(" :"); 82 | Command.Append(arg.NewTopic); 83 | 84 | return arg.Receiver.WriteLine(Command); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Trace.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | 27 | namespace IrcD.Commands 28 | { 29 | public class Trace : CommandBase 30 | { 31 | public Trace(IrcDaemon ircDaemon) 32 | : base(ircDaemon, "TRACE", "TR") 33 | { } 34 | 35 | protected override void PrivateHandle(UserInfo info, List args) 36 | { 37 | } 38 | 39 | protected override int PrivateSend(CommandArgument commandArgument) 40 | { 41 | throw new NotImplementedException(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/User.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | using IrcD.Modes.UserModes; 28 | 29 | namespace IrcD.Commands 30 | { 31 | public class User : CommandBase 32 | { 33 | public User(IrcDaemon ircDaemon) 34 | : base(ircDaemon, "USER", "USER") 35 | { } 36 | 37 | [CheckParamCount(4)] 38 | protected override void PrivateHandle(UserInfo info, List args) 39 | { 40 | if (!info.PassAccepted) 41 | { 42 | IrcDaemon.Replies.SendPasswordMismatch(info); 43 | return; 44 | } 45 | 46 | if (info.UserExists) 47 | { 48 | IrcDaemon.Replies.SendAlreadyRegistered(info); 49 | return; 50 | } 51 | 52 | int.TryParse(args[1], out int flags); 53 | 54 | if ((flags & 8) > 0) 55 | { 56 | info.Modes.Add(new ModeInvisible()); 57 | } 58 | if ((flags & 4) > 0) 59 | { 60 | info.Modes.Add(new ModeWallops()); 61 | } 62 | 63 | info.InitUser(args[0], args[3]); 64 | } 65 | 66 | protected override int PrivateSend(CommandArgument commandArgument) 67 | { 68 | throw new NotImplementedException(); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/UserHost.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | 28 | namespace IrcD.Commands 29 | { 30 | public class UserHost : CommandBase 31 | { 32 | public UserHost(IrcDaemon ircDaemon) 33 | : base(ircDaemon, "USERHOST", "USERHOST") 34 | { } 35 | 36 | [CheckRegistered] 37 | [CheckParamCount(1)] 38 | protected override void PrivateHandle(UserInfo info, List args) 39 | { 40 | var users = new List(); 41 | foreach (var arg in args) 42 | { 43 | if (IrcDaemon.Nicks.TryGetValue(arg, out UserInfo user)) 44 | { 45 | users.Add(user); 46 | } 47 | } 48 | 49 | IrcDaemon.Replies.SendUserHost(info, users); 50 | } 51 | 52 | protected override int PrivateSend(CommandArgument commandArgument) 53 | { 54 | throw new NotImplementedException(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Version.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | 28 | namespace IrcD.Commands 29 | { 30 | public class Version : CommandBase 31 | { 32 | public Version(IrcDaemon ircDaemon) 33 | : base(ircDaemon, "VERSION", "V") 34 | { } 35 | 36 | [CheckRegistered] 37 | protected override void PrivateHandle(UserInfo info, List args) 38 | { 39 | //ToDo: parse target parameter 40 | 41 | IrcDaemon.Replies.SendVersion(info); 42 | } 43 | 44 | protected override int PrivateSend(CommandArgument commandArgument) 45 | { 46 | throw new NotImplementedException(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/Wallops.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | 27 | namespace IrcD.Commands 28 | { 29 | public class Wallops : CommandBase 30 | { 31 | public Wallops(IrcDaemon ircDaemon) 32 | : base(ircDaemon, "WALLOPS", "WA") 33 | { } 34 | 35 | protected override void PrivateHandle(UserInfo info, List args) 36 | { 37 | } 38 | 39 | protected override int PrivateSend(CommandArgument commandArgument) 40 | { 41 | throw new NotImplementedException(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/WhoIs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | using IrcD.Modes.UserModes; 28 | 29 | namespace IrcD.Commands 30 | { 31 | public class WhoIs : CommandBase 32 | { 33 | public WhoIs(IrcDaemon ircDaemon) 34 | : base(ircDaemon, "WHOIS", "W") 35 | { } 36 | 37 | [CheckRegistered] 38 | [CheckParamCount(1)] 39 | protected override void PrivateHandle(UserInfo info, List args) 40 | { 41 | if (!IrcDaemon.Nicks.ContainsKey(args[0])) 42 | { 43 | IrcDaemon.Replies.SendNoSuchNick(info, args[0]); 44 | return; 45 | } 46 | 47 | var user = IrcDaemon.Nicks[args[0]]; 48 | IrcDaemon.Replies.SendWhoIsUser(info, user); 49 | if (info.UserPerChannelInfos.Count > 0) 50 | { 51 | IrcDaemon.Replies.SendWhoIsChannels(info, user); 52 | } 53 | IrcDaemon.Replies.SendWhoIsServer(info, user); 54 | if (user.AwayMessage != null) 55 | { 56 | IrcDaemon.Replies.SendAwayMessage(info, user); 57 | } 58 | 59 | if (IrcDaemon.Options.IrcMode == IrcMode.Modern) 60 | { 61 | IrcDaemon.Replies.SendWhoIsLanguage(info, user); 62 | } 63 | 64 | 65 | if (user.Modes.Exist() || user.Modes.Exist()) 66 | { 67 | IrcDaemon.Replies.SendWhoIsOperator(info, user); 68 | } 69 | 70 | IrcDaemon.Replies.SendWhoIsIdle(info, user); 71 | IrcDaemon.Replies.SendEndOfWhoIs(info, user); 72 | } 73 | 74 | protected override int PrivateSend(CommandArgument commandArgument) 75 | { 76 | throw new NotImplementedException(); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /IrcD.Net/Commands/WhoWas.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using IrcD.Commands.Arguments; 25 | using IrcD.Core; 26 | using IrcD.Core.Utils; 27 | 28 | namespace IrcD.Commands 29 | { 30 | public class WhoWas : CommandBase 31 | { 32 | public WhoWas(IrcDaemon ircDaemon) 33 | : base(ircDaemon, "WHOWAS", "X") 34 | { } 35 | 36 | [CheckRegistered] 37 | protected override void PrivateHandle(UserInfo info, List args) 38 | { 39 | } 40 | 41 | protected override int PrivateSend(CommandArgument commandArgument) 42 | { 43 | throw new NotImplementedException(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /IrcD.Net/Core/InfoBase.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Text; 23 | 24 | namespace IrcD.Core 25 | { 26 | public abstract class InfoBase 27 | { 28 | public IrcDaemon IrcDaemon { get; } 29 | 30 | protected InfoBase(IrcDaemon ircDaemon) 31 | { 32 | IrcDaemon = ircDaemon; 33 | } 34 | 35 | /// 36 | /// Write a Line to the abstract object (hide the socket better) 37 | /// 38 | public abstract int WriteLine(StringBuilder line); 39 | 40 | public abstract int WriteLine(StringBuilder line, UserInfo exception); 41 | } 42 | } -------------------------------------------------------------------------------- /IrcD.Net/Core/ServerInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Text; 24 | 25 | namespace IrcD.Core 26 | { 27 | class ServerInfo : InfoBase 28 | { 29 | public ServerInfo(IrcDaemon ircDaemon) 30 | : base(ircDaemon) 31 | { 32 | 33 | } 34 | 35 | public override int WriteLine(StringBuilder line) 36 | { 37 | throw new NotImplementedException(); 38 | } 39 | 40 | public override int WriteLine(StringBuilder line, UserInfo exception) 41 | { 42 | throw new NotImplementedException(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /IrcD.Net/Core/ServerStats.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | using System.Linq; 24 | using IrcD.Modes.UserModes; 25 | 26 | namespace IrcD.Core 27 | { 28 | public class ServerStats 29 | { 30 | readonly IrcDaemon _ircDaemon; 31 | 32 | public ServerStats(IrcDaemon ircDaemon) 33 | { 34 | _ircDaemon = ircDaemon; 35 | } 36 | 37 | public int ServerCount 38 | { 39 | get 40 | { 41 | return 1; 42 | } 43 | } 44 | 45 | public int ServiceCount 46 | { 47 | get 48 | { 49 | return _ircDaemon.Sockets.Count(s => s.Value.IsService); 50 | } 51 | } 52 | 53 | public int UserCount => _ircDaemon.Nicks.Count - ServiceCount; 54 | 55 | public int OperatorCount 56 | { 57 | get 58 | { 59 | return _ircDaemon.Sockets.Count(s => s.Value.Modes.Exist()); 60 | } 61 | } 62 | 63 | public int LocalOperatorCount 64 | { 65 | get 66 | { 67 | return _ircDaemon.Sockets.Count(s => s.Value.Modes.Exist()); 68 | } 69 | } 70 | 71 | public int UnknowConnectionCount 72 | { 73 | get 74 | { 75 | return _ircDaemon.Sockets.Count(s => !s.Value.IsAcceptSocket); 76 | } 77 | } 78 | 79 | 80 | public int ChannelCount => _ircDaemon.Channels.Count; 81 | 82 | public int ClientCount => _ircDaemon.Nicks.Count; 83 | 84 | public TimeSpan Uptime => DateTime.Now - _ircDaemon.ServerCreated; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /IrcD.Net/Core/Utils/AlreadyCalledException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | 24 | namespace IrcD.Core.Utils 25 | { 26 | /// 27 | /// This Exception is thrown for methods which only should be called once, but are called a second time. 28 | /// 29 | public class AlreadyCalledException : Exception 30 | { 31 | } 32 | } -------------------------------------------------------------------------------- /IrcD.Net/Core/Utils/CheckParamCountAttribute.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | 24 | namespace IrcD.Core.Utils 25 | { 26 | public class CheckParamCountAttribute : Attribute 27 | { 28 | public int MinimumParameterCount { get; } 29 | 30 | public CheckParamCountAttribute(int minimumParameterCount) 31 | { 32 | MinimumParameterCount = minimumParameterCount; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /IrcD.Net/Core/Utils/CheckRegisteredAttribute.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | 24 | namespace IrcD.Core.Utils 25 | { 26 | public class CheckRegisteredAttribute : Attribute 27 | { 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /IrcD.Net/Core/Utils/IrcCaseMapping.cs: -------------------------------------------------------------------------------- 1 | using IrcD.Tools; 2 | 3 | namespace IrcD.Core.Utils 4 | { 5 | public enum IrcCaseMapping 6 | { 7 | [EnumDescription("ascii")] 8 | Ascii, 9 | [EnumDescription("rfc1459")] 10 | Rfc1459, 11 | [EnumDescription("strict-rfc1459")] 12 | StrictRfc1459 13 | } 14 | } -------------------------------------------------------------------------------- /IrcD.Net/Core/Utils/IrcMode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | namespace IrcD.Core.Utils 23 | { 24 | /// 25 | /// Description of IrcMode. 26 | /// 27 | public enum IrcMode 28 | { 29 | Rfc1459, 30 | Rfc2810, 31 | Modern 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /IrcD.Net/Core/Utils/OperHost.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | using IrcD.Tools; 22 | 23 | namespace IrcD.Core.Utils 24 | { 25 | public class OperHost 26 | { 27 | public bool Allow; 28 | public WildCard WildcardHostMask; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /IrcD.Net/Core/Utils/P10Numerics.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace IrcD.Core.Utils 7 | { 8 | public class P10Numeric 9 | { 10 | 11 | const int Base = 64; 12 | static char[] _lookupTable = new char[Base] 13 | { 'A','B','C','D','E','F','G','H','I','J','K','L','M', 14 | 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z', 15 | 'a','b','c','d','e','f','g','h','i','j','k','l','m', 16 | 'n','o','p','q','r','s','t','u','v','w','x','y','z', 17 | '0','1','2','3','4','5','6','7','8','9','[',']'}; 18 | 19 | private readonly int _serverNumeric; 20 | public int ServerId => _serverNumeric; 21 | 22 | private readonly int? _clientNumeric; 23 | public int? ClientId => _clientNumeric; 24 | 25 | public bool IsServer => _clientNumeric.HasValue == false; 26 | 27 | private string _numericString; 28 | private static readonly StringBuilder Builder = new StringBuilder(); 29 | 30 | public P10Numeric(int serverNumeric, int? clientNumeric = null) 31 | { 32 | 33 | _serverNumeric = serverNumeric; 34 | _clientNumeric = clientNumeric; 35 | 36 | CreateString(); 37 | } 38 | 39 | private void CreateString() 40 | { 41 | Builder.Clear(); 42 | 43 | NumericString(_serverNumeric, 2); 44 | 45 | if (_clientNumeric.HasValue) 46 | { 47 | NumericString(_clientNumeric.Value, 3); 48 | } 49 | 50 | _numericString = Builder.ToString(); 51 | 52 | } 53 | 54 | private void NumericString(int numeric, int length) 55 | { 56 | foreach (var index in Enumerable.Range(1, length)) 57 | { 58 | Builder.Append(_lookupTable[numeric / Power(Base, length - index) % Base]); 59 | } 60 | } 61 | 62 | private int Power(int @base, int power) 63 | { 64 | return power switch 65 | { 66 | 0 => 1, 67 | 1 => @base, 68 | _ => @base * Power(@base, power - 1), 69 | }; 70 | } 71 | 72 | public override string ToString() 73 | { 74 | return _numericString; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /IrcD.Net/Core/Utils/RehashEventArgs.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | 24 | namespace IrcD.Core.Utils 25 | { 26 | public class RehashEventArgs : EventArgs 27 | { 28 | public IrcDaemon IrcDaemon { get; } 29 | public UserInfo UserInfo { get; } 30 | 31 | public RehashEventArgs(IrcDaemon ircDaemon, UserInfo userInfo) 32 | { 33 | IrcDaemon = ircDaemon; 34 | UserInfo = userInfo; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /IrcD.Net/IrcD.Net.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 9.0 6 | enable 7 | 8 | true 9 | Fully Functional Object Oriented Implementation of an IrcD Server 10 | BSD-3-Clause-Clear 11 | 12 | Thomas Bruderer 13 | apophis.ch 14 | 1.0.0 15 | https://github.com/FreeApophis/ircddotnet 16 | https://github.com/FreeApophis/ircddotnet 17 | IRC Server Testing 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelMode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using IrcD.Channel; 25 | using IrcD.Commands; 26 | using IrcD.Core; 27 | 28 | namespace IrcD.Modes 29 | { 30 | public abstract class ChannelMode : Mode 31 | { 32 | protected ChannelMode(char mode) 33 | : base(mode) 34 | { 35 | 36 | } 37 | 38 | /// 39 | /// This Method is called to check all the modes on a channel, each Mode has the chance to take control over a command. 40 | /// If it takes control it should return false, therefore the other Commands are not checked, and the control flow will interupt. 41 | /// 42 | /// Type of command 43 | /// The Channel the Mode is operating 44 | /// The User which uses the Command on the channel 45 | /// 46 | /// Handle Event should return true when the command is allowed to proceed normally. 47 | /// It should return false, if the Mode forbids the further execution of the Command. 48 | public abstract bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List args); 49 | 50 | /// 51 | /// Returns a list of ISUPPORT / Numeric 005 information this Mode is providing. 52 | /// 53 | /// Server Object 54 | /// returns strings for direct usage in an ISUPPORT reply 55 | public virtual IEnumerable Support(IrcDaemon ircDaemon) 56 | { 57 | return Enumerable.Empty(); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelModes/IParameter.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Channel; 24 | using IrcD.Core; 25 | 26 | namespace IrcD.Modes.ChannelModes 27 | { 28 | public interface IParameter 29 | { 30 | string Add(string parameter); 31 | } 32 | 33 | public interface IParameterB : IParameter 34 | { 35 | string Parameter { get; set; } 36 | } 37 | 38 | public interface IParameterC : IParameter 39 | { 40 | string Parameter { get; set; } 41 | } 42 | 43 | public interface IParameterListA : IParameter 44 | { 45 | List Parameter { get; } 46 | 47 | void SendList(UserInfo info, ChannelInfo chan); 48 | string Remove(string parameter); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelModes/ModeBanException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using IrcD.Channel; 25 | using IrcD.Commands; 26 | using IrcD.Core; 27 | 28 | namespace IrcD.Modes.ChannelModes 29 | { 30 | public class ModeBanException : ChannelMode, IParameterListA 31 | { 32 | public ModeBanException() 33 | : base('e') 34 | { 35 | } 36 | 37 | private readonly List _banExceptionList = new List(); 38 | 39 | public List Parameter => _banExceptionList; 40 | 41 | public void SendList(UserInfo info, ChannelInfo chan) 42 | { 43 | foreach (var banExcpetion in _banExceptionList) 44 | { 45 | info.IrcDaemon.Replies.SendExceptionList(info, chan, banExcpetion); 46 | } 47 | 48 | info.IrcDaemon.Replies.SendEndOfExceptionList(info, chan); 49 | } 50 | 51 | public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List args) 52 | { 53 | // Handling JOIN is done in the ModeBan class 54 | return true; 55 | } 56 | 57 | public string Add(string parameter) 58 | { 59 | parameter = UserInfo.NormalizeHostmask(parameter); 60 | 61 | _banExceptionList.Add(parameter); 62 | 63 | return parameter; 64 | } 65 | 66 | public string Remove(string parameter) 67 | { 68 | parameter = UserInfo.NormalizeHostmask(parameter); 69 | 70 | return _banExceptionList.RemoveAll(p => p == parameter) > 0 ? parameter : null; 71 | } 72 | 73 | public override IEnumerable Support(IrcDaemon ircDaemon) 74 | { 75 | return Enumerable.Repeat("EXCEPTS=" + Char, 1); 76 | } 77 | } 78 | } 79 | 80 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelModes/ModeColorless.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using IrcD.Channel; 25 | using IrcD.Commands; 26 | using IrcD.Core; 27 | using IrcD.Tools; 28 | 29 | namespace IrcD.Modes.ChannelModes 30 | { 31 | public class ModeColorless : ChannelMode 32 | { 33 | public ModeColorless() 34 | : base('c') 35 | { 36 | } 37 | 38 | public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List args) 39 | { 40 | if (command is PrivateMessage || command is Notice) 41 | { 42 | if (args[1].Any(c => c == IrcConstants.IrcColor)) 43 | { 44 | channel.IrcDaemon.Replies.SendCannotSendToChannel(user, channel.Name, "Color is not permitted in this channel"); 45 | return false; 46 | } 47 | 48 | if (args[1].Any(c => c == IrcConstants.IrcBold || c == IrcConstants.IrcNormal || c == IrcConstants.IrcUnderline || c == IrcConstants.IrcReverse)) 49 | { 50 | channel.IrcDaemon.Replies.SendCannotSendToChannel(user, channel.Name, "Control codes (bold/underline/reverse) are not permitted in this channel"); 51 | return false; 52 | } 53 | } 54 | 55 | return true; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelModes/ModeInvite.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Channel; 24 | using IrcD.Commands; 25 | using IrcD.Core; 26 | 27 | namespace IrcD.Modes.ChannelModes 28 | { 29 | public class ModeInvite : ChannelMode 30 | { 31 | public ModeInvite() 32 | : base('i') 33 | { 34 | } 35 | 36 | public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List args) 37 | { 38 | if (command is Join) 39 | { 40 | if (!user.Invited.Contains(channel)) 41 | { 42 | user.IrcDaemon.Replies.SendInviteOnlyChannel(user, channel); 43 | return false; 44 | } 45 | 46 | user.Invited.Remove(channel); 47 | } 48 | 49 | if (command is Invite) 50 | { 51 | if (channel.UserPerChannelInfos.TryGetValue(user.Nick, out UserPerChannelInfo upci)) 52 | { 53 | if (upci.Modes.Level < 30) 54 | { 55 | channel.IrcDaemon.Replies.SendChannelOpPrivilegesNeeded(user, channel); 56 | return false; 57 | } 58 | } 59 | else 60 | { 61 | channel.IrcDaemon.Replies.SendNotOnChannel(user, channel.Name); 62 | return false; 63 | } 64 | } 65 | 66 | return true; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelModes/ModeInviteException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using IrcD.Channel; 25 | using IrcD.Commands; 26 | using IrcD.Core; 27 | 28 | namespace IrcD.Modes.ChannelModes 29 | { 30 | public class ModeInviteException : ChannelMode, IParameterListA 31 | { 32 | public ModeInviteException() 33 | : base('I') 34 | { 35 | } 36 | 37 | private readonly List _inviteExceptionList = new List(); 38 | 39 | public List Parameter => _inviteExceptionList; 40 | 41 | public void SendList(UserInfo info, ChannelInfo chan) 42 | { 43 | foreach (var invite in _inviteExceptionList) 44 | { 45 | info.IrcDaemon.Replies.SendInviteList(info, chan, invite); 46 | } 47 | 48 | info.IrcDaemon.Replies.SendEndOfInviteList(info, chan); 49 | } 50 | 51 | public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List args) 52 | { 53 | // Handling JOIN is done in the ModeInvite class 54 | return true; 55 | } 56 | 57 | public string Add(string parameter) 58 | { 59 | parameter = UserInfo.NormalizeHostmask(parameter); 60 | 61 | _inviteExceptionList.Add(parameter); 62 | 63 | return parameter; 64 | } 65 | 66 | public string Remove(string parameter) 67 | { 68 | parameter = UserInfo.NormalizeHostmask(parameter); 69 | 70 | return _inviteExceptionList.RemoveAll(p => p == parameter) > 0 ? parameter : null; 71 | } 72 | 73 | public override IEnumerable Support(IrcDaemon ircDaemon) 74 | { 75 | return Enumerable.Repeat("INEVEX=" + Char, 1); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelModes/ModeKey.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using IrcD.Channel; 25 | using IrcD.Commands; 26 | using IrcD.Core; 27 | 28 | namespace IrcD.Modes.ChannelModes 29 | { 30 | public class ModeKey : ChannelMode, IParameterB 31 | { 32 | public ModeKey() 33 | : base('k') 34 | { 35 | } 36 | 37 | private string _key; 38 | 39 | public string Parameter 40 | { 41 | get 42 | { 43 | return _key; 44 | } 45 | set 46 | { 47 | _key = value; 48 | } 49 | } 50 | 51 | public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List args) 52 | { 53 | if (command is Join) 54 | { 55 | var keys = args.Count > 1 ? (IEnumerable)CommandBase.GetSubArgument(args[1]) : new List(); 56 | 57 | if (keys.All(k => k != _key)) 58 | { 59 | user.IrcDaemon.Replies.SendBadChannelKey(user, channel); 60 | return false; 61 | } 62 | } 63 | 64 | return true; 65 | } 66 | 67 | public string Add(string parameter) 68 | { 69 | _key = parameter; 70 | return _key; 71 | } 72 | } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelModes/ModeLimit.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Channel; 24 | using IrcD.Commands; 25 | using IrcD.Core; 26 | 27 | namespace IrcD.Modes.ChannelModes 28 | { 29 | public class ModeLimit : ChannelMode, IParameterC 30 | { 31 | public ModeLimit() : 32 | base('l') 33 | { 34 | 35 | } 36 | 37 | private int _limit; 38 | 39 | public string Parameter 40 | { 41 | get 42 | { 43 | return _limit.ToString(); 44 | } 45 | set 46 | { 47 | SetLimit(value); 48 | } 49 | } 50 | 51 | private void SetLimit(string value) 52 | { 53 | int.TryParse(value, out _limit); 54 | if (_limit < 1) 55 | { 56 | _limit = 1; 57 | } 58 | } 59 | 60 | public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List args) 61 | { 62 | if (command is Join) 63 | { 64 | 65 | if (_limit <= channel.UserPerChannelInfos.Count) 66 | { 67 | user.IrcDaemon.Replies.SendChannelIsFull(user, channel); 68 | return false; 69 | } 70 | } 71 | 72 | return true; 73 | } 74 | 75 | public string Add(string parameter) 76 | { 77 | SetLimit(parameter); 78 | return Parameter; 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelModes/ModeModerated.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Channel; 24 | using IrcD.Commands; 25 | using IrcD.Core; 26 | 27 | namespace IrcD.Modes.ChannelModes 28 | { 29 | public class ModeModerated : ChannelMode 30 | { 31 | public ModeModerated() 32 | : base('m') 33 | { 34 | } 35 | 36 | public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List args) 37 | { 38 | if (command is PrivateMessage || command is Notice) 39 | { 40 | if (!channel.UserPerChannelInfos.TryGetValue(user.Nick, out UserPerChannelInfo upci) || upci.Modes.Level < 10) 41 | { 42 | user.IrcDaemon.Replies.SendCannotSendToChannel(user, channel.Name); 43 | return false; 44 | } 45 | } 46 | 47 | return true; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelModes/ModeNoExternal.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Channel; 24 | using IrcD.Commands; 25 | using IrcD.Core; 26 | 27 | namespace IrcD.Modes.ChannelModes 28 | { 29 | public class ModeNoExternal : ChannelMode 30 | { 31 | public ModeNoExternal() 32 | : base('n') 33 | { 34 | } 35 | 36 | public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List args) 37 | { 38 | if (command is PrivateMessage || command is Notice) 39 | { 40 | if (!channel.UserPerChannelInfos.ContainsKey(user.Nick)) 41 | { 42 | user.IrcDaemon.Replies.SendCannotSendToChannel(user, channel.Name); 43 | return false; 44 | } 45 | } 46 | 47 | return true; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelModes/ModePrivate.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Channel; 24 | using IrcD.Commands; 25 | using IrcD.Core; 26 | 27 | namespace IrcD.Modes.ChannelModes 28 | { 29 | public class ModePrivate : ChannelMode 30 | { 31 | public ModePrivate() 32 | : base('p') 33 | { 34 | } 35 | 36 | public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List args) 37 | { 38 | return true; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelModes/ModeSecret.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Channel; 24 | using IrcD.Commands; 25 | using IrcD.Core; 26 | 27 | namespace IrcD.Modes.ChannelModes 28 | { 29 | public class ModeSecret : ChannelMode 30 | { 31 | public ModeSecret() 32 | : base('s') 33 | { 34 | } 35 | 36 | public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List args) 37 | { 38 | if (command is List) 39 | { 40 | // TODO 41 | } 42 | return true; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelModes/ModeTopic.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Channel; 24 | using IrcD.Commands; 25 | using IrcD.Core; 26 | 27 | namespace IrcD.Modes.ChannelModes 28 | { 29 | public class ModeTopic : ChannelMode 30 | { 31 | public ModeTopic() 32 | : base('t') 33 | { 34 | } 35 | 36 | public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List args) 37 | { 38 | if (command is Topic) 39 | { 40 | if (!channel.UserPerChannelInfos.TryGetValue(user.Nick, out UserPerChannelInfo upci)) 41 | { 42 | user.IrcDaemon.Replies.SendNotOnChannel(user, channel.Name); 43 | return false; 44 | } 45 | 46 | if (upci.Modes.Level < 30) 47 | { 48 | user.IrcDaemon.Replies.SendChannelOpPrivilegesNeeded(user, channel); 49 | return false; 50 | } 51 | } 52 | 53 | return true; 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelModes/ModeTranslate.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Channel; 24 | using IrcD.Commands; 25 | using IrcD.Commands.Arguments; 26 | using IrcD.Core; 27 | 28 | namespace IrcD.Modes.ChannelModes 29 | { 30 | class ModeTranslate : ChannelMode 31 | { 32 | 33 | public ModeTranslate() 34 | : base('T') 35 | { 36 | } 37 | 38 | private bool _onlyOnce; 39 | 40 | public override bool HandleEvent(CommandBase command, ChannelInfo channel, UserInfo user, List args) 41 | { 42 | if (_onlyOnce) { return true; } 43 | 44 | _onlyOnce = true; 45 | 46 | if (command is Join) 47 | { 48 | user.IrcDaemon.Commands.Send(new NoticeArgument(user, user, channel.Name, "This channel automatically translates your messages, use the LANGUAGE command to set your preferred language")); 49 | } 50 | if (!channel.Modes.HandleEvent(command, channel, user, args)) 51 | { 52 | _onlyOnce = false; 53 | return false; 54 | } 55 | 56 | if (command is PrivateMessage || command is Notice) 57 | { 58 | 59 | // Translation Code Removed 60 | 61 | _onlyOnce = false; 62 | return false; 63 | } 64 | 65 | _onlyOnce = false; 66 | return true; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelRank.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | 23 | namespace IrcD.Modes 24 | { 25 | public abstract class ChannelRank : Mode 26 | { 27 | public char Prefix { get; } 28 | public int Level { get; } 29 | 30 | protected ChannelRank(char mode, char prefix, int level) 31 | : base(mode) 32 | { 33 | Prefix = prefix; 34 | Level = level; 35 | } 36 | 37 | 38 | public abstract bool CanChangeChannelMode(ChannelMode mode); 39 | public abstract bool CanChangeChannelRank(ChannelRank rank); 40 | /* ToDo 41 | public abstract bool CanInviteUser(UserInfo user); 42 | public abstract bool CanKickUser(UserInfo user); 43 | public abstract bool CanChangeTopic(); 44 | public abstract bool CanSpeekModerated(); 45 | */ 46 | } 47 | } -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelRanks/ModeAdmin.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | namespace IrcD.Modes.ChannelRanks 23 | { 24 | public class ModeAdmin : ChannelRank 25 | { 26 | public const int AdminLevel = 70; 27 | 28 | public ModeAdmin() 29 | : base('a', '&', AdminLevel) 30 | { 31 | } 32 | 33 | public override bool CanChangeChannelMode(ChannelMode mode) 34 | { 35 | return false; 36 | } 37 | 38 | public override bool CanChangeChannelRank(ChannelRank rank) 39 | { 40 | return false; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelRanks/ModeHalfOp.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | namespace IrcD.Modes.ChannelRanks 23 | { 24 | class ModeHalfOp : ChannelRank 25 | { 26 | public const int HalfOpLevel = 30; 27 | 28 | public ModeHalfOp() 29 | : base('h', '%', HalfOpLevel) 30 | { 31 | 32 | } 33 | 34 | public override bool CanChangeChannelMode(ChannelMode mode) => false; 35 | public override bool CanChangeChannelRank(ChannelRank rank) => rank.Level <= Level; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelRanks/ModeNoRank.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | namespace IrcD.Modes.ChannelRanks 23 | { 24 | class ModeNoRank : ChannelRank 25 | { 26 | private ModeNoRank() 27 | : base(' ', ' ', 0) 28 | { 29 | 30 | } 31 | 32 | private static ModeNoRank _instance; 33 | public static ModeNoRank Instance => _instance ?? (_instance = new ModeNoRank()); 34 | 35 | public override bool CanChangeChannelMode(ChannelMode mode) => false; 36 | public override bool CanChangeChannelRank(ChannelRank rank) => false; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelRanks/ModeOp.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | namespace IrcD.Modes.ChannelRanks 23 | { 24 | class ModeOp : ChannelRank 25 | { 26 | public const int OpLevel = 50; 27 | 28 | public ModeOp() 29 | : base('o', '@', OpLevel) 30 | { 31 | } 32 | 33 | public override bool CanChangeChannelMode(ChannelMode mode) => true; 34 | public override bool CanChangeChannelRank(ChannelRank rank) => true; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelRanks/ModeOwner.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | namespace IrcD.Modes.ChannelRanks 23 | { 24 | public class ModeOwner : ChannelRank 25 | { 26 | public const int OwnerLevel = 100; 27 | 28 | public ModeOwner() 29 | : base('q', '~', OwnerLevel) 30 | { 31 | 32 | } 33 | 34 | public override bool CanChangeChannelMode(ChannelMode mode) => false; 35 | public override bool CanChangeChannelRank(ChannelRank rank) => false; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ChannelRanks/ModeVoice.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | namespace IrcD.Modes.ChannelRanks 23 | { 24 | public class ModeVoice : ChannelRank 25 | { 26 | public const int VoiceLevel = 10; 27 | 28 | public ModeVoice() 29 | : base('v', '+', VoiceLevel) 30 | { 31 | 32 | } 33 | 34 | public override bool CanChangeChannelMode(ChannelMode mode) => false; 35 | public override bool CanChangeChannelRank(ChannelRank rank) => false; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/Mode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | namespace IrcD.Modes 23 | { 24 | public class Mode 25 | { 26 | public char Char { get; } 27 | 28 | public Mode(char mode) 29 | { 30 | Char = mode; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/ModeList.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using System.Text; 25 | using IrcD.Core; 26 | 27 | namespace IrcD.Modes 28 | { 29 | public class ModeList : SortedList where TMode : Mode 30 | { 31 | 32 | protected IrcDaemon IrcDaemon; 33 | 34 | public ModeList(IrcDaemon ircDaemon) 35 | { 36 | IrcDaemon = ircDaemon; 37 | } 38 | 39 | public void Add(T element) where T : TMode 40 | { 41 | bool exists = (bool)typeof(ModeList).GetMethod("Exist").MakeGenericMethod(new[] { element.GetType() }).Invoke(this, null); 42 | if (exists == false) 43 | { 44 | Add(element.Char, element); 45 | } 46 | } 47 | 48 | public T GetMode() where T : TMode 49 | { 50 | return Values.FirstOrDefault(mode => mode is T) as T; 51 | } 52 | 53 | public void RemoveMode() where T : TMode 54 | { 55 | if (Exist()) 56 | { 57 | var mode = GetMode(); 58 | Remove(mode.Char); 59 | } 60 | } 61 | 62 | public override string ToString() 63 | { 64 | var modes = new StringBuilder(); 65 | 66 | foreach (var mode in Values) 67 | { 68 | modes.Append(mode.Char); 69 | } 70 | 71 | return modes.ToString(); 72 | } 73 | 74 | public bool Exist() where TExist : TMode 75 | { 76 | return Values.Any(m => m is TExist); 77 | } 78 | 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/UserMode.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Commands; 24 | using IrcD.Core; 25 | 26 | namespace IrcD.Modes 27 | { 28 | public abstract class UserMode : Mode 29 | { 30 | protected UserMode(char mode) 31 | : base(mode) 32 | { 33 | } 34 | 35 | /// 36 | /// 37 | /// 38 | /// 39 | /// 40 | /// 41 | /// 42 | public abstract bool HandleEvent(CommandBase command, UserInfo user, List args); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/UserModes/ModeAway.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Commands; 24 | using IrcD.Core; 25 | 26 | namespace IrcD.Modes.UserModes 27 | { 28 | public class ModeAway : UserMode 29 | { 30 | public ModeAway() 31 | : base('a') 32 | { } 33 | 34 | public override bool HandleEvent(CommandBase command, UserInfo user, List args) => true; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/UserModes/ModeInvisible.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Commands; 24 | using IrcD.Core; 25 | 26 | namespace IrcD.Modes.UserModes 27 | { 28 | public class ModeInvisible : UserMode 29 | { 30 | public ModeInvisible() 31 | : base('i') 32 | { } 33 | 34 | public override bool HandleEvent(CommandBase command, UserInfo user, List args) => true; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/UserModes/ModeLocalOperator.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Commands; 24 | using IrcD.Core; 25 | 26 | namespace IrcD.Modes.UserModes 27 | { 28 | class ModeLocalOperator : UserMode 29 | { 30 | public ModeLocalOperator() 31 | : base('O') 32 | { } 33 | 34 | public override bool HandleEvent(CommandBase command, UserInfo user, List args) => true; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/UserModes/ModeOperator.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Commands; 24 | using IrcD.Core; 25 | 26 | namespace IrcD.Modes.UserModes 27 | { 28 | class ModeOperator : UserMode 29 | { 30 | public ModeOperator() 31 | : base('o') 32 | { } 33 | 34 | public override bool HandleEvent(CommandBase command, UserInfo user, List args) => true; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /IrcD.Net/Modes/UserModes/ModeRestricted.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Commands; 24 | using IrcD.Core; 25 | 26 | namespace IrcD.Modes.UserModes 27 | { 28 | public class ModeRestricted : UserMode 29 | { 30 | public ModeRestricted() 31 | : base('r') 32 | { } 33 | 34 | public override bool HandleEvent(CommandBase command, UserInfo user, List args) => true; 35 | } 36 | } -------------------------------------------------------------------------------- /IrcD.Net/Modes/UserModes/ModeWallops.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using IrcD.Commands; 24 | using IrcD.Core; 25 | 26 | namespace IrcD.Modes.UserModes 27 | { 28 | class ModeWallops : UserMode 29 | { 30 | public ModeWallops() 31 | : base('w') 32 | { } 33 | 34 | public override bool HandleEvent(CommandBase command, UserInfo user, List args) => true; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /IrcD.Net/Tools/DateTimeUtils.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | 24 | namespace IrcD.Tools 25 | { 26 | static class DateTimeUtils 27 | { 28 | public static long ToUnixTime(this DateTime dateTime) 29 | { 30 | var span = dateTime - new DateTime(1970, 1, 1); 31 | return (long)span.TotalSeconds; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /IrcD.Net/Tools/EnumDescription.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | 24 | namespace IrcD.Tools 25 | { 26 | public class EnumDescription : Attribute 27 | { 28 | public string Text { get; } 29 | 30 | public EnumDescription(string text) 31 | { 32 | Text = text; 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /IrcD.Net/Tools/EnumExtension.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System; 23 | 24 | namespace IrcD.Tools 25 | { 26 | public static class EnumExtension 27 | { 28 | public static string ToDescription(this Enum enumeration) 29 | { 30 | var type = enumeration.GetType(); 31 | var memInfo = type.GetMember(enumeration.ToString()); 32 | 33 | if (null != memInfo && memInfo.Length > 0) 34 | { 35 | object[] attrs = memInfo[0].GetCustomAttributes(typeof(EnumDescription), false); 36 | if (null != attrs && attrs.Length > 0) 37 | return ((EnumDescription)attrs[0]).Text; 38 | } 39 | 40 | return enumeration.ToString(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /IrcD.Net/Tools/Enumerable.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using System.Text; 25 | 26 | namespace IrcD.Tools 27 | { 28 | public static class Enumerable 29 | { 30 | public static string Concatenate(this IEnumerable strings, string separator) 31 | { 32 | var stringBuilder = new StringBuilder(); 33 | 34 | foreach (var item in strings) 35 | { 36 | stringBuilder.Append(item); 37 | stringBuilder.Append(separator); 38 | } 39 | 40 | stringBuilder.Length = stringBuilder.Length - separator.Length; 41 | return stringBuilder.ToString(); 42 | } 43 | 44 | public static IEnumerable> EachIndex(this IEnumerable collection, int index = 0) 45 | { 46 | return collection.Select(value => new EnumerableIndex { Value = value, Index = index++ }); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /IrcD.Net/Tools/EnumerableIndex.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | namespace IrcD.Tools 23 | { 24 | public class EnumerableIndex 25 | { 26 | public T Value; 27 | public int Index; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /IrcD.Net/Tools/IrcConstants.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | namespace IrcD.Tools 23 | { 24 | public static class IrcConstants 25 | { 26 | public const char CtcpChar = '\x1'; 27 | public const char IrcBold = '\x2'; 28 | public const char IrcColor = '\x3'; 29 | public const char IrcReverse = '\x16'; 30 | public const char IrcNormal = '\xf'; 31 | public const char IrcUnderline = '\x1f'; 32 | public const char CtcpQuoteChar = '\x20'; 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /IrcD.Net/Tools/Logger.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using Pastel; 23 | using System; 24 | using System.Diagnostics; 25 | using System.Drawing; 26 | using System.Text; 27 | 28 | namespace IrcD.Tools 29 | { 30 | public static class Logger 31 | { 32 | public static void Log(string message, int level = 4, string location = null) 33 | { 34 | var stackTrace = new StackTrace(); 35 | var callerFrame = stackTrace.GetFrame(1); 36 | 37 | Console.WriteLine("{0} in {2}: {1}", level, message.Pastel("ffffcc"), location ?? FormatLocation(callerFrame)); 38 | } 39 | 40 | public static string FormatLocation(StackFrame frame) 41 | { 42 | StringBuilder location = new StringBuilder(); 43 | 44 | location.Append(frame.GetMethod().DeclaringType); 45 | location.Append("=>"); 46 | location.Append(frame.GetMethod()); 47 | location.Append(" ["); 48 | location.Append(frame.GetILOffset()); 49 | location.Append(":"); 50 | location.Append(frame.GetNativeOffset()); 51 | location.Append("]"); 52 | 53 | return location.ToString(); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /IrcD.Net/Tools/WildCard.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017 Thomas Bruderer 6 | * Copyright (c) 2005-2009 Davide Icardi, reinux 7 | * 8 | * http://www.codeproject.com/KB/recipes/wildcardtoregex.aspx 9 | * 10 | * No explicit license 11 | */ 12 | 13 | using System; 14 | using System.Text.RegularExpressions; 15 | 16 | namespace IrcD.Tools 17 | { 18 | 19 | /// 20 | /// Represents a wildcard running on the 21 | /// engine. 22 | /// 23 | public class WildCard : Regex 24 | { 25 | /// 26 | /// Initializes a wildcard with the given search pattern. 27 | /// 28 | /// The wildcard pattern to match. 29 | public WildCard(string pattern, WildcardMatch matchType) 30 | : base(WildcardToRegex(pattern, matchType)) 31 | { 32 | } 33 | 34 | /// 35 | /// Initializes a wildcard with the given search pattern and options. 36 | /// 37 | /// The wildcard pattern to match. 38 | /// A combination of one or more 39 | /// . 40 | public WildCard(string pattern, RegexOptions options, WildcardMatch matchType) 41 | : base(WildcardToRegex(pattern, matchType), options) 42 | { 43 | } 44 | 45 | /// 46 | /// Converts a wildcard to a regex. 47 | /// 48 | /// The wildcard pattern to convert. 49 | /// A regex equivalent of the given wildcard. 50 | public static string WildcardToRegex(string pattern, WildcardMatch matchType) 51 | { 52 | string escapedPattern = Escape(pattern); 53 | escapedPattern = escapedPattern.Replace("\\*", ".*"); 54 | escapedPattern = escapedPattern.Replace("\\?", "."); 55 | 56 | return matchType switch 57 | { 58 | WildcardMatch.Exact => "^" + escapedPattern + "$", 59 | WildcardMatch.Anywhere => escapedPattern, 60 | WildcardMatch.StartsWith => "^" + escapedPattern, 61 | WildcardMatch.EndsWith => escapedPattern + "$", 62 | _ => throw new ArgumentOutOfRangeException("matchType"), 63 | }; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /IrcD.Net/Tools/WildcardMatch.cs: -------------------------------------------------------------------------------- 1 | namespace IrcD.Tools 2 | { 3 | public enum WildcardMatch 4 | { 5 | Exact = 0, 6 | Anywhere = 1, 7 | StartsWith = 2, 8 | EndsWith = 3 9 | } 10 | } -------------------------------------------------------------------------------- /IrcD.Net/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /IrcD.Server/Engine.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * The ircd.net project is an IRC deamon implementation for the .NET Plattform 3 | * It should run on both .NET and Mono 4 | * 5 | * Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of ArithmeticParser nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | */ 21 | 22 | using System.Threading; 23 | using IrcD.Core; 24 | using IrcD.Core.Utils; 25 | 26 | namespace IrcD.Server 27 | { 28 | static class Engine 29 | { 30 | private static bool blocking = false; 31 | 32 | public static void Main(string[] args) 33 | { 34 | Run(); 35 | } 36 | 37 | public static void Run() 38 | { 39 | var settings = new Settings(); 40 | var ircDaemon = new IrcDaemon(settings.GetIrcMode()); 41 | settings.SetDaemon(ircDaemon); 42 | settings.LoadSettings(); 43 | 44 | if (blocking) 45 | { 46 | ircDaemon.Start(); 47 | } 48 | else { 49 | ircDaemon.ServerRehash += ServerRehash; 50 | 51 | var serverThread = new Thread(ircDaemon.Start) 52 | { 53 | IsBackground = false, 54 | Name = "serverThread-1" 55 | }; 56 | 57 | serverThread.Start(); 58 | } 59 | } 60 | 61 | static void ServerRehash(object sender, RehashEventArgs e) 62 | { 63 | var settings = new Settings(); 64 | settings.SetDaemon(e.IrcDaemon); 65 | settings.LoadSettings(); 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /IrcD.Server/IrcD.Server.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 9.0 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | PreserveNewest 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /IrcD.Test/Enumerable.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using IrcD.Tools; 3 | using Xunit; 4 | 5 | namespace IrcD.Test 6 | { 7 | public class Enumerable 8 | { 9 | 10 | 11 | [Fact] 12 | public void Concatenate() 13 | { 14 | List listA = new List { 29, 15, 11, 28, 32 }; 15 | 16 | string x = listA.Concatenate(", "); 17 | 18 | Assert.Equal("29, 15, 11, 28, 32", x); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IrcD.Test/IrcD.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 9.0 6 | 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /IrcD.Test/P10Numerics.cs: -------------------------------------------------------------------------------- 1 |  2 | using Xunit; 3 | 4 | namespace IrcD.Test 5 | { 6 | public class P10Numeric 7 | { 8 | [Fact] 9 | public void ServerNumeric() 10 | { 11 | var serverNumeric = new Core.Utils.P10Numeric(0); 12 | Assert.Equal("AA", serverNumeric.ToString()); 13 | Assert.True(serverNumeric.IsServer); 14 | 15 | serverNumeric = new Core.Utils.P10Numeric(4095); 16 | Assert.Equal("]]", serverNumeric.ToString()); 17 | Assert.True(serverNumeric.IsServer); 18 | } 19 | 20 | [Fact] 21 | public void ClientNumeric() 22 | { 23 | var clientNumeric = new Core.Utils.P10Numeric(2, 63); 24 | Assert.Equal("ACAA]", clientNumeric.ToString()); 25 | Assert.False(clientNumeric.IsServer); 26 | 27 | clientNumeric = new Core.Utils.P10Numeric(4095, 262143); 28 | Assert.Equal("]]]]]", clientNumeric.ToString()); 29 | Assert.False(clientNumeric.IsServer); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2017, Thomas Bruderer, apophis@apophis.ch 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of ArithmeticParser nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | IrcD.Net 2 | ======== 3 | 4 | Fully Functional Object Oriented Implementation of IrcD Server. 5 | 6 | [![Build Status](https://travis-ci.org/FreeApophis/ircddotnet.svg?branch=master)](https://travis-ci.org/FreeApophis/ircddotnet) 7 | [![NuGet package](https://buildstats.info/nuget/IrcD.Net)](https://www.nuget.org/packages/IrcD.Net) 8 | 9 | Functionality 10 | ------------- 11 | 12 | * Object Oriented Design, very flexible 13 | * Flexible User and Channel Modes 14 | * Fully RFC Compliant (this breaks some Clients) 15 | * Client Compatibility Modes 16 | * Can translate channels on the fly to the users language via google-translate (Channel Mode +T) 17 | 18 | Limitations 19 | ------------- 20 | 21 | * Single IRC Server only 22 | * No Services 23 | * No flood protection 24 | * No channel protection 25 | * Very basic access control 26 | 27 | 28 | Development 29 | =========== 30 | 31 | Compile on Windows 32 | ------------------ 33 | 34 | * Open VS2010 solution 35 | * If you dont have nunit installed, Unload the Test Project 36 | 37 | Compile On Linux 38 | --------------- 39 | 40 | * Use a Mono 2.10+ 41 | * Run xbuild on the solution file 42 | * IF you don't have nunit installed, remove project from the Solution 43 | 44 | --------------------------------------------------------------------------------