]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
access/htsp: add HTSP anonymize function, fixes #3502
authorJaroslav Kysela <perex@perex.cz>
Fri, 19 Feb 2016 15:53:20 +0000 (16:53 +0100)
committerJaroslav Kysela <perex@perex.cz>
Fri, 19 Feb 2016 15:53:20 +0000 (16:53 +0100)
src/access.c
src/access.h
src/htsmsg.c
src/htsmsg.h
src/htsp_server.c
src/webui/static/app/acleditor.js

index 1bf6e4d752343e1a9fae3270469f40bec983d216..bd0051edaa2bb1961ea74067edf1abe8d1c901d9 100644 (file)
@@ -407,7 +407,7 @@ access_dump_a(access_t *a)
   int first;
 
   tvh_strlcatf(buf, sizeof(buf), l,
-    "%s:%s [%c%c%c%c%c%c%c%c%c%c], conn=%u:s%u:r%u:l%u%s",
+    "%s:%s [%c%c%c%c%c%c%c%c%c%c%c], conn=%u:s%u:r%u:l%u%s",
     a->aa_representative ?: "<no-id>",
     a->aa_username ?: "<no-user>",
     a->aa_rights & ACCESS_STREAMING          ? 'S' : ' ',
@@ -419,6 +419,7 @@ access_dump_a(access_t *a)
     a->aa_rights & ACCESS_ALL_RECORDER       ? 'L' : ' ',
     a->aa_rights & ACCESS_ALL_RW_RECORDER    ? 'D' : ' ',
     a->aa_rights & ACCESS_FAILED_RECORDER    ? 'F' : ' ',
+    a->aa_rights & ACCESS_HTSP_ANONYMIZE     ? 'H' : ' ',
     a->aa_rights & ACCESS_ADMIN              ? '*' : ' ',
     a->aa_conn_limit,
     a->aa_conn_limit_streaming,
@@ -1022,6 +1023,8 @@ access_entry_update_rights(access_entry_t *ae)
     r |= ACCESS_ALL_RW_RECORDER;
   if (ae->ae_failed_dvr)
     r |= ACCESS_FAILED_RECORDER;
+  if (ae->ae_htsp_anonymize)
+    r |= ACCESS_HTSP_ANONYMIZE;
   if (ae->ae_admin)
     r |= ACCESS_ADMIN;
   ae->ae_rights = r;
@@ -1553,6 +1556,16 @@ const idclass_t access_entry_class = {
       .off      = offsetof(access_entry_t, ae_failed_dvr),
       .opts     = PO_ADVANCED | PO_HIDDEN,
     },
+    {
+      .type     = PT_BOOL,
+      .id       = "htsp_anonymize",
+      .name     = N_("Anonymize HTSP access"),
+      .desc     = N_("Do not send any stream specific information to"
+                     "the HTSP client like signal strenght, input source"
+                     "etc."),
+      .off      = offsetof(access_entry_t, ae_htsp_anonymize),
+      .opts     = PO_ADVANCED | PO_HIDDEN,
+    },
     {
       .type     = PT_STR,
       .islist   = 1,
index 60462b53d5bae4fe5ddab0b7c2e4ce510e32a0b5..61cee6845e49d3355a42fe645ccfe1cfe1245bd1 100644 (file)
@@ -120,6 +120,8 @@ typedef struct access_entry {
   int ae_all_rw_dvr;
   int ae_failed_dvr;
 
+  int ae_htsp_anonymize;
+
   idnode_list_head_t ae_dvr_configs;
 
   int ae_webui;
@@ -184,7 +186,8 @@ typedef struct access_ticket {
 #define ACCESS_ALL_RECORDER       (1<<7)
 #define ACCESS_ALL_RW_RECORDER    (1<<8)
 #define ACCESS_FAILED_RECORDER    (1<<9)
-#define ACCESS_ADMIN              (1<<10)
+#define ACCESS_HTSP_ANONYMIZE     (1<<10)
+#define ACCESS_ADMIN              (1<<11)
 #define ACCESS_OR                 (1<<30)
 
 #define ACCESS_FULL \
index 14a69f3ea08f59bc8bd8950e942ec8b852fbbd86..b68658b94aef9a92dcd1b17cc3e3e660b593ad51 100644 (file)
@@ -276,6 +276,16 @@ htsmsg_add_str(htsmsg_t *msg, const char *name, const char *str)
   f->hmf_str = strdup(str);
 }
 
+/*
+ *
+ */
+void
+htsmsg_add_str2(htsmsg_t *msg, const char *name, const char *str)
+{
+  if (msg && name && str)
+    htsmsg_add_str(msg, name, str);
+}
+
 /*
  *
  */
index 5672a1b84f9131a7045875f9c2856d734717173d..02e21fc1acbd6f8b50b7bc0fbeab302d5ea147c6 100644 (file)
@@ -155,6 +155,11 @@ htsmsg_set_s32(htsmsg_t *msg, const char *name,  int32_t s32)
  */
 void htsmsg_add_str(htsmsg_t *msg, const char *name, const char *str);
 
+/**
+ * Add a string field (NULL check).
+ */
+void htsmsg_add_str2(htsmsg_t *msg, const char *name, const char *str);
+
 /**
  * Add a string field to a list only once.
  */
index cbfac6ceadd8c35e2bfcdceec864fee6769b4656..e4c8b6466182cf376a57319ff3f6d2547f1b865c 100644 (file)
@@ -276,6 +276,12 @@ htsp_is_stream_enabled(htsp_subscription_t *hs, unsigned int id)
   return 1;
 }
 
+static inline int
+htsp_anonymize(htsp_connection_t *htsp)
+{
+  return (htsp->htsp_granted_access->aa_rights & ACCESS_HTSP_ANONYMIZE) != 0;
+}
+
 /**
  *
  */
@@ -3953,13 +3959,15 @@ htsp_subscription_start(htsp_subscription_t *hs, const streaming_start_t *ss)
     uuid_bin2hex(&si->si_network_uuid, &hex);
     htsmsg_add_str(sourceinfo, "network_uuid", hex.hex);
   }
-  if(si->si_adapter ) htsmsg_add_str(sourceinfo, "adapter",  si->si_adapter );
-  if(si->si_mux     ) htsmsg_add_str(sourceinfo, "mux"    ,  si->si_mux     );
-  if(si->si_network ) htsmsg_add_str(sourceinfo, "network",  si->si_network );
-  if(si->si_network_type) htsmsg_add_str(sourceinfo, "network_type",  si->si_network_type );
-  if(si->si_provider) htsmsg_add_str(sourceinfo, "provider", si->si_provider);
-  if(si->si_service ) htsmsg_add_str(sourceinfo, "service",  si->si_service );
-  if(si->si_satpos  ) htsmsg_add_str(sourceinfo, "satpos",   si->si_satpos  );
+  if (!htsp_anonymize(hs->hs_htsp)) {
+    htsmsg_add_str2(sourceinfo, "adapter",      si->si_adapter     );
+    htsmsg_add_str2(sourceinfo, "mux",          si->si_mux         );
+    htsmsg_add_str2(sourceinfo, "network",      si->si_network     );
+    htsmsg_add_str2(sourceinfo, "network_type", si->si_network_type);
+    htsmsg_add_str2(sourceinfo, "provider",     si->si_provider    );
+    htsmsg_add_str2(sourceinfo, "service",      si->si_service     );
+    htsmsg_add_str2(sourceinfo, "satpos",       si->si_satpos      );
+  }
   
   htsmsg_add_msg(m, "sourceinfo", sourceinfo);
  
@@ -4080,15 +4088,19 @@ htsp_subscription_signal_status(htsp_subscription_t *hs, signal_status_t *sig)
   htsmsg_t *m = htsmsg_create_map();
   htsmsg_add_str(m, "method", "signalStatus");
   htsmsg_add_u32(m, "subscriptionId", hs->hs_sid);
-  htsmsg_add_str(m, "feStatus",   sig->status_text);
-  if((sig->snr != -2) && (sig->snr_scale == SIGNAL_STATUS_SCALE_RELATIVE))
-    htsmsg_add_u32(m, "feSNR",    sig->snr);
-  if((sig->signal != -2) && (sig->signal_scale == SIGNAL_STATUS_SCALE_RELATIVE))
-    htsmsg_add_u32(m, "feSignal", sig->signal);
-  if(sig->ber != -2)
-    htsmsg_add_u32(m, "feBER",    sig->ber);
-  if(sig->unc != -2)
-    htsmsg_add_u32(m, "feUNC",    sig->unc);
+  if (!htsp_anonymize(hs->hs_htsp)) {
+    htsmsg_add_str(m, "feStatus",   sig->status_text);
+    if((sig->snr != -2) && (sig->snr_scale == SIGNAL_STATUS_SCALE_RELATIVE))
+      htsmsg_add_u32(m, "feSNR",    sig->snr);
+    if((sig->signal != -2) && (sig->signal_scale == SIGNAL_STATUS_SCALE_RELATIVE))
+      htsmsg_add_u32(m, "feSignal", sig->signal);
+    if(sig->ber != -2)
+      htsmsg_add_u32(m, "feBER",    sig->ber);
+    if(sig->unc != -2)
+      htsmsg_add_u32(m, "feUNC",    sig->unc);
+  } else {
+    htsmsg_add_str(m, "feStatus", "");
+  }
   htsp_send_message(hs->hs_htsp, m, &hs->hs_htsp->htsp_hmq_qstatus);
 }
 
@@ -4101,6 +4113,8 @@ htsp_subscription_descramble_info(htsp_subscription_t *hs, descramble_info_t *di
   /* don't bother old clients */
   if (hs->hs_htsp->htsp_version < 24)
     return;
+  if (htsp_anonymize(hs->hs_htsp))
+    return;
 
   htsmsg_t *m = htsmsg_create_map();
   htsmsg_add_str(m, "method", "descrambleInfo");
index 6e46ceea910e9653004e895354256fd8f3da516f..de97e6c807e6c781a53bd1669d4947b57055c6b7 100644 (file)
@@ -17,8 +17,9 @@ tvheadend.acleditor = function(panel, index)
                 'streaming,adv_streaming,htsp_streaming,' +
                 'profile,conn_limit_type,conn_limit,' +
                 'dvr,htsp_dvr,all_dvr,all_rw_dvr,' +
-                'failed_dvr,dvr_config,channel_min,channel_max,' +
-                'channel_tag_exclude,channel_tag,comment';
+                'failed_dvr,htsp_anonymize,dvr_config,' +
+                'channel_min,channel_max,channel_tag_exclude,' +
+                'channel_tag,comment';
 
     tvheadend.idnode_grid(panel, {
         id: 'access_entry',