Project

General

Profile

Feature #4735 ยป SAT-IP-Max-Sessions-Max-User-connections.diff

Mono Polimorph, 2017-11-28 11:42

View differences:

src/satip/rtsp.c
183 183
static struct session *
184 184
rtsp_new_session(const char *ipstr, int delsys, uint32_t nsession, int session)
185 185
{
186
  struct session *rs = calloc(1, sizeof(*rs));
186
  struct session *rs = NULL;
187
  int count_s = satip_server_conf.satip_max_sessions;
188
  int count_u = satip_server_conf.satip_max_user_connections;
189

  
190
  if (count_s > 0 || count_u > 0)
191
  TAILQ_FOREACH(rs, &rtsp_sessions, link) {
192
    count_s--;
193
    if (count_s == 0) {
194
      tvhnotice(LS_SATIPS, "Max number (%i) of active RTSP sessions reached.",
195
                satip_server_conf.satip_max_sessions);
196
      return NULL;
197
    }
198
    if (strcmp(rs->peer_ipstr, strdup(ipstr)) == 0)
199
      count_u--;
200
    if (count_u == 0) {
201
      tvhnotice(LS_SATIPS, "Max number (%i) of active RTSP sessions per user (IP: %s).",
202
                satip_server_conf.satip_max_user_connections, strdup(ipstr));
203
      return NULL;
204
    }
205
  }
187 206

  
207
  rs = calloc(1, sizeof(*rs));
188 208
  if (rs == NULL)
189 209
    return NULL;
190 210

  
......
1024 1044
  if (cmd == RTSP_CMD_SETUP) {
1025 1045
    if (!rs) {
1026 1046
      rs = rtsp_new_session(hc->hc_peer_ipstr, msys, 0, -1);
1047
      if (rs == NULL) goto end;
1027 1048
      if (delsys == DVB_SYS_NONE) goto end;
1028 1049
      if (msys == DVB_SYS_NONE) goto end;
1029 1050
      if (!(*valid)) goto end;
1030 1051
      alloc_stream_id = 1;
1031 1052
    } else if (stream != rs->stream) {
1032 1053
      rs = rtsp_new_session(hc->hc_peer_ipstr, msys, rs->nsession, stream);
1054
      if (rs == NULL) goto end;
1033 1055
      if (delsys == DVB_SYS_NONE) goto end;
1034 1056
      if (msys == DVB_SYS_NONE) goto end;
1035 1057
      if (!(*valid)) goto end;
src/satip/server.c
873 873
      .group  = 4,
874 874
    },
875 875
    {
876
      .type   = PT_INT,
877
      .id     = "satip_max_sessions",
878
      .name   = N_("Max Sessions"),
879
      .desc   = N_("The maximum number of active RTSP sessions "
880
                   "(if 0 no limit)."),
881
      .off    = offsetof(struct satip_server_conf, satip_max_sessions),
882
      .opts   = PO_ADVANCED,
883
      .group  = 4,
884
    },
885
    {
886
      .type   = PT_INT,
887
      .id     = "satip_max_user_connections",
888
      .name   = N_("Max User connections"),
889
      .desc   = N_("The maximum concurrent RTSP connections from the "
890
                   "same IP address (if 0 no limit)."),
891
      .off    = offsetof(struct satip_server_conf, satip_max_user_connections),
892
      .opts   = PO_ADVANCED,
893
      .group  = 4,
894
    },
895
    {
876 896
      .type   = PT_BOOL,
877 897
      .id     = "satip_rewrite_pmt",
878 898
      .name   = N_("Rewrite PMT"),
src/satip/server.h
63 63
  int satip_dvbc2;
64 64
  int satip_atsc_t;
65 65
  int satip_atsc_c;
66
  int satip_max_sessions;
67
  int satip_max_user_connections;
66 68
  char *satip_nat_ip;
67 69
  int satip_nat_rtsp;
68 70
  int satip_nat_name_force;
    (1-1/1)