mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
Place the options in the environment after processing them properly.
This commit is contained in:
parent
1a0cf08841
commit
1ee3a0cf44
@ -4671,6 +4671,26 @@ get_transport_bindaddr_from_config(const char *transport)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Given the name of a pluggable transport in <b>transport</b>, check
|
||||||
|
* the configuration file to see if the user has asked us to pass any
|
||||||
|
* parameters to the pluggable transport. Return a smartlist
|
||||||
|
* containing the parameters, otherwise NULL. */
|
||||||
|
smartlist_t *
|
||||||
|
get_options_for_server_transport(const char *transport)
|
||||||
|
{
|
||||||
|
config_line_t *cl;
|
||||||
|
const or_options_t *options = get_options();
|
||||||
|
|
||||||
|
for (cl = options->ServerTransportOptions; cl; cl = cl->next) {
|
||||||
|
smartlist_t *options_sl =
|
||||||
|
get_options_from_transport_options_line(cl->value, transport);
|
||||||
|
if (options_sl)
|
||||||
|
return options_sl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/** Read the contents of a ServerTransportPlugin line from
|
/** Read the contents of a ServerTransportPlugin line from
|
||||||
* <b>line</b>. Return 0 if the line is well-formed, and -1 if it
|
* <b>line</b>. Return 0 if the line is well-formed, and -1 if it
|
||||||
* isn't.
|
* isn't.
|
||||||
|
@ -114,7 +114,7 @@ void bridge_line_free(bridge_line_t *bridge_line);
|
|||||||
bridge_line_t *parse_bridge_line(const char *line);
|
bridge_line_t *parse_bridge_line(const char *line);
|
||||||
smartlist_t *get_options_from_transport_options_line(const char *line,
|
smartlist_t *get_options_from_transport_options_line(const char *line,
|
||||||
const char *transport);
|
const char *transport);
|
||||||
|
smartlist_t *get_options_for_server_transport(const char *transport);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1100,6 +1100,48 @@ parse_cmethod_line(const char *line, managed_proxy_t *mp)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Return a newly allocated string that tor should place in
|
||||||
|
* TOR_PT_SERVER_TRANSPORT_OPTIONS while configuring the server
|
||||||
|
* manged proxy in <b>mp</b>. Return NULL if no such options are found. */
|
||||||
|
static char *
|
||||||
|
get_transport_options_for_server_proxy(const managed_proxy_t *mp)
|
||||||
|
{
|
||||||
|
char *options_string = NULL;
|
||||||
|
smartlist_t *string_sl = smartlist_new();
|
||||||
|
|
||||||
|
tor_assert(mp->is_server);
|
||||||
|
|
||||||
|
/** Loop over the transports of the proxy. If we have options for
|
||||||
|
any of them, format them appropriately and place them in our
|
||||||
|
smartlist. Finally, join our smartlist to get the final
|
||||||
|
string. */
|
||||||
|
SMARTLIST_FOREACH_BEGIN(mp->transports_to_launch, const char *, transport) {
|
||||||
|
smartlist_t *options_tmp_sl = NULL;
|
||||||
|
options_tmp_sl = get_options_for_server_transport(transport);
|
||||||
|
if (!options_tmp_sl)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/** Loop over the options of this transport, escape them, and
|
||||||
|
place them in the smartlist. */
|
||||||
|
SMARTLIST_FOREACH_BEGIN(options_tmp_sl, const char *, options) {
|
||||||
|
char *escaped_opts = tor_escape_str_for_pt_args(options, ":;\\");
|
||||||
|
smartlist_add_asprintf(string_sl, "%s:%s",
|
||||||
|
transport, escaped_opts);
|
||||||
|
tor_free(escaped_opts);
|
||||||
|
} SMARTLIST_FOREACH_END(options);
|
||||||
|
|
||||||
|
SMARTLIST_FOREACH(options_tmp_sl, char *, c, tor_free(c));
|
||||||
|
smartlist_free(options_tmp_sl);
|
||||||
|
} SMARTLIST_FOREACH_END(transport);
|
||||||
|
|
||||||
|
options_string = smartlist_join_strings(string_sl, ";", 0, NULL);
|
||||||
|
|
||||||
|
SMARTLIST_FOREACH(string_sl, char *, t, tor_free(t));
|
||||||
|
smartlist_free(string_sl);
|
||||||
|
|
||||||
|
return options_string;
|
||||||
|
}
|
||||||
|
|
||||||
/** Return the string that tor should place in TOR_PT_SERVER_BINDADDR
|
/** Return the string that tor should place in TOR_PT_SERVER_BINDADDR
|
||||||
* while configuring the server managed proxy in <b>mp</b>. The
|
* while configuring the server managed proxy in <b>mp</b>. The
|
||||||
* string is stored in the heap, and it's the the responsibility of
|
* string is stored in the heap, and it's the the responsibility of
|
||||||
@ -1181,6 +1223,14 @@ create_managed_proxy_environment(const managed_proxy_t *mp)
|
|||||||
tor_free(bindaddr_tmp);
|
tor_free(bindaddr_tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
char *server_transport_options =
|
||||||
|
get_transport_options_for_server_proxy(mp);
|
||||||
|
smartlist_add_asprintf(envs, "TOR_PT_SERVER_TRANSPORT_OPTIONS=%s",
|
||||||
|
server_transport_options);
|
||||||
|
tor_free(server_transport_options);
|
||||||
|
}
|
||||||
|
|
||||||
/* XXX024 Remove the '=' here once versions of obfsproxy which
|
/* XXX024 Remove the '=' here once versions of obfsproxy which
|
||||||
* assert that this env var exists are sufficiently dead.
|
* assert that this env var exists are sufficiently dead.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user