sipcapture / homer-app

HOMER 7.x Front-End and API Server
http://sipcapture.io
GNU Affero General Public License v3.0
205 stars 84 forks source link

Correlation using wildcard? #386

Closed flantel closed 4 years ago

flantel commented 4 years ago

Hi,

We have a b2bua which modifies the A and B leg CallIDs by taking (up to) the first 30 chars before any '@' sign of the A-Leg CID then adds "_@new_domain" to create the B-Leg.

I have a mapping rule which catches this, but as I only know up to the first 30 chars, the only way I could express it is with a % wildcard. However, as the resulting query is "sid in ($1, $2)" wildcards don't work. Is there any way around this?

Thanks

lmangani commented 4 years ago

Hi Barry,

Please provide the current version of your mapping script and some example and we'll be happy to make a suggestion.

flantel commented 4 years ago

Sure. I have a script called callid_genband created under Advanced:

var returnData=[];
var genband_b=[];

for (var i = 0; i < data.length; i++)
{ 
    genband_b = data[i].match(/^.[^@]{1,29}/);
    returnData.push(genband_b + '%');

} 
returnData;

..and my mapping script is as follows.

[
    {
        "source_field": "data_header.callid",
        "lookup_id": 100,
        "lookup_profile": "default",
        "lookup_field": "sid",
        "lookup_range": [
            -300,
            200
        ],
        "input_script": "callid_genband"
    },
    {
        "source_field": "data_header.callid",
        "lookup_id": 5,
        "lookup_profile": "call",
        "lookup_field": "sid",
        "lookup_range": [
            -300,
            200
        ],
        "input_script": "callid_genband"
    },
    {
        "source_field": "protocol_header.correlation_id",
        "lookup_id": 1,
        "lookup_profile": "call",
        "lookup_field": "sid",
        "lookup_range": [
            -300,
            200
        ],
        "input_script": "callid_genband"
    },
    {
        "source_field": "data_header.callid",
        "lookup_id": 1,
        "lookup_profile": "call",
        "lookup_field": "data_header->>'callid'",
        "lookup_range": [
            -300,
            200
        ],
        "input_script": "callid_genband"
    }
]

I can see that the search is being performed as per my script as the homer.app logs show "sid array after JS:" correctly.

homer-app is from revision 6d0e6a162447b279092c84a94c124df89e52561e

Many thanks

flantel commented 4 years ago

Sorry, CallID example:

A-Leg: 29256707-3809921585-53286089@SBC01N1TB.domain2.com B-Leg: 29256707-3809921585-53286089_8358307-3809921586-236453012@ix-nextone-01-domain.com

My resulting lookup is 29256707-3809921585-53286089%

lmangani commented 4 years ago

However, as the resulting query is "sid in ($1, $2)" wildcards don't work

Thanks, Could you also provide the response for this?

flantel commented 4 years ago

Sorry, which response? HTTP POST transaction, or the SQL response to the query?

adubovikov commented 4 years ago

https://github.com/sipcapture/homer-app/commit/da0751c033cf16f09cf77a8be660f0bd774d1702

in the correlation block:

"like_search": true

please take it and test it

flantel commented 4 years ago

That should do the trick. Thanks! I'll check it out.

flantel commented 4 years ago

Works like a charm. Many, many thanks!

adubovikov commented 4 years ago

Great! Have a nice day