mirror of https://github.com/MISP/MISP
Allow SyncTool with empty $server
parent
05bc4c4389
commit
106b6cb06b
|
@ -403,7 +403,7 @@ class ServersController extends AppController {
|
|||
if(!empty($proxy['host'])) {
|
||||
App::uses('SyncTool', 'Tools');
|
||||
$syncTool = new SyncTool();
|
||||
$HttpSocket = $syncTool->setupHttpSocket('www.example.com');
|
||||
$HttpSocket = $syncTool->setupHttpSocket();
|
||||
$proxyResponse = $HttpSocket->get('http://www.example.com/');
|
||||
if(empty($proxyResponse)) {
|
||||
$proxyStatus = 1;
|
||||
|
@ -475,7 +475,7 @@ class ServersController extends AppController {
|
|||
set_error_handler(function() {});
|
||||
App::uses('SyncTool', 'Tools');
|
||||
$syncTool = new SyncTool();
|
||||
$HttpSocket = $syncTool->setupHttpSocket('api.github.com');
|
||||
$HttpSocket = $syncTool->setupHttpSocket();
|
||||
$response = $HttpSocket->get('https://api.github.com/repos/MISP/MISP/tags');
|
||||
$tags = $response->body;
|
||||
restore_error_handler();
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
class SyncTool {
|
||||
// take a server as parameter and return a HttpSocket object using the ssl options defined in the server settings
|
||||
public function setupHttpSocket($server) {
|
||||
public function setupHttpSocket($server = null) {
|
||||
$params = array();
|
||||
App::uses('HttpSocket', 'Network/Http');
|
||||
if(!empty($server['Server'])) {
|
||||
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'];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue