Index: main/manager.c =================================================================== --- main/manager.c (revisão 320797) +++ main/manager.c (cópia de trabalho) @@ -144,6 +144,10 @@ static int num_sessions; 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 @@ -472,6 +476,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. @@ -3431,6 +3460,21 @@ if (!num_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; @@ -4308,6 +4352,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 320797) +++ configs/manager.conf.sample (cópia de trabalho) @@ -25,6 +25,12 @@ ;webenabled = yes port = 5038 +; 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 + ; authtimeout specifies the maximum number of seconds a client has to ; authenticate. If the client does not authenticate beofre this timeout ; expires, the client will be disconnected. (default: 30 seconds)