MISP/app/Lib/Tools/SyncTool.php

27 lines
1.1 KiB
PHP
Raw Normal View History

<?php
class SyncTool {
// take a server as parameter and return a HttpSocket object using the ssl options defined in the server settings
2015-03-19 13:01:29 +01:00
public function setupHttpSocket($server = null) {
$params = array();
App::uses('HttpSocket', 'Network/Http');
2015-03-19 13:01:29 +01:00
if(!empty($server)) {
if ($server['Server']['cert_file']) $params['ssl_cafile'] = APP . "files" . DS . "certs" . DS . $server['Server']['id'] . '.pem';
if ($server['Server']['self_signed']) $params['ssl_allow_self_signed'] = $server['Server']['self_signed'];
}
$HttpSocket = new HttpSocket($params);
2015-03-18 17:58:14 +01:00
$proxy = Configure::read('Proxy');
if (isset($proxy['host']) && !empty($proxy['host'])) $HttpSocket->configProxy($proxy['host'], $proxy['port'], $proxy['method'], $proxy['user'], $proxy['password']);
return $HttpSocket;
}
2016-02-29 22:32:04 +01:00
public function setupHttpSocketFeed($feed = null) {
App::uses('HttpSocket', 'Network/Http');
$HttpSocket = new HttpSocket();
$proxy = Configure::read('Proxy');
if (isset($proxy['host']) && !empty($proxy['host'])) $HttpSocket->configProxy($proxy['host'], $proxy['port'], $proxy['method'], $proxy['user'], $proxy['password']);
return $HttpSocket;
}
}