mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 00:17:03 +03:00
Add curl proxy configuration
This commit is contained in:
parent
23ddda9194
commit
7a411cea86
9 changed files with 1174 additions and 1091 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "RainLoop",
|
"name": "RainLoop",
|
||||||
"title": "RainLoop Webmail",
|
"title": "RainLoop Webmail",
|
||||||
"version": "1.6.2",
|
"version": "1.6.2",
|
||||||
"release": "664",
|
"release": "671",
|
||||||
"description": "Simple, modern & fast web-based email client",
|
"description": "Simple, modern & fast web-based email client",
|
||||||
"homepage": "http://rainloop.net",
|
"homepage": "http://rainloop.net",
|
||||||
"main": "Gruntfile.js",
|
"main": "Gruntfile.js",
|
||||||
|
|
|
||||||
|
|
@ -357,10 +357,14 @@ class Http
|
||||||
* @param string $sCustomUserAgent = 'MailSo Http User Agent (v1)'
|
* @param string $sCustomUserAgent = 'MailSo Http User Agent (v1)'
|
||||||
* @param int $iCode = 0
|
* @param int $iCode = 0
|
||||||
* @param \MailSo\Log\Logger $oLogger = null
|
* @param \MailSo\Log\Logger $oLogger = null
|
||||||
|
* @param int $iTimeout = 20
|
||||||
|
* @param string $sProxy = ''
|
||||||
|
* @param string $sProxyAuth = ''
|
||||||
*
|
*
|
||||||
* @return string|bool
|
* @return string|bool
|
||||||
*/
|
*/
|
||||||
public function SendPostRequest($sUrl, $aPost = array(), $sCustomUserAgent = 'MailSo Http User Agent (v1)', &$iCode = 0, $oLogger = null)
|
public function SendPostRequest($sUrl, $aPost = array(), $sCustomUserAgent = 'MailSo Http User Agent (v1)', &$iCode = 0,
|
||||||
|
$oLogger = null, $iTimeout = 20, $sProxy = '', $sProxyAuth = '')
|
||||||
{
|
{
|
||||||
$aOptions = array(
|
$aOptions = array(
|
||||||
CURLOPT_URL => $sUrl,
|
CURLOPT_URL => $sUrl,
|
||||||
|
|
@ -370,7 +374,7 @@ class Http
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_POST => true,
|
CURLOPT_POST => true,
|
||||||
CURLOPT_POSTFIELDS => $aPost,
|
CURLOPT_POSTFIELDS => $aPost,
|
||||||
CURLOPT_TIMEOUT => 20
|
CURLOPT_TIMEOUT => (int) $iTimeout
|
||||||
);
|
);
|
||||||
|
|
||||||
if (0 < \strlen($sCustomUserAgent))
|
if (0 < \strlen($sCustomUserAgent))
|
||||||
|
|
@ -378,6 +382,15 @@ class Http
|
||||||
$aOptions[CURLOPT_USERAGENT] = $sCustomUserAgent;
|
$aOptions[CURLOPT_USERAGENT] = $sCustomUserAgent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (0 < \strlen($sProxy))
|
||||||
|
{
|
||||||
|
$aOptions[CURLOPT_PROXY] = $sProxy;
|
||||||
|
if (0 < \strlen($sProxyAuth))
|
||||||
|
{
|
||||||
|
$aOptions[CURLOPT_PROXYUSERPWD] = $sProxyAuth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$oCurl = \curl_init();
|
$oCurl = \curl_init();
|
||||||
\curl_setopt_array($oCurl, $aOptions);
|
\curl_setopt_array($oCurl, $aOptions);
|
||||||
|
|
||||||
|
|
@ -416,10 +429,13 @@ class Http
|
||||||
* @param int $iCode = 0
|
* @param int $iCode = 0
|
||||||
* @param \MailSo\Log\Logger $oLogger = null
|
* @param \MailSo\Log\Logger $oLogger = null
|
||||||
* @param int $iTimeout = 10
|
* @param int $iTimeout = 10
|
||||||
|
* @param string $sProxy = ''
|
||||||
|
* @param string $sProxyAuth = ''
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function SaveUrlToFile($sUrl, $rFile, $sCustomUserAgent = 'MailSo Http User Agent (v1)', &$sContentType = '', &$iCode = 0, $oLogger = null, $iTimeout = 10)
|
public function SaveUrlToFile($sUrl, $rFile, $sCustomUserAgent = 'MailSo Http User Agent (v1)', &$sContentType = '', &$iCode = 0,
|
||||||
|
$oLogger = null, $iTimeout = 10, $sProxy = '', $sProxyAuth = '')
|
||||||
{
|
{
|
||||||
if (!is_resource($rFile))
|
if (!is_resource($rFile))
|
||||||
{
|
{
|
||||||
|
|
@ -446,6 +462,15 @@ class Http
|
||||||
$aOptions[CURLOPT_USERAGENT] = $sCustomUserAgent;
|
$aOptions[CURLOPT_USERAGENT] = $sCustomUserAgent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (0 < \strlen($sProxy))
|
||||||
|
{
|
||||||
|
$aOptions[CURLOPT_PROXY] = $sProxy;
|
||||||
|
if (0 < \strlen($sProxyAuth))
|
||||||
|
{
|
||||||
|
$aOptions[CURLOPT_PROXYUSERPWD] = $sProxyAuth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$oCurl = \curl_init();
|
$oCurl = \curl_init();
|
||||||
\curl_setopt_array($oCurl, $aOptions);
|
\curl_setopt_array($oCurl, $aOptions);
|
||||||
|
|
||||||
|
|
@ -482,13 +507,17 @@ class Http
|
||||||
* @param string $sContentType = ''
|
* @param string $sContentType = ''
|
||||||
* @param int $iCode = 0
|
* @param int $iCode = 0
|
||||||
* @param \MailSo\Log\Logger $oLogger = null
|
* @param \MailSo\Log\Logger $oLogger = null
|
||||||
|
* @param int $iTimeout = 10
|
||||||
|
* @param string $sProxy = ''
|
||||||
|
* @param string $sProxyAuth = ''
|
||||||
*
|
*
|
||||||
* @return string|bool
|
* @return string|bool
|
||||||
*/
|
*/
|
||||||
public function GetUrlAsString($sUrl, $sCustomUserAgent = 'MailSo Http User Agent (v1)', &$sContentType = '', &$iCode = 0, $oLogger = null)
|
public function GetUrlAsString($sUrl, $sCustomUserAgent = 'MailSo Http User Agent (v1)', &$sContentType = '', &$iCode = 0,
|
||||||
|
$oLogger = null, $iTimeout = 10, $sProxy = '', $sProxyAuth = '')
|
||||||
{
|
{
|
||||||
$rMemFile = \MailSo\Base\ResourceRegistry::CreateMemoryResource();
|
$rMemFile = \MailSo\Base\ResourceRegistry::CreateMemoryResource();
|
||||||
if ($this->SaveUrlToFile($sUrl, $rMemFile, $sCustomUserAgent, $sContentType, $iCode, $oLogger) && \is_resource($rMemFile))
|
if ($this->SaveUrlToFile($sUrl, $rMemFile, $sCustomUserAgent, $sContentType, $iCode, $oLogger, $iTimeout, $sProxy, $sProxyAuth) && \is_resource($rMemFile))
|
||||||
{
|
{
|
||||||
\rewind($rMemFile);
|
\rewind($rMemFile);
|
||||||
return \stream_get_contents($rMemFile);
|
return \stream_get_contents($rMemFile);
|
||||||
|
|
|
||||||
|
|
@ -2096,7 +2096,8 @@ class Actions
|
||||||
$sContentType = '';
|
$sContentType = '';
|
||||||
|
|
||||||
$sValue = $oHttp->GetUrlAsString(APP_API_PATH.'status/'.\urlencode($sDomain),
|
$sValue = $oHttp->GetUrlAsString(APP_API_PATH.'status/'.\urlencode($sDomain),
|
||||||
'RainLoop', $sContentType, $iCode, $this->Logger());
|
'RainLoop', $sContentType, $iCode, $this->Logger(), 10,
|
||||||
|
$this->Config()->Get('labs', 'curl_proxy', ''), $this->Config()->Get('labs', 'curl_proxy_auth', ''));
|
||||||
|
|
||||||
if (200 !== $iCode)
|
if (200 !== $iCode)
|
||||||
{
|
{
|
||||||
|
|
@ -2165,7 +2166,8 @@ class Actions
|
||||||
|
|
||||||
\sleep(1);
|
\sleep(1);
|
||||||
$sValue = $oHttp->GetUrlAsString(APP_API_PATH.'activate/'.\urlencode($sDomain).'/'.\urlencode($sKey),
|
$sValue = $oHttp->GetUrlAsString(APP_API_PATH.'activate/'.\urlencode($sDomain).'/'.\urlencode($sKey),
|
||||||
'RainLoop', $sContentType, $iCode, $this->Logger());
|
'RainLoop', $sContentType, $iCode, $this->Logger(), 10,
|
||||||
|
$this->Config()->Get('labs', 'curl_proxy', ''), $this->Config()->Get('labs', 'curl_proxy_auth', ''));
|
||||||
|
|
||||||
if (200 !== $iCode)
|
if (200 !== $iCode)
|
||||||
{
|
{
|
||||||
|
|
@ -2439,7 +2441,9 @@ class Actions
|
||||||
$sContentType = '';
|
$sContentType = '';
|
||||||
|
|
||||||
$sRepPath = $sRepo.$sRepoFile;
|
$sRepPath = $sRepo.$sRepoFile;
|
||||||
$sRep = '' !== $sRepo ? $oHttp->GetUrlAsString($sRepPath, 'RainLoop', $sContentType, $iCode, $this->Logger()) : false;
|
$sRep = '' !== $sRepo ? $oHttp->GetUrlAsString($sRepPath, 'RainLoop', $sContentType, $iCode, $this->Logger(), 10,
|
||||||
|
$this->Config()->Get('labs', 'curl_proxy', ''), $this->Config()->Get('labs', 'curl_proxy_auth', '')) : false;
|
||||||
|
|
||||||
if (false !== $sRep)
|
if (false !== $sRep)
|
||||||
{
|
{
|
||||||
$aRep = @\json_decode($sRep);
|
$aRep = @\json_decode($sRep);
|
||||||
|
|
@ -2725,10 +2729,12 @@ class Actions
|
||||||
@\set_time_limit(60);
|
@\set_time_limit(60);
|
||||||
|
|
||||||
$oHttp = \MailSo\Base\Http::SingletonInstance();
|
$oHttp = \MailSo\Base\Http::SingletonInstance();
|
||||||
$bResult = $oHttp->SaveUrlToFile($sUrl, $pDest, $sTmp, $sContentType, $iCode, $this->Logger(), 60);
|
$bResult = $oHttp->SaveUrlToFile($sUrl, $pDest, $sTmp, $sContentType, $iCode, $this->Logger(), 60,
|
||||||
|
$this->Config()->Get('labs', 'curl_proxy', ''), $this->Config()->Get('labs', 'curl_proxy_auth', ''));
|
||||||
|
|
||||||
if (!$bResult)
|
if (!$bResult)
|
||||||
{
|
{
|
||||||
$this->Logger()->Write('Cannot save urt to temp file: ', \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER');
|
$this->Logger()->Write('Cannot save url to temp file: ', \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER');
|
||||||
$this->Logger()->Write($sUrl.' -> '.$sTmp, \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER');
|
$this->Logger()->Write($sUrl.' -> '.$sTmp, \MailSo\Log\Enumerations\Type::ERROR, 'INSTALLER');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4959,7 +4965,8 @@ class Actions
|
||||||
$sContentType = '';
|
$sContentType = '';
|
||||||
|
|
||||||
$rFile = $this->FilesProvider()->GetFile($oAccount, $sTempName, 'wb+');
|
$rFile = $this->FilesProvider()->GetFile($oAccount, $sTempName, 'wb+');
|
||||||
if ($rFile && $oHttp->SaveUrlToFile($sUrl, $rFile, '', $sContentType, $iCode, $this->Logger()))
|
if ($rFile && $oHttp->SaveUrlToFile($sUrl, $rFile, '', $sContentType, $iCode, $this->Logger(), 60,
|
||||||
|
$this->Config()->Get('labs', 'curl_proxy', ''), $this->Config()->Get('labs', 'curl_proxy_auth', '')))
|
||||||
{
|
{
|
||||||
$mResult[$sUrl] = $sTempName;
|
$mResult[$sUrl] = $sTempName;
|
||||||
}
|
}
|
||||||
|
|
@ -5932,6 +5939,18 @@ class Actions
|
||||||
CURLOPT_TIMEOUT => 10
|
CURLOPT_TIMEOUT => 10
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$sProxy = $this->Config()->Get('labs', 'curl_proxy', '');
|
||||||
|
if (0 < \strlen($sProxy))
|
||||||
|
{
|
||||||
|
$aOptions[CURLOPT_PROXY] = $sProxy;
|
||||||
|
|
||||||
|
$sProxyAuth = $this->Config()->Get('labs', 'curl_proxy_auth', '');
|
||||||
|
if (0 < \strlen($sProxyAuth))
|
||||||
|
{
|
||||||
|
$aOptions[CURLOPT_PROXYUSERPWD] = $sProxyAuth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$oCurl = \curl_init();
|
$oCurl = \curl_init();
|
||||||
\curl_setopt_array($oCurl, $aOptions);
|
\curl_setopt_array($oCurl, $aOptions);
|
||||||
$mResult = \curl_exec($oCurl);
|
$mResult = \curl_exec($oCurl);
|
||||||
|
|
|
||||||
|
|
@ -234,6 +234,8 @@ Enables caching in the system'),
|
||||||
'custom_repo' => array(''),
|
'custom_repo' => array(''),
|
||||||
'additional_repo' => array(''),
|
'additional_repo' => array(''),
|
||||||
'cdn_static_domain' => array(''),
|
'cdn_static_domain' => array(''),
|
||||||
|
'curl_proxy' => array(''),
|
||||||
|
'curl_proxy_auth' => array(''),
|
||||||
'in_iframe' => array(false),
|
'in_iframe' => array(false),
|
||||||
'custom_login_link' => array(''),
|
'custom_login_link' => array(''),
|
||||||
'custom_logout_link' => array(''),
|
'custom_logout_link' => array(''),
|
||||||
|
|
|
||||||
|
|
@ -806,6 +806,19 @@ class Social
|
||||||
$oGoogle = new \OAuth2\Client(
|
$oGoogle = new \OAuth2\Client(
|
||||||
\trim($oConfig->Get('social', 'google_client_id', '')),
|
\trim($oConfig->Get('social', 'google_client_id', '')),
|
||||||
\trim($oConfig->Get('social', 'google_client_secret', '')));
|
\trim($oConfig->Get('social', 'google_client_secret', '')));
|
||||||
|
|
||||||
|
|
||||||
|
$sProxy = $this->oActions->Config()->Get('labs', 'curl_proxy', '');
|
||||||
|
if (0 < \strlen($sProxy))
|
||||||
|
{
|
||||||
|
$oGoogle->setCurlOption(CURLOPT_PROXY, $sProxy);
|
||||||
|
|
||||||
|
$sProxyAuth = $this->oActions->Config()->Get('labs', 'curl_proxy_auth', '');
|
||||||
|
if (0 < \strlen($sProxyAuth))
|
||||||
|
{
|
||||||
|
$oGoogle->setCurlOption(CURLOPT_PROXYUSERPWD, $sProxyAuth);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (\Exception $oException)
|
catch (\Exception $oException)
|
||||||
{
|
{
|
||||||
|
|
@ -830,9 +843,14 @@ class Social
|
||||||
include_once APP_VERSION_ROOT_PATH.'app/libraries/tmhOAuth/tmhOAuth.php';
|
include_once APP_VERSION_ROOT_PATH.'app/libraries/tmhOAuth/tmhOAuth.php';
|
||||||
include_once APP_VERSION_ROOT_PATH.'app/libraries/tmhOAuth/tmhUtilities.php';
|
include_once APP_VERSION_ROOT_PATH.'app/libraries/tmhOAuth/tmhUtilities.php';
|
||||||
|
|
||||||
|
$sProxy = $this->oActions->Config()->Get('labs', 'curl_proxy', '');
|
||||||
|
$sProxyAuth = $this->oActions->Config()->Get('labs', 'curl_proxy_auth', '');
|
||||||
|
|
||||||
$oTwitter = new \tmhOAuth(array(
|
$oTwitter = new \tmhOAuth(array(
|
||||||
'consumer_key' => \trim($oConfig->Get('social', 'twitter_consumer_key', '')),
|
'consumer_key' => \trim($oConfig->Get('social', 'twitter_consumer_key', '')),
|
||||||
'consumer_secret' => \trim($oConfig->Get('social', 'twitter_consumer_secret', ''))
|
'consumer_secret' => \trim($oConfig->Get('social', 'twitter_consumer_secret', '')),
|
||||||
|
'curl_proxy' => 0 < \strlen($sProxy) ? $sProxy : false,
|
||||||
|
'curl_proxyuserpwd' => 0 < \strlen($sProxyAuth) ? $sProxyAuth : false
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -854,6 +872,21 @@ class Social
|
||||||
{
|
{
|
||||||
include_once APP_VERSION_ROOT_PATH.'app/libraries/facebook/facebook.php';
|
include_once APP_VERSION_ROOT_PATH.'app/libraries/facebook/facebook.php';
|
||||||
|
|
||||||
|
if (isset(\RainLoopFacebook::$CURL_OPTS) && \is_array(\RainLoopFacebook::$CURL_OPTS))
|
||||||
|
{
|
||||||
|
$sProxy = $this->oActions->Config()->Get('labs', 'curl_proxy', '');
|
||||||
|
if (0 < \strlen($sProxy))
|
||||||
|
{
|
||||||
|
\RainLoopFacebook::$CURL_OPTS[CURLOPT_PROXY] = $sProxy;
|
||||||
|
|
||||||
|
$sProxyAuth = $this->oActions->Config()->Get('labs', 'curl_proxy_auth', '');
|
||||||
|
if (0 < \strlen($sProxyAuth))
|
||||||
|
{
|
||||||
|
\RainLoopFacebook::$CURL_OPTS[CURLOPT_PROXYUSERPWD] = $sProxyAuth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$oFacebook = new \RainLoopFacebook(array(
|
$oFacebook = new \RainLoopFacebook(array(
|
||||||
'rlAccount' => $oAccount,
|
'rlAccount' => $oAccount,
|
||||||
'rlUserHash' => \RainLoop\Utils::GetConnectionToken(),
|
'rlUserHash' => \RainLoop\Utils::GetConnectionToken(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue