feat(p6-protocol): --protocol version-force flag (client-only)
This commit is contained in:
@@ -598,6 +598,12 @@ static const OptionEntry OPTION_TABLE[] = {
|
|||||||
* charsets at startup (client_validation.c) and the full spec rides the
|
* charsets at startup (client_validation.c) and the full spec rides the
|
||||||
* config frame so the receiver derives the wire charset symmetrically. */
|
* config frame so the receiver derives the wire charset symmetrically. */
|
||||||
{"--iconv", NULL, OPT_STRING, offsetof(Config, iconv_spec)},
|
{"--iconv", NULL, OPT_STRING, offsetof(Config, iconv_spec)},
|
||||||
|
/* --protocol=NUM: rsync-compatible flag that forces the wire protocol
|
||||||
|
* version to the current value. FastSync has exactly one wire format, so
|
||||||
|
* any value other than PROTOCOL_VERSION is rejected at validation, before
|
||||||
|
* any network I/O. Client-only: the server does not negotiate, it just
|
||||||
|
* enforces an exact match. */
|
||||||
|
{"--protocol", NULL, OPT_STRING, offsetof(Config, version)},
|
||||||
{"--delete-before", NULL, OPT_FLAG, offsetof(Config, delete_before)},
|
{"--delete-before", NULL, OPT_FLAG, offsetof(Config, delete_before)},
|
||||||
{"--delete-during", "--del", OPT_FLAG, offsetof(Config, delete_during)},
|
{"--delete-during", "--del", OPT_FLAG, offsetof(Config, delete_during)},
|
||||||
{"--delete-delay", NULL, OPT_FLAG, offsetof(Config, delete_delay)},
|
{"--delete-delay", NULL, OPT_FLAG, offsetof(Config, delete_delay)},
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "delay_updates.h"
|
#include "delay_updates.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "usage.h"
|
#include "usage.h"
|
||||||
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/* Validate config after parsing. Returns true if valid. */
|
/* Validate config after parsing. Returns true if valid. */
|
||||||
@@ -132,5 +133,15 @@ bool validate_config(const Config* config) {
|
|||||||
"--iconv requires LOCAL[,REMOTE] charset names supported by iconv");
|
"--iconv requires LOCAL[,REMOTE] charset names supported by iconv");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
/* --protocol: FastSync has exactly one wire format, so the forced version
|
||||||
|
must equal the current PROTOCOL_VERSION exactly. Rejected here, before any
|
||||||
|
network I/O, rather than letting the server hit its own mismatch check. */
|
||||||
|
if (strcmp(config->version, PROTOCOL_VERSION) != 0) {
|
||||||
|
log_message(LOG_LEVEL_ERROR,
|
||||||
|
"--protocol must be %s (FastSync supports only its current wire "
|
||||||
|
"protocol version and cannot speak an older or virtual one)",
|
||||||
|
PROTOCOL_VERSION);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ void print_usage(void) {
|
|||||||
printf(" converted before transmission and back on receipt; a\n");
|
printf(" converted before transmission and back on receipt; a\n");
|
||||||
printf(" name that cannot be represented in the target charset\n");
|
printf(" name that cannot be represented in the target charset\n");
|
||||||
printf(" fails that transfer cleanly (rsync-compatible)\n");
|
printf(" fails that transfer cleanly (rsync-compatible)\n");
|
||||||
|
printf(" --protocol=NUM Force the wire protocol version (must equal the current\n");
|
||||||
|
printf(" PROTOCOL_VERSION; FastSync cannot speak older/virtual\n");
|
||||||
|
printf(" wire formats)\n");
|
||||||
printf(" --delete Delete files on receiver not in source\n");
|
printf(" --delete Delete files on receiver not in source\n");
|
||||||
printf(" (default timing: delete only after the whole\n");
|
printf(" (default timing: delete only after the whole\n");
|
||||||
printf(" transfer has succeeded)\n");
|
printf(" transfer has succeeded)\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user