mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 13:53:31 +01:00
bwauth: Allow "node_id" KeyValue without "$"
Allow "node_id" KeyValue without the dollar sign at the start of the hexdigit in the BandwidthFiles, in order to easier database queries combining Tor documents in which the relays fingerprint doesn't include it. Bugfix on all supported versions of Tor. Closes #40891
This commit is contained in:
parent
8bb7d681ae
commit
d8aa699253
5
changes/ticket40891
Normal file
5
changes/ticket40891
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
o Minor feature (directory authority):
|
||||||
|
- Allow BandwidthFiles "node_id" KeyValue without the dollar sign at the
|
||||||
|
start of the hexdigit, in order to easier database queries combining
|
||||||
|
Tor documents in which the relays fingerprint does not include it.
|
||||||
|
Fixes bug 40891; bugfix on 0.4.7 (all supported versions of Tor).
|
@ -434,15 +434,19 @@ measured_bw_line_parse(measured_bw_line_t *out, const char *orig_line,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
got_bw=1;
|
got_bw=1;
|
||||||
} else if (strcmpstart(cp, "node_id=$") == 0) {
|
// Allow node_id to start with or without the dollar sign.
|
||||||
|
} else if (strcmpstart(cp, "node_id=") == 0) {
|
||||||
if (got_node_id) {
|
if (got_node_id) {
|
||||||
log_warn(LD_DIRSERV, "Double node_id= in bandwidth file line: %s",
|
log_warn(LD_DIRSERV, "Double node_id= in bandwidth file line: %s",
|
||||||
escaped(orig_line));
|
escaped(orig_line));
|
||||||
tor_free(line);
|
tor_free(line);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (strcmpstart(cp, "node_id=$") == 0) {
|
||||||
cp+=strlen("node_id=$");
|
cp+=strlen("node_id=$");
|
||||||
|
} else if (strcmpstart(cp, "node_id=") == 0) {
|
||||||
|
cp+=strlen("node_id=");
|
||||||
|
}
|
||||||
if (strlen(cp) != HEX_DIGEST_LEN ||
|
if (strlen(cp) != HEX_DIGEST_LEN ||
|
||||||
base16_decode(out->node_id, DIGEST_LEN,
|
base16_decode(out->node_id, DIGEST_LEN,
|
||||||
cp, HEX_DIGEST_LEN) != DIGEST_LEN) {
|
cp, HEX_DIGEST_LEN) != DIGEST_LEN) {
|
||||||
|
@ -2072,6 +2072,8 @@ test_dir_measured_bw_kb(void *arg)
|
|||||||
int i;
|
int i;
|
||||||
const char *lines_pass[] = {
|
const char *lines_pass[] = {
|
||||||
"node_id=$557365204145532d32353620696e73746561642e bw=1024\n",
|
"node_id=$557365204145532d32353620696e73746561642e bw=1024\n",
|
||||||
|
/* check whether node_id does not need the dollar sign at the start */
|
||||||
|
"node_id=557365204145532d32353620696e73746561642e bw=1024\n",
|
||||||
"node_id=$557365204145532d32353620696e73746561642e\t bw=1024 \n",
|
"node_id=$557365204145532d32353620696e73746561642e\t bw=1024 \n",
|
||||||
" node_id=$557365204145532d32353620696e73746561642e bw=1024\n",
|
" node_id=$557365204145532d32353620696e73746561642e bw=1024\n",
|
||||||
"\tnoise\tnode_id=$557365204145532d32353620696e73746561642e "
|
"\tnoise\tnode_id=$557365204145532d32353620696e73746561642e "
|
||||||
@ -2129,7 +2131,6 @@ test_dir_measured_bw_kb(void *arg)
|
|||||||
" node_id= ",
|
" node_id= ",
|
||||||
"node_id==$557365204145532d32353620696e73746561642e bw==1024\n",
|
"node_id==$557365204145532d32353620696e73746561642e bw==1024\n",
|
||||||
"node_id=$55736520414552d32353620696e73746561642e bw=1024\n",
|
"node_id=$55736520414552d32353620696e73746561642e bw=1024\n",
|
||||||
"node_id=557365204145532d32353620696e73746561642e bw=1024\n",
|
|
||||||
"node_id= $557365204145532d32353620696e73746561642e bw=0.23\n",
|
"node_id= $557365204145532d32353620696e73746561642e bw=0.23\n",
|
||||||
|
|
||||||
/* Test that a line with vote=0 will fail too, so that it is ignored. */
|
/* Test that a line with vote=0 will fail too, so that it is ignored. */
|
||||||
|
Loading…
Reference in New Issue
Block a user