diff --git a/module.combodo-webhook-integration.php b/module.combodo-webhook-integration.php index 01987c2..384e2a2 100644 --- a/module.combodo-webhook-integration.php +++ b/module.combodo-webhook-integration.php @@ -5,7 +5,7 @@ // // SetupWebPage::AddModule(__FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'combodo-webhook-integration/1.4.5', + 'combodo-webhook-integration/1.4.4', array( // 'label' => 'Webhook integrations', @@ -44,7 +44,14 @@ // Default settings // - 'settings' => array(), + 'settings' => array( + // Configuración de proxy para las llamadas salientes de los webhooks + 'proxy' => array( + 'host' => 'ip.roxy:3128', // IP:PUERTO de tu proxy + 'user' => '', // si no requiere auth, dejalo vacío + 'password' => '', + ) + ) ) ); diff --git a/src/Service/WebRequestSender.php b/src/Service/WebRequestSender.php index 10e3ed0..59393e9 100644 --- a/src/Service/WebRequestSender.php +++ b/src/Service/WebRequestSender.php @@ -124,6 +124,37 @@ public function SendSynchronously(WebRequest $oRequest, &$aIssues, $oLog = null) { try { + // ============================ + // Inyectar opciones de proxy + // ============================ + $oConfig = MetaModel::GetConfig(); + $aProxyConf = $oConfig->GetModuleSetting('combodo-webhook-integration', 'proxy', null); + + if (is_array($aProxyConf) && !empty($aProxyConf['host'])) { + // Recuperar opciones actuales del request (si no hay, iniciamos array vacío) + $aCurlOptions = $oRequest->GetOptions(); + if (!is_array($aCurlOptions)) { + $aCurlOptions = array(); + } + + // Host:puerto del proxy + $aCurlOptions[CURLOPT_PROXY] = $aProxyConf['host']; + $aCurlOptions[CURLOPT_PROXYTYPE] = CURLPROXY_HTTP; + + // Auth opcional si el proxy la requiere + if (!empty($aProxyConf['user'])) { + $sAuth = $aProxyConf['user']; + if (!empty($aProxyConf['password'])) { + $sAuth .= ':'.$aProxyConf['password']; + } + $aCurlOptions[CURLOPT_PROXYUSERPWD] = $sAuth; + } + + // Guardar las opciones de vuelta en el request + $oRequest->SetOptions($aCurlOptions); + } + // ============================ + $aResponseHeaders = array(); $sResponse = $this->DoPostRequest($oRequest->GetURL(), array(), null, $aResponseHeaders, $oRequest->GetOptions()); @@ -164,6 +195,7 @@ public function SendSynchronously(WebRequest $oRequest, &$aIssues, $oLog = null) } } + /** * Add the $oRequest to the queue in order to be send later *