stroke: Allow %any as local address
authorTobias Brunner <tobias@strongswan.org>
Mon, 3 Aug 2015 17:36:45 +0000 (19:36 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 21 Aug 2015 16:19:26 +0000 (18:19 +0200)
Actually, resolving addresses in `left` might be overkill as we'll assume
left=local anyway (the only difference is the log message).

src/libcharon/plugins/stroke/stroke_config.c

index afd88cb..f717194 100644 (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
  */
-static bool is_local(char *address)
+static bool is_local(char *address, bool any_allowed)
 {
        enumerator_t *enumerator;
        host_t *host;
@@ -206,6 +206,10 @@ static bool is_local(char *address)
                                {
                                        found = TRUE;
                                }
+                               else if (any_allowed && host->is_anyaddr(host))
+                               {
+                                       found = TRUE;
+                               }
                                host->destroy(host);
                                if (found)
                                {
@@ -229,7 +233,7 @@ static void swap_ends(stroke_msg_t *msg)
                return;
        }
 
-       if (is_local(msg->add_conn.other.address))
+       if (is_local(msg->add_conn.other.address, FALSE))
        {
                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.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");
        }