#
# patch "ChangeLog"
# from [14b789b0239c4006d5392dfb843c00826dc6d206]
# to [5b2431e5d6c1515b9c46cbb61dcddc6f6ac7d540]
#
# patch "netcmd.cc"
# from [e04a41fed951a77dcef389e94cc26d04ae12220f]
# to [68e9e475c2423fded015699b6dcaa8742326ab6e]
#
# patch "netsync.cc"
# from [6ac44712dc4b51df54c5a0ab95bd0ee0211d26eb]
# to [a473cc63cf2d6086fa68ef5b309ead418bfb4661]
#
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,11 @@
+2005-06-22 Nathaniel Smith
+
+ * netcmd.cc, netsync.cc: Revert backwards compatibility code; 0.19
+ and 0.20 can't be usefully compatible, and the code as it existed
+ would cause real version mismatch error reporting to not work
+ right. (Old client with new server would give a generic "server
+ disconnected" error message instead of something useful.)
+
2005-06-21 Nathaniel Smith
* netsync.cc (rebuild_merkle_trees): Fix FIXME comments to match
--- netcmd.cc
+++ netcmd.cc
@@ -50,9 +50,6 @@
cmd_code(bye_cmd)
{}
-netcmd::netcmd(u8 _version) : version(_version), cmd_code(bye_cmd)
-{}
-
size_t netcmd::encoded_size()
{
string tmp;
@@ -78,22 +75,6 @@
insert_datum_lsb(check.sum(), out);
}
-// last should be zero (doesn't mean we're compatible with version 0).
-// The nonzero elements are the historical netsync/netcmd versions we can
-// interoperate with. For interoperating with newer versions, assume
-// compatibility and let the remote host make the call.
-static u8 const compatible_versions[] = {4, 0};
-
-bool is_compatible(u8 version)
-{
- for (u8 const *x = compatible_versions; *x; ++x)
- {
- if (*x == version)
- return true;
- }
- return false;
-}
-
bool
netcmd::read(string & inbuf)
{
@@ -102,28 +83,20 @@
if (inbuf.size() < constants::netcmd_minsz)
return false;
- u8 ver = extract_datum_lsb(inbuf, pos, "netcmd protocol number");
+ u8 extracted_ver = extract_datum_lsb(inbuf, pos, "netcmd protocol number");
int v = version;
+ if (extracted_ver != version)
+ throw bad_decode(F("protocol version mismatch: wanted '%d' got '%d'")
+ % widen(version)
+ % widen(extracted_ver));
+ version = extracted_ver;
u8 cmd_byte = extract_datum_lsb(inbuf, pos, "netcmd code");
switch (cmd_byte)
{
- // hello may be newer than expected, or one we're compatible with
case static_cast(hello_cmd):
- if (ver < version && !is_compatible(ver))
- throw bad_decode(F("protocol version mismatch: wanted '%d' got '%d'")
- % widen(v)
- % widen(ver));
- break;
- // these may be older compatible versions
case static_cast(anonymous_cmd):
case static_cast(auth_cmd):
- if (ver != version && (ver > version || !is_compatible(ver)))
- throw bad_decode(F("protocol version mismatch: wanted '%d' got '%d'")
- % widen(v)
- % widen(ver));
- break;
- // these must match exactly what's expected
case static_cast(error_cmd):
case static_cast(bye_cmd):
case static_cast(confirm_cmd):
@@ -134,16 +107,11 @@
case static_cast(data_cmd):
case static_cast(delta_cmd):
case static_cast(nonexistant_cmd):
- if (ver != version)
- throw bad_decode(F("protocol version mismatch: wanted '%d' got '%d'")
- % widen(v)
- % widen(ver));
+ cmd_code = static_cast(cmd_byte);
break;
default:
throw bad_decode(F("unknown netcmd code 0x%x") % widen(cmd_byte));
}
- cmd_code = static_cast(cmd_byte);
- version = ver;
// check to see if we have even enough bytes for a complete uleb128
size_t payload_len = 0;
--- netsync.cc
+++ netsync.cc
@@ -221,7 +221,6 @@
string outbuf;
netcmd cmd;
- u8 protocol_version;
bool armed;
bool arm();
@@ -433,7 +432,6 @@
str(sock, to),
inbuf(""),
outbuf(""),
- protocol_version(constants::netcmd_current_protocol_version),
armed(false),
pattern(""),
pattern_re(".*"),
@@ -1316,7 +1314,7 @@
session::queue_bye_cmd()
{
L(F("queueing 'bye' command\n"));
- netcmd cmd(protocol_version);
+ netcmd cmd;
cmd.write_bye_cmd();
write_netcmd_and_try_flush(cmd);
this->sent_goodbye = true;
@@ -1326,7 +1324,7 @@
session::queue_error_cmd(string const & errmsg)
{
L(F("queueing 'error' command\n"));
- netcmd cmd(protocol_version);
+ netcmd cmd;
cmd.write_error_cmd(errmsg);
write_netcmd_and_try_flush(cmd);
this->sent_goodbye = true;
@@ -1339,7 +1337,7 @@
string typestr;
netcmd_item_type_to_string(type, typestr);
L(F("queueing 'done' command for %s level %s\n") % typestr % level);
- netcmd cmd(protocol_version);
+ netcmd cmd;
cmd.write_done_cmd(level, type);
write_netcmd_and_try_flush(cmd);
}
@@ -1348,7 +1346,7 @@
session::queue_hello_cmd(id const & server,
id const & nonce)
{
- netcmd cmd(protocol_version);
+ netcmd cmd;
hexenc server_encoded;
encode_hexenc(server, server_encoded);
@@ -1367,7 +1365,7 @@
string const & pattern,
id const & nonce2)
{
- netcmd cmd(protocol_version);
+ netcmd cmd;
cmd.write_anonymous_cmd(role, pattern, nonce2);
write_netcmd_and_try_flush(cmd);
}
@@ -1380,7 +1378,7 @@
id const & nonce2,
string const & signature)
{
- netcmd cmd(protocol_version);
+ netcmd cmd;
cmd.write_auth_cmd(role, pattern, client, nonce1, nonce2, signature);
write_netcmd_and_try_flush(cmd);
}
@@ -1388,7 +1386,7 @@
void
session::queue_confirm_cmd(string const & signature)
{
- netcmd cmd(protocol_version);
+ netcmd cmd;
cmd.write_confirm_cmd(signature);
write_netcmd_and_try_flush(cmd);
}
@@ -1402,7 +1400,7 @@
netcmd_item_type_to_string(node.type, typestr);
L(F("queueing request for refinement of %s node '%s', level %d\n")
% typestr % hpref % static_cast(node.level));
- netcmd cmd(protocol_version);
+ netcmd cmd;
cmd.write_refine_cmd(node);
write_netcmd_and_try_flush(cmd);
}
@@ -1432,7 +1430,7 @@
L(F("queueing request for data of %s item '%s'\n")
% typestr % hid);
- netcmd cmd(protocol_version);
+ netcmd cmd;
cmd.write_send_data_cmd(type, item);
write_netcmd_and_try_flush(cmd);
note_item_requested(type, item);
@@ -1468,7 +1466,7 @@
L(F("queueing request for contents of %s delta '%s' -> '%s'\n")
% typestr % base_hid % ident_hid);
- netcmd cmd(protocol_version);
+ netcmd cmd;
cmd.write_send_delta_cmd(type, base, ident);
write_netcmd_and_try_flush(cmd);
note_item_requested(type, ident);
@@ -1493,7 +1491,7 @@
L(F("queueing %d bytes of data for %s item '%s'\n")
% dat.size() % typestr % hid);
- netcmd cmd(protocol_version);
+ netcmd cmd;
cmd.write_data_cmd(type, item, dat);
write_netcmd_and_try_flush(cmd);
note_item_sent(type, item);
@@ -1523,7 +1521,7 @@
L(F("queueing %s delta '%s' -> '%s'\n")
% typestr % base_hid % ident_hid);
- netcmd cmd(protocol_version);
+ netcmd cmd;
cmd.write_delta_cmd(type, base, ident, del);
write_netcmd_and_try_flush(cmd);
note_item_sent(type, ident);
@@ -1546,7 +1544,7 @@
L(F("queueing note of nonexistance of %s item '%s'\n")
% typestr % hid);
- netcmd cmd(protocol_version);
+ netcmd cmd;
cmd.write_nonexistant_cmd(type, item);
write_netcmd_and_try_flush(cmd);
}
@@ -1632,22 +1630,6 @@
W(F("No branches found."));
}
-void
-convert_pattern(utf8 & pat, utf8 & conv)
-{
- string x = pat();
- string pattern = "";
- string e = ".|*?+()[]{}^$\\";
- for (string::const_iterator i = x.begin(); i != x.end(); i++)
- {
- if (e.find(*i) != e.npos)
- pattern += '\\';
- pattern += *i;
- }
- conv = pattern + ".*";
-}
-
-
static const var_domain known_servers_domain = var_domain("known-servers");
bool
@@ -1712,13 +1694,6 @@
}
utf8 pat(pattern);
- if (protocol_version < 5)
- {
- W(F("Talking to an old server. "
- "Using %s as a collection, not a regex.") % pattern);
- convert_pattern(pattern, pat);
- this->pattern_re = boost::regex(pat());
- }
vector branchnames;
set ok_branches;
get_branches(app, branchnames);
@@ -2981,8 +2956,6 @@
rsa_pub_key server_key;
id nonce;
cmd.read_hello_cmd(server_keyname, server_key, nonce);
- if (cmd.get_version() < protocol_version)
- protocol_version = cmd.get_version();
return process_hello_cmd(server_keyname, server_key, nonce);
}
break;
@@ -2998,8 +2971,6 @@
string pattern;
id nonce2;
cmd.read_anonymous_cmd(role, pattern, nonce2);
- if (cmd.get_version() < protocol_version)
- protocol_version = cmd.get_version();
return process_anonymous_cmd(role, pattern, nonce2);
}
break;
@@ -3012,8 +2983,6 @@
string pattern, signature;
id client, nonce1, nonce2;
cmd.read_auth_cmd(role, pattern, client, nonce1, nonce2, signature);
- if (cmd.get_version() < protocol_version)
- protocol_version = cmd.get_version();
return process_auth_cmd(role, pattern, client,
nonce1, nonce2, signature);
}