From: Jaroslav Kysela Date: Fri, 19 Feb 2016 15:53:20 +0000 (+0100) Subject: access/htsp: add HTSP anonymize function, fixes #3502 X-Git-Tag: v4.2.1~1008 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d974373f1eb1a6e34759b0fbbb9c14000d08df06;p=thirdparty%2Ftvheadend.git access/htsp: add HTSP anonymize function, fixes #3502 --- diff --git a/src/access.c b/src/access.c index 1bf6e4d75..bd0051eda 100644 --- a/src/access.c +++ b/src/access.c @@ -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 ?: "", a->aa_username ?: "", 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, diff --git a/src/access.h b/src/access.h index 60462b53d..61cee6845 100644 --- a/src/access.h +++ b/src/access.h @@ -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 \ diff --git a/src/htsmsg.c b/src/htsmsg.c index 14a69f3ea..b68658b94 100644 --- a/src/htsmsg.c +++ b/src/htsmsg.c @@ -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); +} + /* * */ diff --git a/src/htsmsg.h b/src/htsmsg.h index 5672a1b84..02e21fc1a 100644 --- a/src/htsmsg.h +++ b/src/htsmsg.h @@ -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. */ diff --git a/src/htsp_server.c b/src/htsp_server.c index cbfac6cea..e4c8b6466 100644 --- a/src/htsp_server.c +++ b/src/htsp_server.c @@ -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"); diff --git a/src/webui/static/app/acleditor.js b/src/webui/static/app/acleditor.js index 6e46ceea9..de97e6c80 100644 --- a/src/webui/static/app/acleditor.js +++ b/src/webui/static/app/acleditor.js @@ -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',