mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +01:00
ClientTransportPlugin parsing done.
This commit is contained in:
parent
ecc9a364c2
commit
20c31c80fb
119
src/or/config.c
119
src/or/config.c
@ -203,8 +203,9 @@ static config_var_t _option_vars[] = {
|
|||||||
V(CircuitStreamTimeout, INTERVAL, "0"),
|
V(CircuitStreamTimeout, INTERVAL, "0"),
|
||||||
V(CircuitPriorityHalflife, DOUBLE, "-100.0"), /*negative:'Use default'*/
|
V(CircuitPriorityHalflife, DOUBLE, "-100.0"), /*negative:'Use default'*/
|
||||||
V(ClientDNSRejectInternalAddresses, BOOL,"1"),
|
V(ClientDNSRejectInternalAddresses, BOOL,"1"),
|
||||||
V(ClientRejectInternalAddresses, BOOL, "1"),
|
|
||||||
V(ClientOnly, BOOL, "0"),
|
V(ClientOnly, BOOL, "0"),
|
||||||
|
V(ClientRejectInternalAddresses, BOOL, "1"),
|
||||||
|
VAR("ClientTransportPlugin", LINELIST, ClientTransportPlugin, NULL),
|
||||||
V(ConsensusParams, STRING, NULL),
|
V(ConsensusParams, STRING, NULL),
|
||||||
V(ConnLimit, UINT, "1000"),
|
V(ConnLimit, UINT, "1000"),
|
||||||
V(ConnDirectionStatistics, BOOL, "0"),
|
V(ConnDirectionStatistics, BOOL, "0"),
|
||||||
@ -570,6 +571,7 @@ static int check_nickname_list(const char *lst, const char *name, char **msg);
|
|||||||
static void config_register_addressmaps(or_options_t *options);
|
static void config_register_addressmaps(or_options_t *options);
|
||||||
|
|
||||||
static int parse_bridge_line(const char *line, int validate_only);
|
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,
|
static int parse_dir_server_line(const char *line,
|
||||||
dirinfo_type_t required_type,
|
dirinfo_type_t required_type,
|
||||||
int validate_only);
|
int validate_only);
|
||||||
@ -1205,6 +1207,17 @@ options_act(or_options_t *old_options)
|
|||||||
if (consider_adding_dir_authorities(options, old_options) < 0)
|
if (consider_adding_dir_authorities(options, old_options) < 0)
|
||||||
return -1;
|
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) {
|
if (options->Bridges) {
|
||||||
mark_bridge_list();
|
mark_bridge_list();
|
||||||
for (cl = options->Bridges; cl; cl = cl->next) {
|
for (cl = options->Bridges; cl; cl = cl->next) {
|
||||||
@ -3663,6 +3676,16 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|||||||
|
|
||||||
if (options->UseBridges && !options->TunnelDirConns)
|
if (options->UseBridges && !options->TunnelDirConns)
|
||||||
REJECT("TunnelDirConns set to 0 only works with UseBridges set to 0");
|
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) {
|
if (options->Bridges) {
|
||||||
for (cl = options->Bridges; cl; cl = cl->next) {
|
for (cl = options->Bridges; cl; cl = cl->next) {
|
||||||
if (parse_bridge_line(cl->value, 1)<0)
|
if (parse_bridge_line(cl->value, 1)<0)
|
||||||
@ -4553,6 +4576,8 @@ parse_bridge_line(const char *line, int validate_only)
|
|||||||
smartlist_t *items = NULL;
|
smartlist_t *items = NULL;
|
||||||
int r;
|
int r;
|
||||||
char *addrport=NULL, *fingerprint=NULL;
|
char *addrport=NULL, *fingerprint=NULL;
|
||||||
|
char *transport_name=NULL;
|
||||||
|
char *field1=NULL;
|
||||||
tor_addr_t addr;
|
tor_addr_t addr;
|
||||||
uint16_t port = 0;
|
uint16_t port = 0;
|
||||||
char digest[DIGEST_LEN];
|
char digest[DIGEST_LEN];
|
||||||
@ -4564,8 +4589,18 @@ parse_bridge_line(const char *line, int validate_only)
|
|||||||
log_warn(LD_CONFIG, "Too few arguments to Bridge line.");
|
log_warn(LD_CONFIG, "Too few arguments to Bridge line.");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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);
|
addrport = smartlist_get(items, 0);
|
||||||
smartlist_del_keeporder(items, 0);
|
smartlist_del_keeporder(items, 0);
|
||||||
|
} else
|
||||||
|
addrport = field1;
|
||||||
|
|
||||||
if (tor_addr_port_parse(addrport, &addr, &port)<0) {
|
if (tor_addr_port_parse(addrport, &addr, &port)<0) {
|
||||||
log_warn(LD_CONFIG, "Error parsing Bridge address '%s'", addrport);
|
log_warn(LD_CONFIG, "Error parsing Bridge address '%s'", addrport);
|
||||||
goto err;
|
goto err;
|
||||||
@ -4590,10 +4625,11 @@ parse_bridge_line(const char *line, int validate_only)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!validate_only) {
|
if (!validate_only) {
|
||||||
log_debug(LD_DIR, "Bridge at %s:%d (%s)", fmt_addr(&addr),
|
log_warn(LD_DIR, "Bridge at %s:%d with transport %s (%s)",
|
||||||
(int)port,
|
fmt_addr(&addr), (int)port, transport_name,
|
||||||
fingerprint ? fingerprint : "no key listed");
|
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;
|
r = 0;
|
||||||
@ -4607,6 +4643,81 @@ parse_bridge_line(const char *line, int validate_only)
|
|||||||
smartlist_free(items);
|
smartlist_free(items);
|
||||||
tor_free(addrport);
|
tor_free(addrport);
|
||||||
tor_free(fingerprint);
|
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;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2660,6 +2660,8 @@ typedef struct {
|
|||||||
|
|
||||||
config_line_t *Bridges; /**< List of bootstrap bridge addresses. */
|
config_line_t *Bridges; /**< List of bootstrap bridge addresses. */
|
||||||
|
|
||||||
|
config_line_t *ClientTransportPlugin; /**< List of client transport plugins. */
|
||||||
|
|
||||||
int BridgeRelay; /**< Boolean: are we acting as a bridge relay? We make
|
int BridgeRelay; /**< Boolean: are we acting as a bridge relay? We make
|
||||||
* this explicit so we can change how we behave in the
|
* this explicit so we can change how we behave in the
|
||||||
* future. */
|
* future. */
|
||||||
|
Loading…
Reference in New Issue
Block a user