aboutsummaryrefslogtreecommitdiff
path: root/src/network/serveropcodes.cpp
Commit message (Collapse)AuthorAge
* Finalize init packets and enable protocol v25est312015-05-16
| | | | This enables srp.
* Make early protocol auth mechanism generic, and add SRPest312015-05-11
| | | | | | | Adds everything needed for SRP (and everything works too), but still deactivated, as protocol v25 init packets aren't final yet. Can be activated by changing the LATEST_PROTOCOL_VERSION header to 25 inside networkprotocol.h.
* Prepare Protocol v25 init & authentication.Loic Blot2015-03-13
| | | | | | | | | | * TOSERVER_INIT and TOCLIENT_INIT renamed to _LEGACY * TOSERVER_PASSWORD merged from dev-0.5, can use protocol v24 and v25 * TOCLIENT_ACCESS_DENIED merged from dev-0.5, can use protocol v24 and v25, with normalized strings an a custom id for custom errors * new TOSERVER_INIT packet only send MT version, supported compressions, protocols and serialization, this permit to rework everything later without break the _INIT packet * new TOSERVER_AUTH packet which auth the client * new TOCLIENT_HELLO packet which send server serialization version atm * new TOCLIENT_AUTH_ACCEPTED which is send when TOCLIENT_AUTH was okay. After this packet, the client load datas from servers, like after TOCLIENT_INIT_LEGACY packet
* Handle the newly added TOCLIENT_ACCESS_DENIED and ↵Loic Blot2015-03-13
| | | | | | | TOCLIENT_DELETE_PARTICLESPAWNER * Rename the handlers from _Legacy to regular, because here we can use same handlers * Fix some packet names and pseudo handlers
* Rename some packet and handlers to <packet>_Legacy name for compat layer ↵Loic Blot2015-03-13
| | | | between new network changes and old network clients
* [Patch 2/4] Network rework: packet writing, sending and cleanupsLoic Blot2015-02-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NetworkPacket.cpp: * Remove some deprecated functions, we must use streaming interface * m_data converted from u8* to std::vector<u8> * Add an exporter to forge packet to Connection object * implement operator << std::wstring. n * implement operator << std::string * dynamic resize when write packet content. * fix string writing and performances. * create ServerCommandFactory, used by client to get useful informations about packet processing (sending). * Reliability * Transmit channel * Implement putRawString for some ugly char (_INIT packet), and use it. * Many packet read and write migrated * Implement oldForgePacket to interface writing with current connection * fix U8/char/bool writing * fix string writing and performances. * add some missing functions * Use v3s16 read instead of reading x,y,z separately * Add irr::video::SColor support into packets * Add some missing handlers * Add a template function to increase offset * Throw a serialization error on packet reading (must be improved) PacketFactories: * Create ServerCommandFactory, used by client to get useful informations about packet processing (sending). * Create ClientCommandFactory, used by server to get useful informations about packet processing (sending). Client.cpp: * implement NetworkPacket ::Send interface. * Move packet handlers to a dedicated file * Remove Client::Send(SharedBuffer) Server.cpp: * implement NetworkPacket ::Send interface. * Rewrite all packets using NetworkPacket * Move packet handlers to a dedicated file * Remove Server::Send(SharedBuffer) ClientIface.cpp: * Remove sendToAll(SharedBuffer<u8>) Connection.hpp rework: * Remove duplicate include * Remove duplicate negation * Remove a useless variable * Improve code performance by using a m_peers_list instead of scanning m_peers map * Remove Connection::Send(SharedBuffer) * Fix useafterfree into NetworkPacket Sending * Remove unused Connection::sendToAll Test.cpp: * Remove dead code * Update tests to use NetworkPackets Misc: * add new wrappers to Send packets in client, using NetworkPacket * Add NetworkPacket methods for Connection * coding style fix * dead code since changes cleanup * Use v3s16 read instead of reading x,y,z separately in some packets * Use different files to handle packets received by client and server * Cleanup: Remove useless includes ok @Zeno- Tested by @Zeno- @VanessaE and @nerzhul on running servers
* Network Layer 7 rework (Packet handling)Loic Blot2015-02-10
* Move networkcode to a dedicated directory * Rename clientserver.h to network/networkprotocol.h (Better name) and sanitize some includes * Create object NetworkPacket * It stores command (opcode) and data separated * It also stores peer_id * Data reading can be done by using a streaming interface * Change packet routing analysis * Remove old conditional analysis * Now uses function pointed analysis and add connection state ({Client,Server}::handlers) * Connection state permit to categorize condition to handle before analyze packets * Create a handler for depreciated messages, instead of duplicating code
"hl opt">, pos) local def = unittests.list[idx] if not def.player then player = nil elseif player == nil then out_callback(false) return false end if not def.map then pos = nil elseif pos == nil then out_callback(false) return false end local tbegin = core.get_us_time() local function done(status, err) local tend = core.get_us_time() local ms_taken = (tend - tbegin) / 1000 if not status then core.log("error", err) end print(string.format("[%s] %s - %dms", status and "PASS" or "FAIL", def.name, ms_taken)) counters.time = counters.time + ms_taken counters.total = counters.total + 1 if status then counters.passed = counters.passed + 1 end end if def.async then core.log("info", "[unittest] running " .. def.name .. " (async)") def.func(function(err) done(err == nil, err) out_callback(true) end, player, pos) else core.log("info", "[unittest] running " .. def.name) local status, err = pcall(def.func, player, pos) done(status, err) out_callback(true) end return true end local function wait_for_player(callback) if #core.get_connected_players() > 0 then return callback(core.get_connected_players()[1]) end local first = true core.register_on_joinplayer(function(player) if first then callback(player) first = false end end) end local function wait_for_map(player, callback) local check = function() if core.get_node_or_nil(player:get_pos()) ~= nil then callback() else minetest.after(0, check) end end check() end function unittests.run_all() -- This runs in a coroutine so it uses await(). local counters = { time = 0, total = 0, passed = 0 } -- Run standalone tests first for idx = 1, #unittests.list do local def = unittests.list[idx] def.done = await(function(cb) unittests.run_one(idx, counters, cb, nil, nil) end) end -- Wait for a player to join, run tests that require a player local player = await(wait_for_player) for idx = 1, #unittests.list do local def = unittests.list[idx] if not def.done then def.done = await(function(cb) unittests.run_one(idx, counters, cb, player, nil) end) end end -- Wait for the world to generate/load, run tests that require map access await(function(cb) wait_for_map(player, cb) end) local pos = vector.round(player:get_pos()) for idx = 1, #unittests.list do local def = unittests.list[idx] if not def.done then def.done = await(function(cb) unittests.run_one(idx, counters, cb, player, pos) end) end end -- Print stats assert(#unittests.list == counters.total) print(string.rep("+", 80)) print(string.format("Unit Test Results: %s", counters.total == counters.passed and "PASSED" or "FAILED")) print(string.format(" %d / %d failed tests.", counters.total - counters.passed, counters.total)) print(string.format(" Testing took %dms total.", counters.time)) print(string.rep("+", 80)) unittests.on_finished(counters.total == counters.passed) return counters.total == counters.passed end -------------- local modpath = minetest.get_modpath("unittests") dofile(modpath .. "/misc.lua") dofile(modpath .. "/player.lua") dofile(modpath .. "/crafting.lua") dofile(modpath .. "/itemdescription.lua") -------------- if core.settings:get_bool("devtest_unittests_autostart", false) then core.after(0, function() coroutine.wrap(unittests.run_all)() end) else minetest.register_chatcommand("unittests", { privs = {basic_privs=true}, description = "Runs devtest unittests (may modify player or map state)", func = function(name, param) unittests.on_finished = function(ok) core.chat_send_player(name, (ok and "All tests passed." or "There were test failures.") .. " Check the console for detailed output.") end coroutine.wrap(unittests.run_all)() return true, "" end, }) end