From: Jaroslav Kysela Date: Tue, 20 Jun 2017 15:46:02 +0000 (+0200) Subject: satip server: add 'Anonymize' configuration option, fixes #4227 X-Git-Tag: v4.2.4~108 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a0a613a1e45fd78f989523c4838246b955695b3;p=thirdparty%2Ftvheadend.git satip server: add 'Anonymize' configuration option, fixes #4227 --- diff --git a/src/satip/rtsp.c b/src/satip/rtsp.c index fe313afd2..cfeeddc35 100644 --- a/src/satip/rtsp.c +++ b/src/satip/rtsp.c @@ -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); } diff --git a/src/satip/server.c b/src/satip/server.c index 88f06b4d0..3fd578e9d 100644 --- a/src/satip/server.c +++ b/src/satip/server.c @@ -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", diff --git a/src/satip/server.h b/src/satip/server.h index fd07c59fb..3de498d18 100644 --- a/src/satip/server.h +++ b/src/satip/server.h @@ -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;