X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Finspircd.h;h=b0e9903f24752ef533b13e6a24fbb9431eb55419;hb=952ee5cc603a5231348b8cfab18ee85a097f5394;hp=0f73f192fe2e5540d8761b561d51dc91a90a80e3;hpb=454c8d374955d2ffb3ec1fca39a6efc32032c649;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/inspircd.h b/include/inspircd.h index 0f73f192f..b0e9903f2 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -1,13 +1,19 @@ /* * InspIRCd -- Internet Relay Chat Daemon * - * Copyright (C) 2009 Daniel De Graaf + * Copyright (C) 2019 Matt Schatz + * Copyright (C) 2018 linuxdaemon + * Copyright (C) 2013 Daniel Vassdal + * Copyright (C) 2012-2016, 2018 Attila Molnar + * Copyright (C) 2012-2014, 2017-2019 Sadie Powell + * Copyright (C) 2012, 2019 Robby + * Copyright (C) 2012 ChrisTX + * Copyright (C) 2009-2010 Daniel De Graaf + * Copyright (C) 2008 Thomas Stagner + * Copyright (C) 2007-2009 Dennis Friis * Copyright (C) 2007-2008 Robin Burchell - * Copyright (C) 2008 Pippijn van Steenhoven - * Copyright (C) 2003-2008 Craig Edwards - * Copyright (C) 2006-2007 Oliver Lupton - * Copyright (C) 2007 Dennis Friis - * Copyright (C) 2003 randomdan + * Copyright (C) 2007 Oliver Lupton + * Copyright (C) 2005-2008, 2010 Craig Edwards * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -25,6 +31,11 @@ #pragma once +// If the system has a pre-C11 stdint header this must be defined in +// order to use the numeric limit macros. +#define __STDC_LIMIT_MACROS + +#include #include #include #include @@ -49,6 +60,7 @@ #include "compat.h" #include "aligned_storage.h" #include "typedefs.h" +#include "convto.h" #include "stdalgo.h" CoreExport extern InspIRCd* ServerInstance; @@ -65,12 +77,13 @@ struct fakederef }; #include "config.h" -#include "convto.h" #include "dynref.h" #include "consolecolors.h" #include "cull_list.h" +#include "serialize.h" #include "extensible.h" #include "fileutils.h" +#include "ctables.h" #include "numerics.h" #include "numeric.h" #include "uid.h" @@ -82,7 +95,6 @@ struct fakederef #include "logger.h" #include "usermanager.h" #include "socket.h" -#include "ctables.h" #include "command_parse.h" #include "mode.h" #include "socketengine.h" @@ -90,6 +102,7 @@ struct fakederef #include "filelogger.h" #include "message.h" #include "modules.h" +#include "clientprotocol.h" #include "threadengine.h" #include "configreader.h" #include "inspstring.h" @@ -174,15 +187,6 @@ class serverstats class CoreExport InspIRCd { private: - /** Set up the signal handlers - */ - void SetSignals(); - - /** Daemonize the ircd and close standard input/output streams - * @return True if the program daemonized succesfully - */ - bool DaemonSeed(); - /** The current time, updated in the mainloop */ struct timespec TIME; @@ -192,10 +196,7 @@ class CoreExport InspIRCd */ char ReadBuffer[65535]; - /** Check we aren't running as root, and exit if we are - * with exit code EXIT_STATUS_ROOT. - */ - void CheckRoot(); + ClientProtocol::RFCEvents rfcevents; public: @@ -211,7 +212,7 @@ class CoreExport InspIRCd * Reason for it: * kludge alert! * SendMode expects a User* to send the numeric replies - * back to, so we create it a fake user that isnt in the user + * back to, so we create it a fake user that isn't in the user * hash and set its descriptor to FD_MAGIC_NUMBER so the data * falls into the abyss :p */ @@ -280,7 +281,7 @@ class CoreExport InspIRCd */ TimerManager Timers; - /** X-Line manager. Handles G/K/Q/E line setting, removal and matching + /** X-line manager. Handles G/K/Q/E-line setting, removal and matching */ XLineManager* XLines; @@ -296,7 +297,7 @@ class CoreExport InspIRCd */ std::vector ports; - /** Set to the current signal recieved + /** Set to the current signal received */ static sig_atomic_t s_signal; @@ -343,10 +344,17 @@ class CoreExport InspIRCd */ static void DefaultGenRandom(char* output, size_t max); + /** Bind to a specific port from a config tag. + * @param tag the tag that contains bind information. + * @param sa The endpoint to listen on. + * @param old_ports Previously listening ports that may be on the same endpoint. + */ + bool BindPort(ConfigTag* tag, const irc::sockets::sockaddrs& sa, std::vector& old_ports); + /** Bind all ports specified in the configuration file. * @return The number of ports bound without error */ - int BindPorts(FailedPortList &failed_ports); + size_t BindPorts(FailedPortList &failed_ports); /** Find a user in the nick hash. * If the user cant be found in the nick hash check the uuid hash @@ -380,18 +388,24 @@ class CoreExport InspIRCd */ static bool DefaultIsChannel(const std::string& channel); + /** Determines whether a hostname is valid according to RFC 5891 rules. + * @param host The hostname to validate. + * @return True if the hostname is valid; otherwise, false. + */ + static bool IsHost(const std::string& host); + /** Return true if str looks like a server ID * @param sid string to check against */ static bool IsSID(const std::string& sid); /** Handles incoming signals after being set - * @param signal the signal recieved + * @param signal the signal received */ void SignalHandler(int signal); - /** Sets the signal recieved - * @param signal the signal recieved + /** Sets the signal received + * @param signal the signal received */ static void SetSignal(int signal); @@ -485,6 +499,26 @@ class CoreExport InspIRCd */ static unsigned long Duration(const std::string& str); + /** Calculate a duration in seconds from a string in the form 1y2w3d4h6m5s + * @param str A string containing a time in the form 1y2w3d4h6m5s + * (one year, two weeks, three days, four hours, six minutes and five seconds) + * @param duration The location to place the parsed duration valur + * @return Whether the duration was a valid format or not + */ + static bool Duration(const std::string& str, unsigned long& duration); + + /** Determines whether a string contains a valid duration. + * @param str A string containing a time in the form 1y2w3d4h6m5s + * @return True if the string is a valid duration; otherwise, false. + */ + static bool IsValidDuration(const std::string& str); + + /** Return a duration in seconds as a human-readable string. + * @param duration The duration in seconds to convert to a human-readable string. + * @return A string representing the given duration. + */ + static std::string DurationString(time_t duration); + /** Attempt to compare a password to a string from the config file. * This will be passed to handling modules which will compare the data * against possible hashed equivalents in the input string. @@ -504,7 +538,6 @@ class CoreExport InspIRCd /** Attempt to write the process id to a given file * @param filename The PID file to attempt to write to * @param exitonfail If true and the PID fail cannot be written log to stdout and exit, otherwise only log on failure - * @return This function may bail if the file cannot be written */ void WritePID(const std::string& filename, bool exitonfail = true); @@ -551,30 +584,30 @@ class CoreExport InspIRCd { return this->ReadBuffer; } + + ClientProtocol::RFCEvents& GetRFCEvents() { return rfcevents; } }; ENTRYPOINT; -template -class CommandModule : public Module -{ - Cmd cmd; - public: - CommandModule() : cmd(this) - { - } - - Version GetVersion() CXX11_OVERRIDE - { - return Version(cmd.name, VF_VENDOR|VF_CORE); - } -}; - inline void stdalgo::culldeleter::operator()(classbase* item) { if (item) ServerInstance->GlobalCulls.AddItem(item); } +inline void Channel::Write(ClientProtocol::EventProvider& protoevprov, ClientProtocol::Message& msg, char status, const CUList& except_list) +{ + ClientProtocol::Event event(protoevprov, msg); + Write(event, status, except_list); +} + +inline void LocalUser::Send(ClientProtocol::EventProvider& protoevprov, ClientProtocol::Message& msg) +{ + ClientProtocol::Event event(protoevprov, msg); + Send(event); +} + #include "numericbuilder.h" -#include "modules/whois.h" +#include "clientprotocolmsg.h" +#include "clientprotocolevent.h"