stroke: Allow %any as local address

Actually, resolving addresses in `left` might be overkill as we'll assume
left=local anyway (the only difference is the log message).
This commit is contained in:
Tobias Brunner
2015-08-21 18:19:26 +02:00
parent 8212f3d9a4
commit ffa20bad63
+7 -3
View File
@@ -186,7 +186,7 @@ static void add_proposals(private_stroke_config_t *this, char *string,
/** /**
* Check if any addresses in the given string are local * Check if any addresses in the given string are local
*/ */
static bool is_local(char *address) static bool is_local(char *address, bool any_allowed)
{ {
enumerator_t *enumerator; enumerator_t *enumerator;
host_t *host; host_t *host;
@@ -206,6 +206,10 @@ static bool is_local(char *address)
{ {
found = TRUE; found = TRUE;
} }
else if (any_allowed && host->is_anyaddr(host))
{
found = TRUE;
}
host->destroy(host); host->destroy(host);
if (found) if (found)
{ {
@@ -229,7 +233,7 @@ static void swap_ends(stroke_msg_t *msg)
return; return;
} }
if (is_local(msg->add_conn.other.address)) if (is_local(msg->add_conn.other.address, FALSE))
{ {
stroke_end_t tmp_end; stroke_end_t tmp_end;
@@ -238,7 +242,7 @@ static void swap_ends(stroke_msg_t *msg)
msg->add_conn.me = msg->add_conn.other; msg->add_conn.me = msg->add_conn.other;
msg->add_conn.other = tmp_end; msg->add_conn.other = tmp_end;
} }
else if (!is_local(msg->add_conn.me.address)) else if (!is_local(msg->add_conn.me.address, TRUE))
{ {
DBG1(DBG_CFG, "left nor right host is our side, assuming left=local"); DBG1(DBG_CFG, "left nor right host is our side, assuming left=local");
} }