V(CircuitStreamTimeout, INTERVAL, "0"),
V(CircuitPriorityHalflife, DOUBLE, "-100.0"), /*negative:'Use default'*/
V(ClientDNSRejectInternalAddresses, BOOL,"1"),
- V(ClientRejectInternalAddresses, BOOL, "1"),
V(ClientOnly, BOOL, "0"),
+ V(ClientRejectInternalAddresses, BOOL, "1"),
+ VAR("ClientTransportPlugin", LINELIST, ClientTransportPlugin, NULL),
V(ConsensusParams, STRING, NULL),
V(ConnLimit, UINT, "1000"),
V(ConnDirectionStatistics, BOOL, "0"),
static void config_register_addressmaps(or_options_t *options);
static int parse_bridge_line(const char *line, int validate_only);
+static int parse_transport_line(const char *line, int validate_only);
static int parse_dir_server_line(const char *line,
dirinfo_type_t required_type,
int validate_only);
if (consider_adding_dir_authorities(options, old_options) < 0)
return -1;
+ if (options->ClientTransportPlugin) {
+ for (cl = options->ClientTransportPlugin; cl; cl = cl->next) {
+ if (parse_transport_line(cl->value, 0)<0) {
+ log_warn(LD_BUG,
+ "Previously validated ClientTransportPlugin line "
+ "could not be added!");
+ return -1;
+ }
+ }
+ }
+
if (options->Bridges) {
mark_bridge_list();
for (cl = options->Bridges; cl; cl = cl->next) {
if (options->UseBridges && !options->TunnelDirConns)
REJECT("TunnelDirConns set to 0 only works with UseBridges set to 0");
+
+ if (options->ClientTransportPlugin) {
+ if (!options->Bridges)
+ REJECT("ClientTransportPlugin found without any bridges.");
+ for (cl = options->ClientTransportPlugin; cl; cl = cl->next) {
+ if (parse_transport_line(cl->value, 1)<0)
+ REJECT("Transport line did not parse. See logs for details.");
+ }
+ }
+
if (options->Bridges) {
for (cl = options->Bridges; cl; cl = cl->next) {
if (parse_bridge_line(cl->value, 1)<0)
smartlist_t *items = NULL;
int r;
char *addrport=NULL, *fingerprint=NULL;
+ char *transport_name=NULL;
+ char *field1=NULL;
tor_addr_t addr;
uint16_t port = 0;
char digest[DIGEST_LEN];
log_warn(LD_CONFIG, "Too few arguments to Bridge line.");
goto err;
}
- addrport = smartlist_get(items, 0);
+
+ /* field1 is either a transport name or addrport */
+ field1 = smartlist_get(items, 0);
smartlist_del_keeporder(items, 0);
+
+ if (!strstr(field1, ".")) { /* new-style bridge line */
+ transport_name = field1;
+ addrport = smartlist_get(items, 0);
+ smartlist_del_keeporder(items, 0);
+ } else
+ addrport = field1;
+
if (tor_addr_port_parse(addrport, &addr, &port)<0) {
log_warn(LD_CONFIG, "Error parsing Bridge address '%s'", addrport);
goto err;
}
if (!validate_only) {
- log_debug(LD_DIR, "Bridge at %s:%d (%s)", fmt_addr(&addr),
- (int)port,
+ log_warn(LD_DIR, "Bridge at %s:%d with transport %s (%s)",
+ fmt_addr(&addr), (int)port, transport_name,
fingerprint ? fingerprint : "no key listed");
- bridge_add_from_config(&addr, port, fingerprint ? digest : NULL);
+ bridge_add_from_config(&addr, port,
+ fingerprint ? digest : NULL/*, transport_name*/);
}
r = 0;
smartlist_free(items);
tor_free(addrport);
tor_free(fingerprint);
+ tor_free(transport_name);
return r;
}
+static int
+parse_transport_line(const char *line, int validate_only)
+{
+ smartlist_t *items = NULL;
+ int r;
+ char *socks_ver_str=NULL;
+ char *name=NULL;
+ char *addrport=NULL;
+ int socks_ver;
+ tor_addr_t addr;
+ uint16_t port = 0;
+
+ items = smartlist_create();
+ smartlist_split_string(items, line, NULL,
+ SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, -1);
+
+ if (smartlist_len(items) < 3) {
+ log_warn(LD_CONFIG, "parse_transport_line(): "
+ "Too few arguments on ClientTransportPlugin line.");
+ goto err;
+ }
+
+ name = smartlist_get(items, 0);
+ smartlist_del_keeporder(items, 0);
+
+ socks_ver_str = smartlist_get(items, 0);
+ smartlist_del_keeporder(items, 0);
+
+ if (!strcmp(socks_ver_str,"socks4"))
+ socks_ver = PROXY_SOCKS4;
+ else if (!strcmp(socks_ver_str,"socks5"))
+ socks_ver = PROXY_SOCKS5;
+ else {
+ log_warn(LD_CONFIG, "Strange transport proxy type.");
+ goto err;
+ }
+
+ addrport = smartlist_get(items, 0);
+ smartlist_del_keeporder(items, 0);
+
+ if (tor_addr_port_parse(addrport, &addr, &port)<0) {
+ log_warn(LD_CONFIG, "Error parsing transport "
+ "address '%s'", addrport);
+ goto err;
+ }
+
+ if (!port) {
+ log_warn(LD_CONFIG,
+ "Transport address '%s' has no port.", addrport);
+ goto err;
+ }
+
+ if (!validate_only) {
+ log_warn(LD_DIR, "Transport %s at %s:%d", name,
+ fmt_addr(&addr), (int)port);
+ /* transport_add_from_config(&addr, port,
+ fingerprint ? digest : NULL, transport); */
+ }
+
+ r = 0;
+ goto done;
+
+ err:
+ r = -1;
+
+ done:
+ SMARTLIST_FOREACH(items, char*, s, tor_free(s));
+ smartlist_free(items);
+ tor_free(socks_ver_str);
+ tor_free(name);
+ tor_free(addrport);
+ return r;
+}
+
/** Read the contents of a DirServer line from <b>line</b>. If
* <b>validate_only</b> is 0, and the line is well-formed, and it
* shares any bits with <b>required_type</b> or <b>required_type</b>