Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
access/htsp: add HTSP anonymize function, fixes #3502
  • Loading branch information
perexg committed Feb 19, 2016
1 parent fb4c72d commit d974373
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 20 deletions.
15 changes: 14 additions & 1 deletion src/access.c
Expand Up @@ -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' : ' ',
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion src/access.h
Expand Up @@ -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;
Expand Down Expand Up @@ -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 \
Expand Down
10 changes: 10 additions & 0 deletions src/htsmsg.c
Expand Up @@ -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);
}

/*
*
*/
Expand Down
5 changes: 5 additions & 0 deletions src/htsmsg.h
Expand Up @@ -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.
*/
Expand Down
46 changes: 30 additions & 16 deletions src/htsp_server.c
Expand Up @@ -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;
}

/**
*
*/
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}

Expand All @@ -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");
Expand Down
5 changes: 3 additions & 2 deletions src/webui/static/app/acleditor.js
Expand Up @@ -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',
Expand Down

0 comments on commit d974373

Please sign in to comment.