Skip to content

Commit

Permalink
Merge pull request sipcapture#1 from sipcapture/master
Browse files Browse the repository at this point in the history
update from sipcapture/master
  • Loading branch information
dancapper authored Oct 19, 2016
2 parents ab3916e + 1b9e759 commit 7f22b6f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 11 deletions.
2 changes: 1 addition & 1 deletion api/Database/Layer/pgsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function querySearchData($layerHelper)

if(isset($layerHelper['fields']['distinct']))
{
$layerHelper['values'][] = "DISTINCT ON (".$layerHelper['fields']['distinct'].")";
$layerHelper['values'][] = "DISTINCT ".$layerHelper['fields']['distinct']." ";
}

if(isset($layerHelper['fields']['md5msg']) && $layerHelper['fields']['md5msg'] == true)
Expand Down
2 changes: 1 addition & 1 deletion api/Database/PDOConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function dbconnect_node($node) {
$dbstring = DATABASE_DRIVER.":host=".$host.(($dbport) ? ";port=".$dbport : "" ).";dbname=".$dbname;
$this->connection = new PDO($dbstring, $dbusername, $dbpassword);
if(DATABASE_DRIVER == "mysql") $this->executeQuery('SET time_zone = "+00:00";');
else if(DATABASE_DRIVER == "pgsql") $this->executeQuery('SET TIME ZONE ‘0′');
//else if(DATABASE_DRIVER == "pgsql") $this->executeQuery('SET TIME ZONE ‘0′');

} catch (PDOException $e){
try {
Expand Down
56 changes: 52 additions & 4 deletions api/RestApi/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ public function doSearchMessagesData($timestamp, $param, $full = false, $count =
$search['node'] = getVar('node', NULL, $param['search'], 'string');
$search['proto'] = getVar('proto', NULL, $param['search'], 'string');
$search['family'] = getVar('family', NULL, $param['search'], 'string');
$search['custom_field1'] = getVar('custom_field1', NULL, $param['search'], 'string');
$search['custom_field2'] = getVar('custom_field2', NULL, $param['search'], 'string');
$search['custom_field2'] = getVar('custom_field3', NULL, $param['search'], 'string');


$and_or = getVar('orand', NULL, $param['search'], 'string');
$b2b = getVar('b2b', false, $param['search'], 'bool');
Expand Down Expand Up @@ -637,6 +641,9 @@ public function doExportMessagesData($timestamp, $param, $full = false, $count =
$search['node'] = getVar('node', NULL, $param['search'], 'string');
$search['proto'] = getVar('proto', NULL, $param['search'], 'string');
$search['family'] = getVar('family', NULL, $param['search'], 'string');
$search['custom_field1'] = getVar('custom_field1', NULL, $param['search'], 'string');
$search['custom_field2'] = getVar('custom_field2', NULL, $param['search'], 'string');
$search['custom_field2'] = getVar('custom_field3', NULL, $param['search'], 'string');

$and_or = getVar('orand', NULL, $param['search'], 'string');
$b2b = getVar('b2b', false, $param['search'], 'bool');
Expand Down Expand Up @@ -1793,8 +1800,11 @@ function getSIPCflow($data, &$hosts, &$info, &$uac, &$hostcount, &$rtpinfo, $mes
$src_id = $data->source_ip.":".$data->source_port;
$dst_id = $data->destination_ip.":".$data->destination_port;

if(!isset($hosts[$src_id])) { $hosts[$src_id] = $hostcount; $hostcount+=$host_step; }
if(!isset($hosts[$dst_id])) { $hosts[$dst_id] = $hostcount; $hostcount+=$host_step; }
$src_id_complete = $data->source_ip.":".$data->source_port."-".$data->node;
$dst_id_complete = $data->destination_ip.":".$data->destination_port."-".$data->node;

if(!isset($hosts[$src_id_complete])) { $hosts[$src_id_complete] = $hostcount; $hostcount+=$host_step; }
if(!isset($hosts[$dst_id_complete])) { $hosts[$dst_id_complete] = $hostcount; $hostcount+=$host_step; }

$ssrc = ":".$data->source_port;

Expand Down Expand Up @@ -1966,7 +1976,7 @@ function getSIPCflow($data, &$hosts, &$info, &$uac, &$hostcount, &$rtpinfo, $mes
$calldata["msg_color"] = $msgcol;

/*IF */
if($hosts[$src_id] > $hosts[$dst_id]) $calldata["destination"] = 2;
if($hosts[$src_id_complete] > $hosts[$dst_id_complete]) $calldata["destination"] = 2;
else $calldata["destination"] = 1;

return $calldata;
Expand Down Expand Up @@ -2533,8 +2543,46 @@ private function applyHostsAliases(&$data) {
// Apply source_alias
if (isset($alias_cache[$key])) $alias = $alias_cache[$key];
else {
if (preg_match('/(.*):(.*)-(.*)/', $key, $matches)) {
$key_ip_address = $matches[1];
$key_port = $matches[2];
$key_node = $matches[3];

if (isset($alias_cache[$key_ip_address . ":" . $key_port . "-" . $key_node])) {
$alias = $alias_cache[$key_ip_address . ":" . $key_port . "-" . $key_node];
}
else if (isset($alias_cache[$key_ip_address . ":" . $key_port . "-*"])) {
$alias = $alias_cache[$key_ip_address . ":" . $key_port . "-*"];
}
else if (isset($alias_cache[$key_ip_address . ":" . $key_port])) {
$alias = $alias_cache[$key_ip_address . ":" . $key_port];
}
else if (isset($alias_cache[$key_ip_address])) {
$alias = $alias_cache[$key_ip_address];
}
else {
$alias = $key_ip_address.":".$key_port;
}
}
// port was omitted in alias:
else if (preg_match('/(.*)-(.*)/', $key, $matches)) {
$key_ip_address = $matches[1];
$key_node = $matches[2];
if (isset($alias_cache[$key_ip_address . "-" . $key_node])) {
$alias = $alias_cache[$key_ip_address . "-" . $key_node];
}
else if (isset($alias_cache[$key_ip_address . "-*"])) {
$alias = $alias_cache[$key_ip_address . "-*"];
}
else if (isset($alias_cache[$key_ip_address])) {
$alias = $alias_cache[$key_ip_address];
}
else {
$alias = $key_ip_address;
}
}
// extract IP address from $key:
if (preg_match('/(.*):.*/', $key, $matches)) {
else if (preg_match('/(.*):.*/', $key, $matches)) {
$key_ip_address = $matches[1];
if (isset($alias_cache[$key_ip_address])) {
$alias = $alias_cache[$key_ip_address];
Expand Down
10 changes: 5 additions & 5 deletions sql/schema_configuration.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CREATE TABLE IF NOT EXISTS `alias` (
UNIQUE KEY `id` (`id`),
UNIQUE KEY `host_2` (`ip`,`port`,`capture_id`),
KEY `host` (`ip`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `alias`
Expand All @@ -45,7 +45,7 @@ CREATE TABLE IF NOT EXISTS `group` (
`gid` int(10) NOT NULL DEFAULT 0,
`name` varchar(100) NOT NULL DEFAULT '',
UNIQUE KEY `gid` (`gid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `group`
Expand Down Expand Up @@ -89,7 +89,7 @@ CREATE TABLE IF NOT EXISTS `node` (
UNIQUE KEY `id` (`id`),
UNIQUE KEY `host_2` (`host`),
KEY `host` (`host`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `node`
Expand Down Expand Up @@ -118,7 +118,7 @@ CREATE TABLE IF NOT EXISTS `setting` (
UNIQUE KEY `uid_2` (`uid`,`param_name`),
KEY `param_name` (`param_name`),
KEY `uid` (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;

--
-- Dumping data for table `setting`
Expand Down Expand Up @@ -149,7 +149,7 @@ CREATE TABLE IF NOT EXISTS `user` (
PRIMARY KEY (`uid`),
UNIQUE KEY `login` (`username`),
UNIQUE KEY `username` (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `user`
Expand Down

0 comments on commit 7f22b6f

Please sign in to comment.