libnm: fix return value for nm_wireguard_peer_append_allowed_ip()
According to documentation, this returns a boolean indicating whether
the value is valid. Previously, it was indicating whether the instance
was modified.
Together with the @accept_invalid argument, both behaviors make some
sense. Change it, because that is also how the other setters behave.
(cherry picked from commit f3ac8c6fe8
)
This commit is contained in:
@@ -647,6 +647,7 @@ _peer_append_allowed_ip (NMWireGuardPeer *self,
|
|||||||
int prefix;
|
int prefix;
|
||||||
NMIPAddr addrbin;
|
NMIPAddr addrbin;
|
||||||
char *str;
|
char *str;
|
||||||
|
gboolean is_valid = TRUE;
|
||||||
|
|
||||||
nm_assert (NM_IS_WIREGUARD_PEER (self, FALSE));
|
nm_assert (NM_IS_WIREGUARD_PEER (self, FALSE));
|
||||||
nm_assert (allowed_ip);
|
nm_assert (allowed_ip);
|
||||||
@@ -662,6 +663,7 @@ _peer_append_allowed_ip (NMWireGuardPeer *self,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
/* mark the entry as invalid by having a "X" prefix. */
|
/* mark the entry as invalid by having a "X" prefix. */
|
||||||
str = g_strconcat (ALLOWED_IP_INVALID_X_STR, allowed_ip, NULL);
|
str = g_strconcat (ALLOWED_IP_INVALID_X_STR, allowed_ip, NULL);
|
||||||
|
is_valid = FALSE;
|
||||||
} else {
|
} else {
|
||||||
char addrstr[NM_UTILS_INET_ADDRSTRLEN];
|
char addrstr[NM_UTILS_INET_ADDRSTRLEN];
|
||||||
|
|
||||||
@@ -679,7 +681,7 @@ _peer_append_allowed_ip (NMWireGuardPeer *self,
|
|||||||
self->allowed_ips = g_ptr_array_new_with_free_func (g_free);
|
self->allowed_ips = g_ptr_array_new_with_free_func (g_free);
|
||||||
|
|
||||||
g_ptr_array_add (self->allowed_ips, str);
|
g_ptr_array_add (self->allowed_ips, str);
|
||||||
return TRUE;
|
return is_valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user