static struct session *
rtsp_new_session(const char *ipstr, int delsys, uint32_t nsession, int session)
{
- struct session *rs = calloc(1, sizeof(*rs));
+ struct session *rs = NULL;
+ int count_s = satip_server_conf.satip_max_sessions;
+ int count_u = satip_server_conf.satip_max_user_connections;
+
+ if (count_s > 0 || count_u > 0)
+ TAILQ_FOREACH(rs, &rtsp_sessions, link) {
+ if (--count_s == 0) {
+ tvhnotice(LS_SATIPS, "Max number (%i) of active RTSP sessions reached.",
+ satip_server_conf.satip_max_sessions);
+ return NULL;
+ }
+ if (strcmp(rs->peer_ipstr, ipstr) == 0 && --count_i == 0) {
+ tvhnotice(LS_SATIPS, "Max number (%i) of active RTSP sessions per user (IP: %s).",
+ satip_server_conf.satip_max_user_connections, strdup(ipstr));
+ return NULL;
+ }
+ }
+ rs = calloc(1, sizeof(*rs));
if (rs == NULL)
return NULL;
if (cmd == RTSP_CMD_SETUP) {
if (!rs) {
rs = rtsp_new_session(hc->hc_peer_ipstr, msys, 0, -1);
+ if (rs == NULL) goto end;
if (delsys == DVB_SYS_NONE) goto end;
if (msys == DVB_SYS_NONE) goto end;
if (!(*valid)) goto end;
alloc_stream_id = 1;
} else if (stream != rs->stream) {
rs = rtsp_new_session(hc->hc_peer_ipstr, msys, rs->nsession, stream);
+ if (rs == NULL) goto end;
if (delsys == DVB_SYS_NONE) goto end;
if (msys == DVB_SYS_NONE) goto end;
if (!(*valid)) goto end;
.off = offsetof(struct satip_server_conf, satip_atsc_c),
.group = 4,
},
+ {
+ .type = PT_INT,
+ .id = "satip_max_sessions",
+ .name = N_("Max Sessions"),
+ .desc = N_("The maximum number of active RTSP sessions "
+ "(if 0 no limit)."),
+ .off = offsetof(struct satip_server_conf, satip_max_sessions),
+ .opts = PO_ADVANCED,
+ .group = 4,
+ },
+ {
+ .type = PT_INT,
+ .id = "satip_max_user_connections",
+ .name = N_("Max User connections"),
+ .desc = N_("The maximum concurrent RTSP connections from the "
+ "same IP address (if 0 no limit)."),
+ .off = offsetof(struct satip_server_conf, satip_max_user_connections),
+ .opts = PO_ADVANCED,
+ .group = 4,
+ },
{
.type = PT_BOOL,
.id = "satip_rewrite_pmt",