diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-06-22 16:05:02 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-06-22 16:05:02 +0200 |
commit | c13cffcd30da6b7f4e040de935d5958a30326f8c (patch) | |
tree | 7967052d180cad38d4c10981241f9b98ec5000b9 /src/ClientHandle.cpp | |
parent | Fixed another daylight sensor bug (diff) | |
parent | Fixed missing break (diff) | |
download | cuberite-c13cffcd30da6b7f4e040de935d5958a30326f8c.tar cuberite-c13cffcd30da6b7f4e040de935d5958a30326f8c.tar.gz cuberite-c13cffcd30da6b7f4e040de935d5958a30326f8c.tar.bz2 cuberite-c13cffcd30da6b7f4e040de935d5958a30326f8c.tar.lz cuberite-c13cffcd30da6b7f4e040de935d5958a30326f8c.tar.xz cuberite-c13cffcd30da6b7f4e040de935d5958a30326f8c.tar.zst cuberite-c13cffcd30da6b7f4e040de935d5958a30326f8c.zip |
Diffstat (limited to 'src/ClientHandle.cpp')
-rw-r--r-- | src/ClientHandle.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index ade7e20ac..46083a8f1 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -232,6 +232,9 @@ AString cClientHandle::FormatMessageType(bool ShouldAppendChatPrefixes, eMessage AString cClientHandle::GenerateOfflineUUID(const AString & a_Username) { + // Online UUIDs are always version 4 (random) + // We use Version 3 (MD5 hash) UUIDs for the offline UUIDs + // This guarantees that they will never collide with an online UUID and can be distinguished. // Proper format for a version 3 UUID is: // xxxxxxxx-xxxx-3xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, A, or B @@ -254,6 +257,32 @@ AString cClientHandle::GenerateOfflineUUID(const AString & a_Username) +bool cClientHandle::IsUUIDOnline(const AString & a_UUID) +{ + // Online UUIDs are always version 4 (random) + // We use Version 3 (MD5 hash) UUIDs for the offline UUIDs + // This guarantees that they will never collide with an online UUID and can be distinguished. + // The version-specifying char is at pos #12 of raw UUID, pos #14 in dashed-UUID. + switch (a_UUID.size()) + { + case 32: + { + // This is the UUID format without dashes, the version char is at pos #12: + return (a_UUID[12] == '4'); + } + case 36: + { + // This is the UUID format with dashes, the version char is at pos #14: + return (a_UUID[14] == '4'); + } + } + return false; +} + + + + + void cClientHandle::Kick(const AString & a_Reason) { if (m_State >= csAuthenticating) // Don't log pings |