summaryrefslogtreecommitdiff
path: root/src/lib.c
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2014-07-28 07:08:56 (GMT)
committerNirbheek Chauhan <nirbheek@centricular.com>2014-07-28 07:08:56 (GMT)
commit06a53c87bf2870967ced8af0b32927dfbd7363ca (patch)
treece37cf90d92919072a5bbb4fd78c59d527afa33e /src/lib.c
parent9e9eb34d73873c4488d0fe69002dd53e463d62fc (diff)
downloadsoup-transcoding-proxy-06a53c87bf2870967ced8af0b32927dfbd7363ca.zip
soup-transcoding-proxy-06a53c87bf2870967ced8af0b32927dfbd7363ca.tar.gz
server: Verify the UDP client list during token validation
Diffstat (limited to 'src/lib.c')
-rw-r--r--src/lib.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/lib.c b/src/lib.c
index cc36292..ec32660 100644
--- a/src/lib.c
+++ b/src/lib.c
@@ -88,6 +88,55 @@ stp_validate_token_server (GInetAddressMask *mask,
return ret;
}
+gboolean stp_clients_is_subset (char *superset,
+ char *subset)
+{
+ gsize i, n;
+ gboolean ret;
+ char **supersetv, **subsetv;
+ GHashTable *superset_table = NULL;
+
+ if (!subset)
+ return TRUE;
+
+ if (!superset)
+ return FALSE;
+
+ /* Simplest case */
+ if (g_strcmp0 (superset, subset) == 0)
+ return TRUE;
+
+ subsetv = g_strsplit (subset, ",", 0);
+ supersetv = g_strsplit (superset, ",", 0);
+
+ if (sizeof(supersetv)/sizeof(supersetv[0]) <= 1 ||
+ sizeof(subsetv)/sizeof(subsetv[0]) < 1)
+ /* If there's one client in the superset, and the subset didn't match,
+ * it won't match. Same if there's less than one client in either list. */
+ goto fail;
+
+ /* Easiest way to check. Add superset clients to a table, and then check
+ * whether every subset client is in that table. */
+ superset_table = g_hash_table_new (g_str_hash, g_str_equal);
+ for (i = 0, n = sizeof(supersetv)/sizeof(supersetv[0]); i < n; i++)
+ g_hash_table_add (superset_table, supersetv[i]);
+
+ for (i = 0, n = sizeof(subsetv)/sizeof(subsetv[0]); i < n; i++)
+ if (!g_hash_table_contains (superset_table, subsetv[i]))
+ goto fail;
+
+ ret = TRUE;
+out:
+ if (superset_table)
+ g_hash_table_destroy (superset_table);
+ g_strfreev (supersetv);
+ g_strfreev (subsetv);
+ return ret;
+fail:
+ ret = FALSE;
+ goto out;
+}
+
gboolean
stp_on_gst_bus_message (GstBus *bus,
GstMessage *msg,