]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
satip server: add 'Anonymize' configuration option, fixes #4227
authorJaroslav Kysela <perex@perex.cz>
Tue, 20 Jun 2017 15:46:02 +0000 (17:46 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 6 Jul 2017 13:23:37 +0000 (15:23 +0200)
src/satip/rtsp.c
src/satip/server.c
src/satip/server.h

index fe313afd2ad21436cb6bb20fb8f50d4222830343..cfeeddc354cbcf3deb63000230cf81dc796653ff 100644 (file)
@@ -44,6 +44,7 @@ typedef struct slave_subscription {
 
 typedef struct session {
   TAILQ_ENTRY(session) link;
+  char *peer_ipstr;
   int delsys;
   int stream;
   int frontend;
@@ -169,13 +170,14 @@ result:
  *
  */
 static struct session *
-rtsp_new_session(int delsys, uint32_t nsession, int session)
+rtsp_new_session(const char *ipstr, int delsys, uint32_t nsession, int session)
 {
   struct session *rs = calloc(1, sizeof(*rs));
 
   if (rs == NULL)
     return NULL;
 
+  rs->peer_ipstr = strdup(ipstr);
   rs->nsession = nsession ?: session_number;
   snprintf(rs->session, sizeof(rs->session), "%08X", session_number);
   if (!nsession) {
@@ -197,7 +199,9 @@ rtsp_find_session(http_connection_t *hc, int stream)
   struct session *rs, *first = NULL;
 
   TAILQ_FOREACH(rs, &rtsp_sessions, link) {
-    if (hc->hc_session && !strcmp(rs->session, hc->hc_session)) {
+    if (hc->hc_session &&
+        strcmp(rs->session, hc->hc_session) == 0 &&
+        strcmp(rs->peer_ipstr, hc->hc_peer_ipstr) == 0) {
       if (stream == rs->stream)
         return rs;
       if (first == NULL)
@@ -922,12 +926,12 @@ rtsp_parse_cmd
 
   if (cmd) {
     if (!rs) {
-      rs = rtsp_new_session(msys, 0, -1);
+      rs = rtsp_new_session(hc->hc_peer_ipstr, msys, 0, -1);
       if (delsys == DVB_SYS_NONE) goto end;
       if (msys == DVB_SYS_NONE) goto end;
       if (!(*valid)) goto end;
     } else if (stream != rs->stream) {
-      rs = rtsp_new_session(msys, rs->nsession, stream);
+      rs = rtsp_new_session(hc->hc_peer_ipstr, msys, rs->nsession, stream);
       if (delsys == DVB_SYS_NONE) goto end;
       if (msys == DVB_SYS_NONE) goto end;
       if (!(*valid)) goto end;
@@ -1305,6 +1309,9 @@ rtsp_process_describe(http_connection_t *hc)
       if (stream > 0 && rs->stream != stream)
         continue;
     }
+    if (satip_server_conf.satip_anonymize &&
+        strcmp(hc->hc_peer_ipstr, rs->peer_ipstr))
+      continue;
     if (first) {
       rtsp_describe_header(hc->hc_session ? rs : NULL, &q);
       first = 0;
@@ -1604,6 +1611,7 @@ rtsp_free_session(session_t *rs)
   mtimer_disarm(&rs->timer);
   pthread_mutex_unlock(&global_lock);
   mpegts_pid_done(&rs->pids);
+  free(rs->peer_ipstr);
   free(rs);
 }
 
index 88f06b4d05fa6aadd42aa9f5e593f46ef3a6cf46..3fd578e9d9609082fafd6ed10cf25e8a0cdde3a1 100644 (file)
@@ -635,6 +635,15 @@ const idclass_t satip_server_class = {
       .off    = offsetof(struct satip_server_conf, satip_rtsp),
       .group  = 1,
     },
+    {
+      .type   = PT_BOOL,
+      .id     = "satip_anonymize",
+      .name   = N_("Anonymize"),
+      .desc   = N_("Show only information for sessions which "
+                   "are initiated from an IP address of the requester."),
+      .off    = offsetof(struct satip_server_conf, satip_anonymize),
+      .group  = 1,
+    },
     {
       .type   = PT_INT,
       .id     = "satip_weight",
index fd07c59fb07e69d66205a74c1b2c21847aa11ea5..3de498d1819486ac3aa17e0d228c2a39434ba37c 100644 (file)
@@ -47,6 +47,7 @@ struct satip_server_conf {
   int satip_rewrite_pmt;
   int satip_muxcnf;
   int satip_nom3u;
+  int satip_anonymize;
   int satip_iptv_sig_level;
   int satip_dvbs;
   int satip_dvbs2;