|
@@ -280,6 +280,7 @@ static config_var_t option_vars_[] = {
|
|
|
V(IPv6Exit, BOOL, "0"),
|
|
|
VAR("ServerTransportPlugin", LINELIST, ServerTransportPlugin, NULL),
|
|
|
V(ServerTransportListenAddr, LINELIST, NULL),
|
|
|
+ V(ServerTransportOptions, LINELIST, NULL),
|
|
|
V(Socks4Proxy, STRING, NULL),
|
|
|
V(Socks5Proxy, STRING, NULL),
|
|
|
V(Socks5ProxyUsername, STRING, NULL),
|
|
@@ -3147,6 +3148,19 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|
|
"ServerTransportListenAddr line will be ignored.");
|
|
|
}
|
|
|
|
|
|
+ for (cl = options->ServerTransportOptions; cl; cl = cl->next) {
|
|
|
+
|
|
|
+ 'transport' being NULL, it means that something went wrong
|
|
|
+ while parsing the ServerTransportOptions line. */
|
|
|
+ smartlist_t *options_sl =
|
|
|
+ get_options_from_transport_options_line(cl->value, NULL);
|
|
|
+ if (!options_sl)
|
|
|
+ REJECT("ServerTransportOptions did not parse. See logs for details.");
|
|
|
+
|
|
|
+ SMARTLIST_FOREACH(options_sl, char *, cp, tor_free(cp));
|
|
|
+ smartlist_free(options_sl);
|
|
|
+ }
|
|
|
+
|
|
|
if (options->ConstrainedSockets) {
|
|
|
|
|
|
* limit is between MIN|MAX_TCPSOCK_BUFFER in k increments. */
|
|
@@ -4580,6 +4594,63 @@ get_bindaddr_from_transport_listen_line(const char *line,const char *transport)
|
|
|
return addrport;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * with the options. Return NULL if the line was not well-formed.
|
|
|
+ *
|
|
|
+ * If <b>transport</b> is set, return NULL if the line is not
|
|
|
+ * referring to <b>transport</b>.
|
|
|
+ *
|
|
|
+ * The returned smartlist and its strings are allocated on the heap
|
|
|
+ * and it's the responsibility of the caller to free it. */
|
|
|
+smartlist_t *
|
|
|
+get_options_from_transport_options_line(const char *line,const char *transport)
|
|
|
+{
|
|
|
+ smartlist_t *items = smartlist_new();
|
|
|
+ smartlist_t *options = smartlist_new();
|
|
|
+ const char *parsed_transport = NULL;
|
|
|
+
|
|
|
+ smartlist_split_string(items, line, NULL,
|
|
|
+ SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, -1);
|
|
|
+
|
|
|
+ if (smartlist_len(items) < 2) {
|
|
|
+ log_warn(LD_CONFIG,"Too few arguments on ServerTransportOptions line.");
|
|
|
+ goto err;
|
|
|
+ }
|
|
|
+
|
|
|
+ parsed_transport = smartlist_get(items, 0);
|
|
|
+
|
|
|
+ if (transport && strcmp(transport, parsed_transport))
|
|
|
+ goto err;
|
|
|
+
|
|
|
+ SMARTLIST_FOREACH_BEGIN(items, const char *, option) {
|
|
|
+ if (option_sl_idx == 0)
|
|
|
+ continue;
|
|
|
+
|
|
|
+
|
|
|
+ if (!string_is_key_value(LOG_WARN, option)) {
|
|
|
+ log_warn(LD_CONFIG, "%s is not a k=v value.", escaped(option));
|
|
|
+ goto err;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ smartlist_add(options, tor_strdup(option));
|
|
|
+ log_debug(LD_CONFIG, "Added %s to the list of options", escaped(option));
|
|
|
+ } SMARTLIST_FOREACH_END(option);
|
|
|
+
|
|
|
+ goto done;
|
|
|
+
|
|
|
+ err:
|
|
|
+ SMARTLIST_FOREACH(options, char*, s, tor_free(s));
|
|
|
+ smartlist_free(options);
|
|
|
+ options = NULL;
|
|
|
+
|
|
|
+ done:
|
|
|
+ SMARTLIST_FOREACH(items, char*, s, tor_free(s));
|
|
|
+ smartlist_free(items);
|
|
|
+
|
|
|
+ return options;
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
* the configuration file to see if the user has explicitly asked for
|
|
|
* it to listen on a specific port. Return a <address:port> string if
|
|
@@ -4600,6 +4671,26 @@ get_transport_bindaddr_from_config(const char *transport)
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 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;
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
* <b>line</b>. Return 0 if the line is well-formed, and -1 if it
|
|
|
* isn't.
|