X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fuid.h;h=c00161cac2104a533df6dc2762b8c390552ee5c7;hb=c05f81cac83e80c7727594e3929e0709eccca689;hp=d3b1d1fa9bd8140632a6d3089a26d7c47c04ce87;hpb=cd712c40e1b352c05e7ae0f72e0a5e84cdf64323;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/uid.h b/include/uid.h index d3b1d1fa9..c00161cac 100644 --- a/include/uid.h +++ b/include/uid.h @@ -1,21 +1,59 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2013, 2019 Sadie Powell + * Copyright (C) 2013 Attila Molnar + * Copyright (C) 2012 Robby + * Copyright (C) 2010 Craig Edwards + * Copyright (C) 2007 Robin Burchell * - * This program is free but copyrighted software; see - * the file COPYING for details. + * 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 + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -/** - * This is the maximum length of a UUID (unique user identifier). - * This length is set in compliance with TS6 protocol, and really should not be changed. Ever. - * It allows for a lot of clients as-is. -- w00t. - */ -#define UUID_LENGTH 10 +#pragma once + +class CoreExport UIDGenerator +{ + private: + /** Holds the current UID. Used to generate the next one. + */ + std::string current_uid; + + /** Increments the current UID by one. + */ + void IncrementUID(unsigned int pos); + + public: + /** + * This is the maximum length of a UUID (unique user identifier). + * It allows up to 12,960 servers and 2,176,782,336 users per server. + */ + static const unsigned int UUID_LENGTH = 9; + + /** Initializes this UID generator with the given SID + * @param sid SID that conforms to InspIRCd::IsSID() + */ + void init(const std::string& sid); + /** Returns the next available UID for this server. + */ + std::string GetUID(); + /** Generates a pseudorandom SID based on a servername and a description + * Guaranteed to return the same if invoked with the same parameters + * @param servername The server name to use as seed + * @param serverdesc The server description to use as seed + * @return A valid SID + */ + static std::string GenerateSID(const std::string& servername, const std::string& serverdesc); +};