New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Forge protocol handshake support #3869
Merged
Merged
Changes from 167 commits
Commits
Show all changes
180 commits
Select commit
Hold shift + click to select a range
a53734e
Send modinfo/modList in 1.12 ping response
satoshinm 376c525
Refactor to new ForgeHandshake class
satoshinm 5f4f050
Add modinfo to ping response of all protocol versions
satoshinm 24adfe9
Move cForgeHandshake to instance variable of Protocol
satoshinm 2c0dd69
Detect Forge client connection (\0FML\0 in server name)
satoshinm c6eff1d
Send plugin channel registration to Forge client after login success
satoshinm e73c227
Refactor sending plugin channels into cForgeHandshake::onLoginSuccess
satoshinm 3950cda
Send FML|HS ServerHello to Forge clients
satoshinm 60fedd7
Listen for FML|HS in ForgeDataReceived, client hello
satoshinm 9dc47b2
Move cForgeHandshake instance to cClientHandle to fix duplication cau…
satoshinm 506bebd
Fix recognizing FML protocol version 2 in ClientHello field
satoshinm e299ad3
Add m_Client member to m_ForgeHandshake, move from parameters
satoshinm 62b57cc
Send client modlist back in server modlist packet
satoshinm 91e908d
Send encoded server ModList
satoshinm 86d8c27
Receive HandshakeAck packets with phase byte
satoshinm 3b0dbab
Simplify ForgeHandshake switch on discriminator
satoshinm f9b337b
Call BeginForgeHandshake() in cClientHandle::Authenticate() instead
satoshinm 31887fd
Try using a cCriticalSection, but not locked by current thread
satoshinm 40551e1
Remove broken m_CSLock in cForgeHandshake
satoshinm ad5cb68
Move second half of Authenticate into PostAuthenticate
satoshinm 8969bd6
cForgeHandshake calls PostAuthenticate after completing
satoshinm 61d1919
Add missing SendServerHello() in BeginForgeHandshake()
satoshinm bff3bc7
Add missing ForgeHandshake.h
satoshinm 1fe784e
Fixed signedness error in discriminator, -1 not 255
satoshinm 6906315
Rename PostAuthenticate to FinishAuthenticate since it actually sets …
satoshinm 367f2c1
Implement the pending/completion acknowledgments, send stub registry
satoshinm 6b73390
Use a valid registry id name, potions
satoshinm 3c5fca7
Remove semi-unused Stage enum
satoshinm 442d8f1
Fix signedness compile errors in counts in RegistryData
satoshinm 8b1eac5
Add missing break in case Discriminator_HandshakeAck
satoshinm d0a5426
Parse number of mods from client ModList
satoshinm 7fac624
Parse mod name/version from client ModList
satoshinm 934c8a3
Show client mod list on connecting, AStringMap
satoshinm b174347
Merge branch 'master' into forge
satoshinm 07f82d1
Add HOOK_PLAYER_FORGE_MODS Lua API hook, call with mods, allow plugin…
satoshinm 2813628
Add new cForgeMods class representing a list of Forge mods+versions
satoshinm ead2601
Try to document GetForgeMods()
satoshinm 66c52f0
Move // tolua_end comment to end of file
satoshinm a12fa5d
Remove unbridgeable AStringMap mods list from HOOK_PLAYER_FORGE_MODS …
satoshinm d669b75
Rename hook to HOOK_LOGIN_FORGE
satoshinm df6e37f
Add cForgeMods to Lua plugins bindings
satoshinm bf5f211
Pass protocol version string to AugmentServerListPing()
satoshinm f2d6ec1
Revert "Pass protocol version string to AugmentServerListPing()"
satoshinm b916c77
Log protocol version received in augmentServerListPing() - available …
satoshinm 5b86899
Fix capitalization of AugmentServerListPing()
satoshinm 734de89
Add RegisterForgeMod() Lua API to cServer
satoshinm 2b33a30
Change RegisterForgeMod() to register for all versions, add RegisterF…
satoshinm 02dc012
Server ping list doesn't include modinfo unless Forge mods were regis…
satoshinm c8f5b14
Remove some unnecessary whitespace changes
satoshinm 6705990
Revert submodule Core checkout change
satoshinm 280113e
Add cClientHandle IsModded()
satoshinm 8910218
Revert unnecessary whitespace changes
satoshinm c2c575e
Remove outdated comment
satoshinm 78a094e
Add documentation for new Lua API
satoshinm d7f8fe9
Add cServer mod registration Lua API documentation
satoshinm 117a555
Add mod unregistration APIs
satoshinm 8af34c0
Remove another outdated comment (unmodded checked above)
satoshinm 81d4d71
Rename to HasMods clarifying no mods on server, versus modded but pos…
satoshinm caafd12
Send plugin-registered server-side Forge mods in FML|HS ModList packet
satoshinm 3158c15
Fix cForgeMods Remove() iterator erasing from versions vector
satoshinm 2950468
Fix trailing whitespace style violations
satoshinm e865cf7
Fixed signedness errors not caught with Xcode cmake target
satoshinm 82caf1b
Fix style violations in ForgeHandshake and ForgeMods
satoshinm e70b0f3
Fix remaining style violations caught by src/CheckBasicStyle.lua
satoshinm 46593e3
Fix capitalization on m_IsForgeClient member variable
satoshinm 6c2d177
Fix new variable names to CamelCase convention
satoshinm 44bc3b8
Merge branch 'master' into forge
satoshinm 789a545
Remove cForgeMods::GetModVersionAt(), use GetModVersion() instead
satoshinm 12117fb
Fix top-level 5 empty line whitespace in cForgeHandshake
satoshinm 02915d6
Change to map data structure for m_ForgeModsByVersion instead of indi…
satoshinm 82e2fdd
Rename IsModded -> IsForgeClient
satoshinm b58aae7
Alpha-sort the PluginManager hook list for HOOK_LOGIN_FORGE
satoshinm 3749574
Initialize m_ForgeMods pointer with nullptr instead of 0 integer
satoshinm 0cb1ed5
Alpha-sort src/Protocol/CMakeLists new Forge files
satoshinm 0a2c0e6
cForgeHandshake constructor initialization list on separate lines
satoshinm 6ca813a
Clean up ModList parsing, pass only payload and add length check
satoshinm 6da327f
Add whitespace before ForgeHandshake class definition
satoshinm 859acae
Move enums into ForgeHandshake implementation file, not part of inter…
satoshinm a3fa137
Comment and whitespace on cProtocol::ForgeDataReceived
satoshinm 6e9fc39
Merge branch 'master' into forge
satoshinm 688ba2d
Add documentation for HOOK_LOGIN_FORGE
satoshinm 2ce1ddc
Change cClientHandle cForgeMods to std::unique_ptr
satoshinm a3ee324
Change fixed handshake channels list from vector to std::array
satoshinm f3a8b58
Change to use uniform initialization insert() on string maps
satoshinm 9e5cbe2
Change cForgeMods AString params to const AString
satoshinm fa7e152
Check Buf.ReadVar return values in ForgeHandshake parsing
satoshinm 66975f8
Fix double copy in cForgeMods constructor, pass by reference
satoshinm 222ac0e
Merge branch 'master' into forge
satoshinm 276918d
Forge mod registration checks success, prevent duplicate regresion
satoshinm 981486f
Manually bind RegisterForgeMod to throw Lua exception on failure
satoshinm d7e5e58
Remove all-protocol Forge mod registration, rename per-proto to Regis…
satoshinm 3868658
Simplify using GetStackValues() in manual binding for tolua_cServer_R…
satoshinm 343467b
Revert accidental whitespace change in tolua_cScoreboard_GetTeamNames
satoshinm 094a4e7
Remove unnecessary nullptr check before m_ForgeMods.reset()
satoshinm 2da145c
Remove cProtocol::ForgeDataReceived(), unnecessary indirection
satoshinm 8823e39
Privitize m_ForgeMods and m_ForgeHandshake
satoshinm 7be5d61
Move member variables after typedef
satoshinm 19026b9
enum Discriminator: signed char, Discriminator_ -> Discriminator::
satoshinm 4401a75
a_ prefix on cForgeHandshake constructor
satoshinm ed6acb7
size_t format specifier: %zu -> SIZE_T_FMT
satoshinm 935bebc
Tone down logging in ParseModList, debug log only errors
satoshinm 5109370
Remove empty lines in ForgeHandshake, more logical block grouping
satoshinm bc3adb6
Refactor cForgeHandshake::DataReceived into Handle* functions
satoshinm f7b6d3a
Merge branch 'master' into forge
satoshinm 9dfb124
Fix initialization error in file Plugins/APIDump/APIDesc.lua: 2 (Plug…
satoshinm ab62461
Revert enum Discriminator: signed char, Discriminator_ -> Discriminat…
satoshinm 4c59531
Try changing Discriminator to an 'enum class'
satoshinm e10e3ff
Change client/server phase to enum classes
satoshinm db5956d
Revert "Change client/server phase to enum classes" (gcc fail)
satoshinm 342056d
Revert "Try changing Discriminator to an 'enum class'" (gcc fail)
satoshinm cd07cd1
Initialize m_ForgeModsByVersion on-demand when each version is requested
satoshinm bfb4b7a
Add doxy comment for GetRegisteredForgeMods()
satoshinm 7a7992b
Remove cForgeMods in registration, use AStringMap
satoshinm 2d63362
Remove cForgeMods in ClientHandle, use AStringMap
satoshinm f547136
Remove cForgeMods class in favor of AStringMap
satoshinm abd295f
APIDesc: GetForgeMods() returns table (Lua), =C++ AStringMap?
satoshinm c01c9ff
(Incomplete) Try to bridge GetForgeMods AStringMap -> Lua table
satoshinm 4aea032
Copy saved values by value for BeginForgeHandshake(), not ptr
satoshinm d360dd3
Fix m_Properties copy (curiously only clang on Travis caught this...)
satoshinm ee58733
Restore cForgeMods until I can properly bridge AStringMap to Lua table
satoshinm ee630a2
Revert "Restore cForgeMods until I can properly bridge AStringMap to …
satoshinm cc8ca32
Fix tolua_cClientHandle_GetForgeMods() return value 1
satoshinm 8e8db6c
LOGD when Forge client connected
satoshinm 8fffcb3
Fix tolua_cServer_RegisterForgeMod, it doesn't return a value
satoshinm 0bd28f3
static const registration channels array
satoshinm 6040fe5
Merge branch 'master' into forge
satoshinm 60a5a47
Fix comment, PostAuthenticate was renamed FinishAuthenticate
satoshinm 33bdcea
LOGD commonplace ForgeHandshake messages
satoshinm bd5f1c9
Pass mods AStringMap param to Forge login hook
satoshinm 67b2570
Use namespaces for discriminator and phase constants
satoshinm 3f0926b
Merge branch 'master' into forge
satoshinm 87435ce
Change cClientHandle m_ForgeMods to value, remove pointer
satoshinm a51b606
Update plugin Core from master branch
satoshinm 4d25690
Use CheckParamSelf() in manual bindings, remove now-unnecessary null …
satoshinm 9884d27
Use GetStackValue() instead of reinterpret_cast<cClientHandle *>(tolu…
satoshinm ea7f421
Alpha-sort manual bindings cClientHandle and add blank line to separa…
satoshinm 1bf7c3d
Spaces around i = in ModList parse debugging message
satoshinm c45d6a7
Fix ClientHello error message, unexpected length not only short
satoshinm d7ccda1
Space after & in auto &
satoshinm d5390be
Fix finishing login in ClientPhase::COMPLETE ack, and catch unknown p…
satoshinm 1c5a48a
Single-line cases in Discriminator switch
satoshinm 716fa0a
Merge branch 'master' into forge
satoshinm 1a7f587
Change to use 'auto' everywhere possible
satoshinm ef94a24
Change SetError() to variadic macro SET_HANDSHAKE_ERROR()
satoshinm df5be52
Merge branch 'master' into forge
satoshinm 254b339
Change to SetError(Printf()) removing variadic macro
satoshinm de1cf38
Fix checking errored state and add SetError() documentation
satoshinm abf00ed
Merge branch 'master' into forge
satoshinm 5cbdbd2
Fix cByteBuffer definition error from latest merge
satoshinm 44bf20e
Style: remove indent for if condition in tolua_cClientHandle_GetForge…
satoshinm 68b9a11
Remove unnecessary Mods variable in tolua_cClientHandle_GetForgeMods
satoshinm e7f1ccd
Change .size() == 0 to .empty()
satoshinm 620b68b
Spaces around '=' in ParseModList error message
satoshinm 8035bff
Loop induction variable UInt32 to match NumMods not size_t
satoshinm ab7910b
Scale max ModList buffer size to 256 bytes per mod
satoshinm c61d209
Consts in HandleModList
satoshinm 1dd19be
Comment field names instead of variables
satoshinm b0cd907
Space around '=' with phase
satoshinm d89917f
Remove logging binary data in cForgeHandshake::DataReceived
satoshinm ab61bcb
Remove unnecessary forward declaration of Json in ForgeHandshake
satoshinm c5908ed
Move data members above functions in cForgeHandshake
satoshinm d34632a
Move ClientHandle include to Protocol_1_10 where it is used
satoshinm f6307c5
Whitespace around tolua comments Server.h
satoshinm c2645db
Merge branch 'master' into forge
satoshinm aa596db
const GetRegisteredForgeMods() and add private non-const accessor
satoshinm 68d0782
Revert "const GetRegisteredForgeMods() and add private non-const acce…
satoshinm 9de99fe
const GetRegisteredForgeMods() and add private non-const accessor
satoshinm 16ca36b
Merge branch 'master' into forge
satoshinm 0737594
Augment server ping for 1.12.1 protocol for Forge
satoshinm bc28d90
Merge branch 'master' into forge
satoshinm a466173
Fix duplicate CompositeChat.h inclusion in ManualBindings
satoshinm 63a0f40
Fix ManualBindings merge
satoshinm c169ec9
Fix UUID type, now cUUID not AString
satoshinm b4056d5
Encode Forge ServerHello using cByteBuffer
satoshinm 6cd0545
Change mod list string to use AppendPrintf
satoshinm 6642288
Fix five lines spacing after CallHookLoginForge()
satoshinm 9a9f612
Add const to AString references in (Un)registerForgeMod
satoshinm b8e5b3f
Enhance documentation string for m_ForgeModsByVersion
satoshinm b6570d8
Enhance documentation string for GetRegisteredForgeMods, detail map
satoshinm 13ef3a6
Merge branch 'master' into forge
satoshinm File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
#include "../Generating/ChunkDesc.h" | ||
#include "../LineBlockTracer.h" | ||
#include "../CompositeChat.h" | ||
#include "../Server.h" | ||
#include "../StringCompression.h" | ||
#include "../CommandOutput.h" | ||
#include "../BuildInfo.h" | ||
|
@@ -2342,6 +2343,28 @@ static int tolua_cClientHandle_SendPluginMessage(lua_State * L) | |
|
||
|
||
|
||
static int tolua_cClientHandle_GetForgeMods(lua_State * L) | ||
{ | ||
cLuaState S(L); | ||
if ( | ||
!S.CheckParamSelf("cClientHandle") || | ||
!S.CheckParamEnd(2) | ||
) | ||
{ | ||
return 0; | ||
} | ||
cClientHandle * Client; | ||
S.GetStackValue(1, Client); | ||
|
||
S.Push(Client->GetForgeMods()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the unneeded |
||
return 1; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
static int tolua_cMojangAPI_AddPlayerNameToUUIDMapping(lua_State * L) | ||
{ | ||
cLuaState S(L); | ||
|
@@ -3133,6 +3156,37 @@ static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S) | |
|
||
|
||
|
||
static int tolua_cServer_RegisterForgeMod(lua_State * a_LuaState) | ||
{ | ||
cLuaState L(a_LuaState); | ||
if ( | ||
!L.CheckParamSelf("cServer") || | ||
!L.CheckParamString(2, 3) || | ||
!L.CheckParamNumber(4) || | ||
!L.CheckParamEnd(5) | ||
) | ||
{ | ||
return 0; | ||
} | ||
|
||
cServer * Server; | ||
AString Name, Version; | ||
UInt32 Protocol; | ||
L.GetStackValues(1, Server, Name, Version, Protocol); | ||
|
||
if (!Server->RegisterForgeMod(Name, Version, Protocol)) | ||
{ | ||
tolua_error(L, "duplicate Forge mod name registration", nullptr); | ||
return 0; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
static int tolua_cScoreboard_GetTeamNames(lua_State * L) | ||
{ | ||
cLuaState S(L); | ||
|
@@ -3741,6 +3795,8 @@ void cManualBindings::Bind(lua_State * tolua_S) | |
tolua_beginmodule(tolua_S, "cClientHandle"); | ||
tolua_constant(tolua_S, "MAX_VIEW_DISTANCE", cClientHandle::MAX_VIEW_DISTANCE); | ||
tolua_constant(tolua_S, "MIN_VIEW_DISTANCE", cClientHandle::MIN_VIEW_DISTANCE); | ||
|
||
tolua_function(tolua_S, "GetForgeMods", tolua_cClientHandle_GetForgeMods); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alpha-sort the (two) functions. Perhaps add an empty line to separate the functions from the constants. |
||
tolua_function(tolua_S, "SendPluginMessage", tolua_cClientHandle_SendPluginMessage); | ||
tolua_endmodule(tolua_S); | ||
|
||
|
@@ -3884,6 +3940,10 @@ void cManualBindings::Bind(lua_State * tolua_S) | |
tolua_function(tolua_S, "GetTeamNames", tolua_cScoreboard_GetTeamNames); | ||
tolua_endmodule(tolua_S); | ||
|
||
tolua_beginmodule(tolua_S, "cServer"); | ||
tolua_function(tolua_S, "RegisterForgeMod", tolua_cServer_RegisterForgeMod); | ||
tolua_endmodule(tolua_S); | ||
|
||
tolua_beginmodule(tolua_S, "cStringCompression"); | ||
tolua_function(tolua_S, "CompressStringZLIB", tolua_CompressStringZLIB); | ||
tolua_function(tolua_S, "UncompressStringZLIB", tolua_UncompressStringZLIB); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be Forge-specific, or (future-proofing) would this mean any client-side mod? Perhaps consider renaming to indicate Forge-specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forge-specific, or technically, if the "Forge Mod Loader" is installed on the client which is a part of Forge. Won't pick up LiteLoader or other loaders, or other non-loader mods. Renamed IsModded to "IsForgeClient", a clearer description.