aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp5
-rw-r--r--src/clientiface.h4
-rw-r--r--src/network/clientpackethandler.cpp19
-rw-r--r--src/network/networkprotocol.h18
-rw-r--r--src/network/serveropcodes.cpp2
-rw-r--r--src/network/serverpackethandler.cpp18
6 files changed, 38 insertions, 28 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 8cfcc85a7..780b07872 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1000,8 +1000,9 @@ void Client::sendInit(const std::string &playerName)
{
NetworkPacket pkt(TOSERVER_INIT, 1 + 2 + 2 + (1 + playerName.size()));
- // TODO (later) actually send supported compression modes
- pkt << (u8) SER_FMT_VER_HIGHEST_READ << (u8) 42;
+ // we don't support network compression yet
+ u16 supp_comp_modes = NETPROTO_COMPRESSION_NONE;
+ pkt << (u8) SER_FMT_VER_HIGHEST_READ << (u16) supp_comp_modes;
pkt << (u16) CLIENT_PROTOCOL_VERSION_MIN << (u16) CLIENT_PROTOCOL_VERSION_MAX;
pkt << playerName;
diff --git a/src/clientiface.h b/src/clientiface.h
index 070559c3a..4707f4d9a 100644
--- a/src/clientiface.h
+++ b/src/clientiface.h
@@ -337,7 +337,7 @@ public:
void setPendingSerializationVersion(u8 version)
{ m_pending_serialization_version = version; }
- void setSupportedCompressionModes(u8 byteFlag)
+ void setSupportedCompressionModes(u16 byteFlag)
{ m_supported_compressions = byteFlag; }
void confirmSerializationVersion()
@@ -416,7 +416,7 @@ private:
std::string m_full_version;
- u8 m_supported_compressions;
+ u16 m_supported_compressions;
/*
time this client was created
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp
index 2106e4368..1f13c62f9 100644
--- a/src/network/clientpackethandler.cpp
+++ b/src/network/clientpackethandler.cpp
@@ -44,26 +44,31 @@ void Client::handleCommand_Hello(NetworkPacket* pkt)
if (pkt->getSize() < 1)
return;
- u8 deployed;
+ u8 serialization_ver;
+ u16 proto_ver;
+ u16 compression_mode;
u32 auth_mechs;
std::string username_legacy; // for case insensitivity
- *pkt >> deployed >> auth_mechs >> username_legacy;
+ *pkt >> serialization_ver >> compression_mode >> proto_ver
+ >> auth_mechs >> username_legacy;
// Chose an auth method we support
AuthMechanism chosen_auth_mechanism = choseAuthMech(auth_mechs);
infostream << "Client: TOCLIENT_HELLO received with "
- "deployed=" << ((int)deployed & 0xff) << ", auth_mechs="
- << auth_mechs << ", chosen=" << chosen_auth_mechanism << std::endl;
+ << "serialization_ver=" << serialization_ver
+ << ", auth_mechs=" << auth_mechs
+ << ", compression_mode=" << compression_mode
+ << ". Doing auth with mech " << chosen_auth_mechanism << std::endl;
- if (!ser_ver_supported(deployed)) {
+ if (!ser_ver_supported(serialization_ver)) {
infostream << "Client: TOCLIENT_HELLO: Server sent "
<< "unsupported ser_fmt_ver"<< std::endl;
return;
}
- m_server_ser_ver = deployed;
- m_proto_ver = deployed;
+ m_server_ser_ver = serialization_ver;
+ m_proto_ver = proto_ver;
//TODO verify that username_legacy matches sent username, only
// differs in casing (make both uppercase and compare)
diff --git a/src/network/networkprotocol.h b/src/network/networkprotocol.h
index ba12a206e..09617c9d9 100644
--- a/src/network/networkprotocol.h
+++ b/src/network/networkprotocol.h
@@ -131,7 +131,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Add TOCLIENT_AUTH_ACCEPT to accept connection from client
*/
-#define LATEST_PROTOCOL_VERSION 24
+#define LATEST_PROTOCOL_VERSION 25
// Server's supported network protocol range
#define SERVER_PROTOCOL_VERSION_MIN 13
@@ -158,7 +158,9 @@ enum ToClientCommand
/*
Sent after TOSERVER_INIT.
- u8 deployed version
+ u8 deployed serialisation version
+ u16 deployed network compression mode
+ u16 deployed protocol version
u32 supported auth methods
std::string username that should be used for legacy hash (for proper casing)
*/
@@ -632,11 +634,11 @@ enum ToServerCommand
/*
Sent first after connected.
- [2] u8 SER_FMT_VER_HIGHEST_READ
- [3] u8 compression_modes
- [4] u16 minimum supported network protocol version
- [6] u16 maximum supported network protocol version
- [8] std::string player name
+ u8 serialisation version (=SER_FMT_VER_HIGHEST_READ)
+ u16 supported network compression modes
+ u16 minimum supported network protocol version
+ u16 maximum supported network protocol version
+ std::string player name
*/
TOSERVER_INIT_LEGACY = 0x10,
@@ -936,7 +938,7 @@ enum AccessDeniedCode {
};
enum NetProtoCompressionMode {
- NETPROTO_COMPRESSION_ZLIB = 0,
+ NETPROTO_COMPRESSION_NONE = 0,
};
const static std::string accessDeniedStrings[SERVER_ACCESSDENIED_MAX] = {
diff --git a/src/network/serveropcodes.cpp b/src/network/serveropcodes.cpp
index 92d24fe40..9b14a1be3 100644
--- a/src/network/serveropcodes.cpp
+++ b/src/network/serveropcodes.cpp
@@ -115,7 +115,7 @@ const ClientCommandFactory clientCommandFactoryTable[TOCLIENT_NUM_MSG_TYPES] =
{
null_command_factory, // 0x00
null_command_factory, // 0x01
- null_command_factory, // 0x02
+ { "TOCLIENT_HELLO", 0, true }, // 0x02
{ "TOCLIENT_AUTH_ACCEPT", 0, true }, // 0x03
{ "TOCLIENT_ACCEPT_SUDO_MODE", 0, true }, // 0x04
{ "TOCLIENT_DENY_SUDO_MODE", 0, true }, // 0x05
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp
index a6f5ffca1..38b8b3cff 100644
--- a/src/network/serverpackethandler.cpp
+++ b/src/network/serverpackethandler.cpp
@@ -91,22 +91,22 @@ void Server::handleCommand_Init(NetworkPacket* pkt)
// First byte after command is maximum supported
// serialization version
u8 client_max;
- u8 compression_modes;
+ u16 supp_compr_modes;
u16 min_net_proto_version = 0;
u16 max_net_proto_version;
std::string playerName;
- *pkt >> client_max >> compression_modes >> min_net_proto_version
+ *pkt >> client_max >> supp_compr_modes >> min_net_proto_version
>> max_net_proto_version >> playerName;
u8 our_max = SER_FMT_VER_HIGHEST_READ;
// Use the highest version supported by both
- u8 deployed = std::min(client_max, our_max);
+ u8 depl_serial_v = std::min(client_max, our_max);
// If it's lower than the lowest supported, give up.
- if (deployed < SER_FMT_VER_LOWEST)
- deployed = SER_FMT_VER_INVALID;
+ if (depl_serial_v < SER_FMT_VER_LOWEST)
+ depl_serial_v = SER_FMT_VER_INVALID;
- if (deployed == SER_FMT_VER_INVALID) {
+ if (depl_serial_v == SER_FMT_VER_INVALID) {
actionstream << "Server: A mismatched client tried to connect from "
<< addr_s << std::endl;
infostream<<"Server: Cannot negotiate serialization version with "
@@ -115,7 +115,7 @@ void Server::handleCommand_Init(NetworkPacket* pkt)
return;
}
- client->setPendingSerializationVersion(deployed);
+ client->setPendingSerializationVersion(depl_serial_v);
/*
Read and check network protocol version
@@ -274,7 +274,9 @@ void Server::handleCommand_Init(NetworkPacket* pkt)
NetworkPacket resp_pkt(TOCLIENT_HELLO, 1 + 4
+ legacyPlayerNameCasing.size(), pkt->getPeerId());
- resp_pkt << deployed << auth_mechs << legacyPlayerNameCasing;
+ u16 depl_compress_mode = NETPROTO_COMPRESSION_NONE;
+ resp_pkt << depl_serial_v << depl_compress_mode << net_proto_version
+ << auth_mechs << legacyPlayerNameCasing;
Send(&resp_pkt);