dbus: SAT>IP allow to block the server by IP address

This commit is contained in:
Jaroslav Kysela 2014-08-08 17:19:33 +02:00
parent 9d6ab33b98
commit 840a0ae05c
4 changed files with 46 additions and 0 deletions

View file

@ -227,6 +227,9 @@ dbus_reply_to_rpc(dbus_rpc_t *rpc, DBusMessage *msg, DBusConnection *conn)
path = dbus_message_get_path(msg);
if (path == NULL)
return;
if (strncmp(path, "/org/tvheadend/", 15))
return;
path += 14;
if (!dbus_message_iter_init(msg, &args))
return;
if (rpc->rpc_s64) {

View file

@ -55,6 +55,46 @@ satip_device_dbus_notify( satip_device_t *sd, const char *sig_name )
#endif
}
static void
satip_device_block( const char *addr, int block )
{
extern const idclass_t satip_device_class;
tvh_hardware_t *th;
satip_device_t *sd;
satip_frontend_t *lfe;
pthread_mutex_lock(&global_lock);
TVH_HARDWARE_FOREACH(th) {
if (!idnode_is_instance(&th->th_id, &satip_device_class))
continue;
sd = (satip_device_t *)th;
if (strcmp(sd->sd_info.addr, addr) == 0) {
sd->sd_dbus_block = block < 0 ? 0 : block;
if (block < 0) {
TAILQ_FOREACH(lfe, &sd->sd_frontends, sf_link)
mpegts_input_stop_all((mpegts_input_t *)lfe);
}
}
}
pthread_mutex_unlock(&global_lock);
}
static char *
satip_device_addr( void *aux, const char *path, char *value )
{
if (strcmp(path, "/stop") == 0) {
satip_device_block(value, -1);
return strdup("ok");
} else if (strcmp(path, "/disable") == 0) {
satip_device_block(value, 0);
return strdup("ok");
} else if (strcmp(path, "/allow") == 0) {
satip_device_block(value, 1);
return strdup("ok");
}
return strdup("err");
}
/*
* SAT-IP client
*/
@ -978,6 +1018,7 @@ void satip_init ( str_list_t *clients )
{
TAILQ_INIT(&satip_discoveries);
satip_static_clients = clients;
dbus_register_rpc_str("satip_addr", NULL, satip_device_addr);
satip_device_discovery_start();
}

View file

@ -376,6 +376,7 @@ satip_frontend_is_enabled ( mpegts_input_t *mi, mpegts_mux_t *mm,
lock_assert(&global_lock);
if (!mpegts_input_is_enabled(mi, mm, reason)) return 0;
if (lfe->sf_device->sd_dbus_block) return 0;
if (lfe->sf_type != DVB_TYPE_S) return 1;
/* check if the position is enabled */
position = satip_satconf_get_position(lfe, mm);

View file

@ -81,6 +81,7 @@ struct satip_device
int sd_sig_scale;
int sd_pids0;
int sd_pilot_on;
int sd_dbus_block;
pthread_mutex_t sd_tune_mutex;
};