sipcapture / paStash

pastaʃ'ʃ = Spaghetti I/O Event Data Processing, Interpolation, Correlation and beyond :spaghetti:
http://sipcapture.io
Apache License 2.0
101 stars 27 forks source link

Make HEP network setting configurable #191

Closed hamidrhashmi closed 2 months ago

hamidrhashmi commented 2 months ago

I am trying to send freeswitch CDRs as HEP Log to Homer. But I am unable to set HEP SRC IP and SRC Port with respect to IPs in the CDRs so That I can see Log Correclty in the flow.

Pastash Configuration

input {
      file {
        path => "/home/hrhashmi/FREESWITCH/var/log/freeswitch/cdr-csv/Master.csv"
      }
    }
 filter {
   csv {
    headers => ['caller_id_name', 'caller_id_number', 'source_ip', 'source_port', 'destination_number', 'context', 'start_stamp', 'answer_stamp', 'end_stamp', 'duration', 'billsec', 'hangup_cause', 'uuid', 'bleg_uuid', 'accountcode','codec','bleg_codec']
 }
  compute_field {
    field => correlation_id
    value => "#{uuid}"
  }
  compute_field {
    field => s_ip
    value => "#{source_ip}"
  }
  compute_field {
    field => s_port
    value => "#{source_port}"
  }
}
    output {
      hep {
        host => debian10.hbvoice.local
        port => 9063
        hep_id => 2022
        hep_type => 100
        hep_cid => '#{correlation_id}'
        hep_protocol => 17
        src_ip => '#{s_ip}'
        src_port => '#{s_port}'
        dst_ip => 192.168.0.167
      }
      stdout{}
    }

Pasttash Logs (it does not print hep packet.)


[Wed, 08 May 2024 11:37:05 GMT] DEBUG Event received for /home/hrhashmi/FREESWITCH/var/log/freeswitch/cdr-csv/Master.csv : change Master.csv
[Wed, 08 May 2024 11:37:05 GMT] DEBUG File /home/hrhashmi/FREESWITCH/var/log/freeswitch/cdr-csv/Master.csv changed
[Wed, 08 May 2024 11:37:05 GMT] DEBUG Launch reading on 20 , current_index 2832072
[Wed, 08 May 2024 11:37:05 GMT] DEBUG Read from 20 : 212 bytes
[Wed, 08 May 2024 11:37:05 GMT] DEBUG CSV Data! Row {
  caller_id_name: 'Hamid R. Hashmi',
  caller_id_number: '+923009682285',
  source_ip: '192.168.0.110',
  source_port: '64874',
  destination_number: '+97123456789',
  context: 'public',
  start_stamp: '2024-05-08 16:37:01',
  answer_stamp: '',
  end_stamp: '2024-05-08 16:37:05',
  duration: '4',
  billsec: '0',
  hangup_cause: 'ORIGINATOR_CANCEL',
  uuid: '0d51a83875da4ea38dcbc1328191ddbe',
  bleg_uuid: '',
  accountcode: '',
  codec: 'PCMA',
  bleg_codec: 'PCMA'
}
[STDOUT] {
  "caller_id_name": "Hamid R. Hashmi",
  "caller_id_number": "+923009682285",
  "source_ip": "192.168.0.110",
  "source_port": "64874",
  "destination_number": "+97123456789",
  "context": "public",
  "start_stamp": "2024-05-08 16:37:01",
  "answer_stamp": "",
  "end_stamp": "2024-05-08 16:37:05",
  "duration": "4",
  "billsec": "0",
  "hangup_cause": "ORIGINATOR_CANCEL",
  "uuid": "0d51a83875da4ea38dcbc1328191ddbe",
  "bleg_uuid": "",
  "accountcode": "",
  "codec": "PCMA",
  "bleg_codec": "PCMA",
  "correlation_id": "0d51a83875da4ea38dcbc1328191ddbe",
  "s_ip": "192.168.0.110",
  "s_port": "64874"
}

I can see a comment here which says that the Network part is to be Done.

lmangani commented 2 months ago

s_ip and s_port will have no effect. The correct fields to force IPs in the HEP output are srcIp, srcPort, dstIp, dstPort

        // Build HEP3 w/ null network parameters
        hep_proto.srcIp = data.srcIp || this.src_ip;
        hep_proto.dstIp = data.dstIp || this.dst_ip;
        hep_proto.srcPort = data.srcPort || this.src_port;
        hep_proto.dstPort = data.dstPort || this.dst_port;

Full logic in the source code