mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-23 20:03:31 +01:00
Add changes file for tpo/core/tor#11101.
This commit is contained in:
parent
b4f8518f8f
commit
3c8035b452
4
changes/ticket11101
Normal file
4
changes/ticket11101
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
o Minor feature (bridges, pluggable transport):
|
||||||
|
- Add STATUS TYPE=version handler for Pluggable Transport. This allows us to
|
||||||
|
gather version statistics on Pluggable Transport usage from bridge servers
|
||||||
|
on our metrics portal. Closes ticket 11101.
|
@ -89,6 +89,7 @@
|
|||||||
* old transports from the circuitbuild.c subsystem.
|
* old transports from the circuitbuild.c subsystem.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
#include "lib/string/printf.h"
|
||||||
#define PT_PRIVATE
|
#define PT_PRIVATE
|
||||||
#include "core/or/or.h"
|
#include "core/or/or.h"
|
||||||
#include "feature/client/bridges.h"
|
#include "feature/client/bridges.h"
|
||||||
@ -1307,6 +1308,11 @@ STATIC void
|
|||||||
handle_status_message(const config_line_t *values,
|
handle_status_message(const config_line_t *values,
|
||||||
managed_proxy_t *mp)
|
managed_proxy_t *mp)
|
||||||
{
|
{
|
||||||
|
if (config_count_key(values, "TYPE") > 1) {
|
||||||
|
log_warn(LD_PT, "Managed proxy \"%s\" has multiple TYPE key which "
|
||||||
|
"is not allowed.", mp->argv[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const config_line_t *message_type = config_line_find(values, "TYPE");
|
const config_line_t *message_type = config_line_find(values, "TYPE");
|
||||||
|
|
||||||
/* Check if we have a TYPE field? */
|
/* Check if we have a TYPE field? */
|
||||||
@ -1790,16 +1796,22 @@ pt_get_extra_info_descriptor_string(void)
|
|||||||
tor_free(transport_args);
|
tor_free(transport_args);
|
||||||
} SMARTLIST_FOREACH_END(t);
|
} SMARTLIST_FOREACH_END(t);
|
||||||
|
|
||||||
if (mp->version != NULL) {
|
/* Set transport-info line. */
|
||||||
smartlist_add_asprintf(string_chunks,
|
{
|
||||||
"transport-version %s",
|
char *transport_info_args = NULL;
|
||||||
mp->version);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mp->implementation != NULL) {
|
if (mp->version) {
|
||||||
smartlist_add_asprintf(string_chunks,
|
tor_asprintf(&transport_info_args, " version=%s", mp->version);
|
||||||
"transport-implementation %s",
|
}
|
||||||
mp->implementation);
|
if (mp->implementation) {
|
||||||
|
tor_asprintf(&transport_info_args, " implementation=%s",
|
||||||
|
mp->implementation);
|
||||||
|
}
|
||||||
|
if (transport_info_args) {
|
||||||
|
smartlist_add_asprintf(string_chunks, "transport-info%s",
|
||||||
|
transport_info_args ? transport_info_args : "");
|
||||||
|
tor_free(transport_info_args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} SMARTLIST_FOREACH_END(mp);
|
} SMARTLIST_FOREACH_END(mp);
|
||||||
|
|
||||||
|
@ -162,6 +162,7 @@ test_pt_status_parsing(void *arg)
|
|||||||
tt_ptr_op(mp->version, OP_EQ, NULL);
|
tt_ptr_op(mp->version, OP_EQ, NULL);
|
||||||
tt_ptr_op(mp->implementation, OP_EQ, NULL);
|
tt_ptr_op(mp->implementation, OP_EQ, NULL);
|
||||||
|
|
||||||
|
/* Normal case. */
|
||||||
strlcpy(line, "STATUS "
|
strlcpy(line, "STATUS "
|
||||||
"IMPLEMENTATION=xyz "
|
"IMPLEMENTATION=xyz "
|
||||||
"TYPE=version "
|
"TYPE=version "
|
||||||
@ -171,7 +172,92 @@ test_pt_status_parsing(void *arg)
|
|||||||
|
|
||||||
tt_str_op(mp->version, OP_EQ, "1.33.7-hax beta");
|
tt_str_op(mp->version, OP_EQ, "1.33.7-hax beta");
|
||||||
tt_str_op(mp->implementation, OP_EQ, "xyz");
|
tt_str_op(mp->implementation, OP_EQ, "xyz");
|
||||||
|
reset_mp(mp);
|
||||||
|
|
||||||
|
/* Normal case but different case for TYPE value. */
|
||||||
|
strlcpy(line, "STATUS "
|
||||||
|
"IMPLEMENTATION=xyz "
|
||||||
|
"TYPE=vErSiON "
|
||||||
|
"VERSION=\"1.33.7-hax beta\"",
|
||||||
|
sizeof(line));
|
||||||
|
handle_proxy_line(line, mp);
|
||||||
|
|
||||||
|
tt_str_op(mp->version, OP_EQ, "1.33.7-hax beta");
|
||||||
|
tt_str_op(mp->implementation, OP_EQ, "xyz");
|
||||||
|
reset_mp(mp);
|
||||||
|
|
||||||
|
/* IMPLEMENTATION and VERSION set but no TYPE. */
|
||||||
|
strlcpy(line, "STATUS "
|
||||||
|
"IMPLEMENTATION=xyz "
|
||||||
|
"VERSION=\"1.33.7-hax beta\"",
|
||||||
|
sizeof(line));
|
||||||
|
handle_proxy_line(line, mp);
|
||||||
|
|
||||||
|
tt_assert(mp->version == NULL);
|
||||||
|
tt_assert(mp->implementation == NULL);
|
||||||
|
reset_mp(mp);
|
||||||
|
|
||||||
|
/* Multiple TYPE= is not allowed. */
|
||||||
|
strlcpy(line, "STATUS "
|
||||||
|
"IMPLEMENTATION=xyz "
|
||||||
|
"TYPE=version "
|
||||||
|
"VERSION=\"1.33.7-hax beta\" "
|
||||||
|
"TYPE=nothing",
|
||||||
|
sizeof(line));
|
||||||
|
handle_proxy_line(line, mp);
|
||||||
|
|
||||||
|
tt_assert(mp->version == NULL);
|
||||||
|
tt_assert(mp->implementation == NULL);
|
||||||
|
reset_mp(mp);
|
||||||
|
|
||||||
|
/* Multiple TYPE= is not allowed. */
|
||||||
|
strlcpy(line, "STATUS "
|
||||||
|
"IMPLEMENTATION=xyz "
|
||||||
|
"TYPE=version "
|
||||||
|
"VERSION=\"1.33.7-hax beta\" "
|
||||||
|
"TYPE=version",
|
||||||
|
sizeof(line));
|
||||||
|
handle_proxy_line(line, mp);
|
||||||
|
|
||||||
|
tt_assert(mp->version == NULL);
|
||||||
|
tt_assert(mp->implementation == NULL);
|
||||||
|
reset_mp(mp);
|
||||||
|
|
||||||
|
/* Missing VERSION. */
|
||||||
|
strlcpy(line, "STATUS "
|
||||||
|
"TYPE=version "
|
||||||
|
"IMPLEMENTATION=xyz ",
|
||||||
|
sizeof(line));
|
||||||
|
handle_proxy_line(line, mp);
|
||||||
|
|
||||||
|
tt_assert(mp->version == NULL);
|
||||||
|
tt_assert(mp->implementation == NULL);
|
||||||
|
reset_mp(mp);
|
||||||
|
|
||||||
|
/* Many IMPLEMENTATION and VERSION. First found are used. */
|
||||||
|
strlcpy(line, "STATUS "
|
||||||
|
"TYPE=version "
|
||||||
|
"IMPLEMENTATION=xyz "
|
||||||
|
"VERSION=\"1.33.7-hax beta\" "
|
||||||
|
"IMPLEMENTATION=abc "
|
||||||
|
"VERSION=\"2.33.7-hax beta\" ",
|
||||||
|
sizeof(line));
|
||||||
|
handle_proxy_line(line, mp);
|
||||||
|
|
||||||
|
tt_str_op(mp->version, OP_EQ, "1.33.7-hax beta");
|
||||||
|
tt_str_op(mp->implementation, OP_EQ, "xyz");
|
||||||
|
reset_mp(mp);
|
||||||
|
|
||||||
|
/* Control characters. Invalid input. */
|
||||||
|
strlcpy(line, "STATUS "
|
||||||
|
"TYPE=version "
|
||||||
|
"IMPLEMENTATION=xyz\0abc "
|
||||||
|
"VERSION=\"1.33.7-hax beta\"\0.3 ",
|
||||||
|
sizeof(line));
|
||||||
|
handle_proxy_line(line, mp);
|
||||||
|
|
||||||
|
tt_assert(mp->version == NULL);
|
||||||
|
tt_assert(mp->implementation == NULL);
|
||||||
reset_mp(mp);
|
reset_mp(mp);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
Loading…
Reference in New Issue
Block a user