diff --git a/ChangeLog b/ChangeLog index 118d059..172c2e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,10 @@ 0.8.4dev ======== + 27-Dec-2020: - plugin_stripheaders: deal with mode header field 17-Sep-2020: - fix: buffer overflow in process_aclist if a wrong syntax in config file was used for ACLs. - Improved string handling on some more places. + 0.8.3 ===== 25-Aug-2020: - Released 0.8.3 diff --git a/doc/siproxd.conf.example b/doc/siproxd.conf.example index 5ac9922..3c89444 100644 --- a/doc/siproxd.conf.example +++ b/doc/siproxd.conf.example @@ -448,16 +448,21 @@ plugin_regex_replace = \1:001 # # unconditionally strip the specified SIP header from the packet. # May be used to workaround IP fragmentation by removing "unimportant" -# SIP headers - this is clearly a ugly hack but sometimes saves on +# SIP headers - this is clearly a ugly hack but sometimes saves one # from headache. # Format is
[:], the : part is optional - if not # present the full header will be removed. +# NOTE: not all headers are surrently supported due to how libosip +# does store them internally. # # remove entire header (all values attached to this header) plugin_stripheader_remove = Allow plugin_stripheader_remove = User-Agent # remove only a particular value from a header (no spaces allowed) plugin_stripheader_remove = Supported:100rel +# remove all Record-Route headers (only full removal is supported) +plugin_stripheader_remove = Record-Route + ###################################################################### # Plugin_codecfilter diff --git a/src/plugin_stripheader.c b/src/plugin_stripheader.c index c69c17e..78da55c 100644 --- a/src/plugin_stripheader.c +++ b/src/plugin_stripheader.c @@ -112,6 +112,12 @@ int PLUGIN_PROCESS(int stage, sip_ticket_t *ticket){ header_remove = strdup(plugin_cfg.header_remove.string[i]); } + /* + * some headers are stored in their own struncture in the SIP message structure + * -> special cases + * and other headers are stored in a generic header structure + * -> generic headers + */ /* special case Allow header */ if (strcasecmp(header_remove, "allow") == 0) { @@ -121,7 +127,7 @@ int PLUGIN_PROCESS(int stage, sip_ticket_t *ticket){ pos, &allow)) != -1) { if (--dlc <= 0) { ERROR("deadlock counter has triggered. Likely a bug in code."); return STS_FAILURE;} if (header_remove_args == NULL) { - /* remova all values for header */ + /* remove all values for header */ DEBUGC(DBCLASS_PLUGIN, "%s: removing Allow header pos=%i, val=%s", name, pos, allow->value); osip_list_remove(&ticket->sipmsg->allows, pos); @@ -141,6 +147,24 @@ int PLUGIN_PROCESS(int stage, sip_ticket_t *ticket){ } } + /* special case: Record-Route headers */ + } else if (strcasecmp(header_remove, "record-route") == 0) { + osip_record_route_t *rroute=NULL; + pos=0; + while ((pos = osip_message_get_record_route(ticket->sipmsg, + pos, &rroute)) != -1) { + if (--dlc <= 0) { ERROR("deadlock counter has triggered. Likely a bug in code."); return STS_FAILURE;} + /* remove all values for header */ + char *tmpstr=NULL; + osip_record_route_to_str(rroute, &tmpstr); + DEBUGC(DBCLASS_PLUGIN, "%s: removing Record-Route header pos=%i, val=%s", name, + pos, tmpstr); + osip_free(tmpstr); + osip_list_remove(&ticket->sipmsg->record_routes, pos); + osip_record_route_free(rroute); + rroute=NULL; + } + /* generic headers */ } else { osip_header_t *h=NULL;