Advertisement
Guest User

Untitled

a guest
Apr 15th, 2016
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. diff --git a/src/subscriptions.c b/src/subscriptions.c
  2. index 276cade..26a2a96 100644
  3. --- a/src/subscriptions.c
  4. +++ b/src/subscriptions.c
  5. @@ -1225,3 +1225,32 @@ void subscription_log(th_subscription_t *s, int on)
  6. }
  7. }
  8.  
  9. +int subscription_get_user_count_on_other_muxes(char *username, tvh_uuid_t mux_uuid)
  10. +{
  11. + th_subscription_t *s;
  12. + int count;
  13. +
  14. + tvhinfo("dbg", "listing subscriptions for %s on other muxes", username);
  15. +
  16. + count = 0;
  17. +
  18. + LIST_FOREACH(s, &subscriptions, ths_global_link) {
  19. + tvhinfo("dbg", "=>chan=0x%x, srv=0x%x", s->ths_channel?1:0, s->ths_service?1:0);
  20. + if (s->ths_service)
  21. + {
  22. + source_info_t si;
  23. + s->ths_service->s_setsourceinfo(s->ths_service, &si);
  24. + tvhinfo("dbg", "subscription from %s on %s", s->ths_username?:"no-user", s->ths_channel->ch_name);
  25. + if (s->ths_username && username && !strcmp(username, s->ths_username) && uuid_cmp(&si.si_mux_uuid, &mux_uuid))
  26. + {
  27. + tvhinfo("dbg", "OTHER MUX");
  28. + count++;
  29. + }
  30. + }
  31. + }
  32. +
  33. + tvhinfo("dbg", "%s has %d subscriptions on other muxes", username, count);
  34. +
  35. + return count;
  36. +}
  37. +
  38. diff --git a/src/subscriptions.h b/src/subscriptions.h
  39. index 5fb5ecf..a6a610a 100644
  40. --- a/src/subscriptions.h
  41. +++ b/src/subscriptions.h
  42. @@ -231,4 +231,6 @@ static inline int subscriptions_active(void)
  43. struct htsmsg;
  44. struct htsmsg *subscription_create_msg(th_subscription_t *s, const char *lang);
  45.  
  46. +int subscription_get_user_count_on_other_muxes(char *username, tvh_uuid_t mux_uuid);
  47. +
  48. #endif /* SUBSCRIPTIONS_H */
  49. diff --git a/src/webui/webui.c b/src/webui/webui.c
  50. index bca4d92..9ccac87 100644
  51. --- a/src/webui/webui.c
  52. +++ b/src/webui/webui.c
  53. @@ -1211,6 +1211,8 @@ http_stream_channel(http_connection_t *hc, channel_t *ch, int weight)
  54. const char *name;
  55. void *tcp_id;
  56. int res = HTTP_STATUS_SERVICE;
  57. + idnode_list_mapping_t* ilm;
  58. + service_t* ch_first_service;
  59.  
  60. if (http_access_verify_channel(hc, ACCESS_STREAMING, ch))
  61. return HTTP_STATUS_UNAUTHORIZED;
  62. @@ -1232,6 +1234,24 @@ http_stream_channel(http_connection_t *hc, channel_t *ch, int weight)
  63. else
  64. qsize = 1500000;
  65.  
  66. + ilm = LIST_FIRST(&ch->ch_services);
  67. + if (ilm)
  68. + {
  69. + ch_first_service = (service_t* )ilm->ilm_in1;
  70. + if (ch_first_service)
  71. + {
  72. + source_info_t si;
  73. + int count;
  74. + ch_first_service->s_setsourceinfo(ch_first_service, &si);
  75. + count = subscription_get_user_count_on_other_muxes(hc->hc_username?:(hc->hc_access?hc->hc_access->aa_username:NULL), si.si_mux_uuid);
  76. + if (count > 0)
  77. + {
  78. + tvherror("webui", "User is already using %d muxes while the max is %d", count, 1);
  79. + return HTTP_STATUS_NOT_ALLOWED;
  80. + }
  81. + }
  82. + }
  83. +
  84. profile_chain_init(&prch, pro, ch);
  85. if (!profile_chain_open(&prch, NULL, 0, qsize)) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement