diff options
author | madmaxoft <github@xoft.cz> | 2014-06-21 22:13:35 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-06-21 22:13:35 +0200 |
commit | 08fed2a213f40e963ef871664439d744faefffba (patch) | |
tree | da4ef449fe2c19b46d2c32470869298ea45d492c /src/ClientHandle.cpp | |
parent | Restored style continuity. (diff) | |
download | cuberite-08fed2a213f40e963ef871664439d744faefffba.tar cuberite-08fed2a213f40e963ef871664439d744faefffba.tar.gz cuberite-08fed2a213f40e963ef871664439d744faefffba.tar.bz2 cuberite-08fed2a213f40e963ef871664439d744faefffba.tar.lz cuberite-08fed2a213f40e963ef871664439d744faefffba.tar.xz cuberite-08fed2a213f40e963ef871664439d744faefffba.tar.zst cuberite-08fed2a213f40e963ef871664439d744faefffba.zip |
Diffstat (limited to '')
-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 |