1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2019-2020 Sadie Powell <sadie@witchery.services>
5  *   Copyright (C) 2018 Matt Schatz <genius3000@g3k.solutions>
6  *   Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
7  *
8  * This file is part of InspIRCd.  InspIRCd is free software: you can
9  * redistribute it and/or modify it under the terms of the GNU General Public
10  * License as published by the Free Software Foundation, version 2.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 #pragma once
23 
24 class CoreExport Server : public classbase
25 {
26  protected:
27 	/** The unique identifier for this server. */
28 	const std::string id;
29 
30 	/** The name of this server
31 	 */
32 	const std::string name;
33 
34 	/** The description of this server.
35 	 * This can be updated by the protocol module (for remote servers) or by a rehash (for the local server).
36 	 */
37 	std::string description;
38 
39 	/** True if this server is ulined
40 	 */
41 	bool uline;
42 
43 	/** True if this server is a silent uline, i.e. silent="yes" in the uline block
44 	 */
45 	bool silentuline;
46 
47 	/** Allow ConfigReaderThread to update the description on a rehash
48 	 */
49 	friend class ConfigReaderThread;
50 
51  public:
Server(const std::string & srvid,const std::string & srvname,const std::string & srvdesc)52 	Server(const std::string& srvid, const std::string& srvname, const std::string& srvdesc)
53 		: id(srvid)
54 		, name(srvname)
55 		, description(srvdesc)
56 		, uline(false)
57 		, silentuline(false)
58 	{
59 	}
60 
DEPRECATED_METHOD(Server (const std::string & srvname,const std::string & srvdesc))61 	DEPRECATED_METHOD(Server(const std::string& srvname, const std::string& srvdesc))
62 		: name(srvname)
63 		, description(srvdesc)
64 		, uline(false)
65 		, silentuline(false)
66 	{
67 	}
68 
69 	/** Retrieves the unique identifier for this server (e.g. 36C). */
GetId()70 	const std::string& GetId() const { return id; }
71 
72 	/**
73 	 * Returns the name of this server
74 	 * @return The name of this server, for example "irc.inspircd.org".
75 	 */
GetName()76 	const std::string& GetName() const { return name; }
77 
78 	/** Returns the description of this server
79 	 * @return The description of this server
80 	 */
GetDesc()81 	const std::string& GetDesc() const { return description; }
82 
83 	/**
84 	 * Checks whether this server is ulined
85 	 * @return True if this server is ulined, false otherwise.
86 	 */
IsULine()87 	bool IsULine() const { return uline; }
88 
89 	/**
90 	 * Checks whether this server is a silent uline
91 	 * Silent uline servers introduce, quit and oper up users without a snotice being generated.
92 	 * @return True if this server is a silent uline, false otherwise.
93 	 */
IsSilentULine()94 	bool IsSilentULine() const { return silentuline; }
95 };
96