Index: main/manager.c =================================================================== --- main/manager.c (revisão 321327) +++ main/manager.c (cópia de trabalho) @@ -870,6 +870,10 @@ static int block_sockets; static int unauth_sessions = 0; +static char **enabled_events = NULL; +static char *name_events = NULL; +static int enabled_events_count = 0; + static int manager_debug; /*!< enable some debugging code in the manager */ /*! \brief @@ -1180,6 +1184,31 @@ return ret; } +static int set_enabled_events(const char *enabled_events_str) +{ + int aux_count; + enabled_events_count = 0; + + /* Make an array with the names of the events we received */ + if (!ast_strlen_zero(enabled_events_str)) { + name_events = ast_calloc(strlen(enabled_events_str), 1); + strcpy(name_events, enabled_events_str); + + enabled_events_count = 1; + aux_count = 1; + do { + if (name_events[aux_count] == ',') enabled_events_count++; + } while(name_events[aux_count++] != '\0'); + + enabled_events = ast_calloc(enabled_events_count, sizeof(char*)); + for(aux_count=0; aux_count < enabled_events_count; aux_count++) { + enabled_events[aux_count] = strsep(&name_events, ","); + } + } + + return 0; +} + /*! * A number returns itself, false returns 0, true returns all flags, * other strings return the flags that are set. @@ -4899,6 +4928,21 @@ if (!(sessions && ao2_container_count(sessions)) && AST_RWLIST_EMPTY(&manager_hooks)) { return 0; } + + if(enabled_events_count > 0) { + int found_enabled = 0, aux_count; + // Check if this event is enabled + for(aux_count=0; aux_count < enabled_events_count; aux_count++) { + if(!strcmp(event, enabled_events[aux_count])) { + found_enabled = 1; + break; + } + } + if(!found_enabled) { + ast_debug(1, "Event %s blocked. Not Enabled\n", event); + return 0; + } + } if (!(buf = ast_str_thread_get(&manager_event_buf, MANAGER_EVENT_BUF_INITSIZE))) { return -1; @@ -6362,6 +6406,8 @@ manager_debug = ast_true(val); } else if (!strcasecmp(var->name, "httptimeout")) { newhttptimeout = atoi(val); + } else if (!strcasecmp(var->name, "enabledevents")) { + set_enabled_events(val); } else if (!strcasecmp(var->name, "authtimeout")) { int timeout = atoi(var->value); Index: configs/manager.conf.sample =================================================================== --- configs/manager.conf.sample (revisão 321327) +++ configs/manager.conf.sample (cópia de trabalho) @@ -27,6 +27,12 @@ port = 5038 bindaddr = 0.0.0.0 +; enabledevents: if set, only the listed events will be sent to the clients +; and the hooks. Can be used to filter wich events the clients are expecting. +; If not set all events will be sent (default). + +;enabledevents=AgentCalled,AgentConnect,AgentComplete,AgentRingNoAnswer,AgentSkip,Join,Leave,QueueCallerAbandon,QueueParams,QueueEntry,Dial,OriginateResponse,Hangup,Shutdown + ; Parameters that control AMI over TLS. ("enabled" must be set too). ; You can open a connection to this socket with e.g. ;