From dfded1122bd4dfc6dee07fcf4f1d0525d8ee1d7d Mon Sep 17 00:00:00 2001 From: net909 Date: Thu, 26 Dec 2024 14:34:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=91=E6=9C=8D=E5=8A=A1=E5=95=86=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=94=AF=E6=8C=81=E4=BB=A3=E7=90=86=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common.php | 48 +++++++++++++--------- app/controller/Domain.php | 4 ++ app/lib/CertHelper.php | 18 +++++++++ app/lib/DeployHelper.php | 72 +++++++++++++++++++++++++++++++++ app/lib/acme/ACMEv2.php | 21 +--------- app/lib/cert/aliyun.php | 3 +- app/lib/cert/huoshan.php | 3 +- app/lib/cert/tencent.php | 3 +- app/lib/client/AWS.php | 7 +++- app/lib/client/Aliyun.php | 7 +++- app/lib/client/AliyunNew.php | 7 +++- app/lib/client/AliyunOss.php | 7 +++- app/lib/client/BaiduCloud.php | 7 +++- app/lib/client/HuaweiCloud.php | 7 +++- app/lib/client/Qiniu.php | 7 +++- app/lib/client/TencentCloud.php | 7 +++- app/lib/client/Volcengine.php | 7 +++- app/lib/deploy/aliyun.php | 32 ++++++++------- app/lib/deploy/aws.php | 8 ++-- app/lib/deploy/baidu.php | 6 ++- app/lib/deploy/doge.php | 4 +- app/lib/deploy/huawei.php | 12 +++--- app/lib/deploy/huoshan.php | 8 ++-- app/lib/deploy/qiniu.php | 2 +- app/lib/deploy/tencent.php | 18 +++++---- app/lib/dns/aliyun.php | 3 +- app/lib/dns/baidu.php | 3 +- app/lib/dns/cloudflare.php | 5 +++ app/lib/dns/dnsla.php | 7 +++- app/lib/dns/dnspod.php | 3 +- app/lib/dns/huawei.php | 3 +- app/lib/dns/huoshan.php | 3 +- app/lib/dns/namesilo.php | 4 +- app/lib/dns/west.php | 33 +++++---------- app/sql/install.sql | 1 + app/sql/update.sql | 5 ++- app/utils/MsgNotice.php | 21 +--------- app/view/cert/account_form.html | 5 ++- app/view/cert/deploy_form.html | 6 ++- app/view/domain/account.html | 20 +++++++-- config/app.php | 4 +- 41 files changed, 300 insertions(+), 151 deletions(-) diff --git a/app/common.php b/app/common.php index f334612..e6f0581 100644 --- a/app/common.php +++ b/app/common.php @@ -408,26 +408,7 @@ function curl_client($url, $data = null, $referer = null, $cookie = null, $heade } if ($proxy) { - $proxy_server = config_get('proxy_server'); - $proxy_port = intval(config_get('proxy_port')); - $proxy_userpwd = config_get('proxy_user') . ':' . config_get('proxy_pwd'); - $proxy_type = config_get('proxy_type'); - if ($proxy_type == 'https') { - $proxy_type = CURLPROXY_HTTPS; - } elseif ($proxy_type == 'sock4') { - $proxy_type = CURLPROXY_SOCKS4; - } elseif ($proxy_type == 'sock5') { - $proxy_type = CURLPROXY_SOCKS5; - } else { - $proxy_type = CURLPROXY_HTTP; - } - curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); - curl_setopt($ch, CURLOPT_PROXY, $proxy_server); - curl_setopt($ch, CURLOPT_PROXYPORT, $proxy_port); - if ($proxy_userpwd != ':') { - curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_userpwd); - } - curl_setopt($ch, CURLOPT_PROXYTYPE, $proxy_type); + curl_set_proxy($ch); } $ret = curl_exec($ch); @@ -443,4 +424,31 @@ function curl_client($url, $data = null, $referer = null, $cookie = null, $heade $header = substr($ret, 0, $headerSize); $body = substr($ret, $headerSize); return ['code' => $httpCode, 'redirect_url' => $redirect_url, 'header' => $header, 'body' => $body]; +} + +function curl_set_proxy(&$ch) +{ + $proxy_server = config_get('proxy_server'); + $proxy_port = intval(config_get('proxy_port')); + $proxy_userpwd = config_get('proxy_user') . ':' . config_get('proxy_pwd'); + $proxy_type = config_get('proxy_type'); + if (empty($proxy_server) || empty($proxy_port)) { + return; + } + if ($proxy_type == 'https') { + $proxy_type = CURLPROXY_HTTPS; + } elseif ($proxy_type == 'sock4') { + $proxy_type = CURLPROXY_SOCKS4; + } elseif ($proxy_type == 'sock5') { + $proxy_type = CURLPROXY_SOCKS5; + } else { + $proxy_type = CURLPROXY_HTTP; + } + curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); + curl_setopt($ch, CURLOPT_PROXY, $proxy_server); + curl_setopt($ch, CURLOPT_PROXYPORT, $proxy_port); + if ($proxy_userpwd != ':') { + curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_userpwd); + } + curl_setopt($ch, CURLOPT_PROXYTYPE, $proxy_type); } \ No newline at end of file diff --git a/app/controller/Domain.php b/app/controller/Domain.php index ad315e5..9dd6262 100644 --- a/app/controller/Domain.php +++ b/app/controller/Domain.php @@ -57,6 +57,7 @@ class Domain extends BaseController $sk = input('post.sk', null, 'trim'); $ext = input('post.ext', null, 'trim'); $remark = input('post.remark', null, 'trim'); + $proxy = input('post.proxy/d', 0); if (empty($ak) || empty($sk)) return json(['code' => -1, 'msg' => 'AccessKey和SecretKey不能为空']); if (Db::name('account')->where('type', $type)->where('ak', $ak)->find()) { return json(['code' => -1, 'msg' => '域名账户已存在']); @@ -67,6 +68,7 @@ class Domain extends BaseController 'ak' => $ak, 'sk' => $sk, 'ext' => $ext, + 'proxy' => $proxy, 'remark' => $remark, 'addtime' => date('Y-m-d H:i:s'), ]); @@ -92,6 +94,7 @@ class Domain extends BaseController $sk = input('post.sk', null, 'trim'); $ext = input('post.ext', null, 'trim'); $remark = input('post.remark', null, 'trim'); + $proxy = input('post.proxy/d', 0); if (empty($ak) || empty($sk)) return json(['code' => -1, 'msg' => 'AccessKey和SecretKey不能为空']); if (Db::name('account')->where('type', $type)->where('ak', $ak)->where('id', '<>', $id)->find()) { return json(['code' => -1, 'msg' => '域名账户已存在']); @@ -102,6 +105,7 @@ class Domain extends BaseController 'ak' => $ak, 'sk' => $sk, 'ext' => $ext, + 'proxy' => $proxy, 'remark' => $remark, ]); $dns = DnsHelper::getModel($id); diff --git a/app/lib/CertHelper.php b/app/lib/CertHelper.php index 5fbf340..7611bbb 100644 --- a/app/lib/CertHelper.php +++ b/app/lib/CertHelper.php @@ -154,6 +154,15 @@ class CertHelper 'placeholder' => '申请证书时填写的邮箱', 'required' => true, ], + 'proxy' => [ + 'name' => '使用代理服务器', + 'type' => 'radio', + 'options' => [ + '0' => '否', + '1' => '是', + ], + 'value' => '0' + ], ] ], 'aliyun' => [ @@ -195,6 +204,15 @@ class CertHelper 'placeholder' => '申请联系人的邮箱地址', 'required' => true, ], + 'proxy' => [ + 'name' => '使用代理服务器', + 'type' => 'radio', + 'options' => [ + '0' => '否', + '1' => '是', + ], + 'value' => '0' + ], ] ], 'ucloud' => [ diff --git a/app/lib/DeployHelper.php b/app/lib/DeployHelper.php index b81c697..52709d4 100644 --- a/app/lib/DeployHelper.php +++ b/app/lib/DeployHelper.php @@ -418,6 +418,15 @@ class DeployHelper 'placeholder' => '', 'required' => true, ], + 'proxy' => [ + 'name' => '使用代理服务器', + 'type' => 'radio', + 'options' => [ + '0' => '否', + '1' => '是', + ], + 'value' => '0' + ], ], 'taskinputs' => [ 'product' => [ @@ -556,6 +565,15 @@ class DeployHelper 'placeholder' => '', 'required' => true, ], + 'proxy' => [ + 'name' => '使用代理服务器', + 'type' => 'radio', + 'options' => [ + '0' => '否', + '1' => '是', + ], + 'value' => '0' + ], ], 'taskinputs' => [ 'product' => [ @@ -680,6 +698,15 @@ class DeployHelper 'placeholder' => '', 'required' => true, ], + 'proxy' => [ + 'name' => '使用代理服务器', + 'type' => 'radio', + 'options' => [ + '0' => '否', + '1' => '是', + ], + 'value' => '0' + ], ], 'taskinputs' => [ 'product' => [ @@ -772,6 +799,15 @@ class DeployHelper 'placeholder' => '', 'required' => true, ], + 'proxy' => [ + 'name' => '使用代理服务器', + 'type' => 'radio', + 'options' => [ + '0' => '否', + '1' => '是', + ], + 'value' => '0' + ], ], 'taskinputs' => [ 'product' => [ @@ -810,6 +846,15 @@ class DeployHelper 'placeholder' => '', 'required' => true, ], + 'proxy' => [ + 'name' => '使用代理服务器', + 'type' => 'radio', + 'options' => [ + '0' => '否', + '1' => '是', + ], + 'value' => '0' + ], ], 'taskinputs' => [ 'domain' => [ @@ -838,6 +883,15 @@ class DeployHelper 'placeholder' => '', 'required' => true, ], + 'proxy' => [ + 'name' => '使用代理服务器', + 'type' => 'radio', + 'options' => [ + '0' => '否', + '1' => '是', + ], + 'value' => '0' + ], ], 'taskinputs' => [ 'domain' => [ @@ -866,6 +920,15 @@ class DeployHelper 'placeholder' => '', 'required' => true, ], + 'proxy' => [ + 'name' => '使用代理服务器', + 'type' => 'radio', + 'options' => [ + '0' => '否', + '1' => '是', + ], + 'value' => '0' + ], ], 'taskinputs' => [ 'domain' => [ @@ -964,6 +1027,15 @@ class DeployHelper 'placeholder' => '', 'required' => true, ], + 'proxy' => [ + 'name' => '使用代理服务器', + 'type' => 'radio', + 'options' => [ + '0' => '否', + '1' => '是', + ], + 'value' => '0' + ], ], 'taskinputs' => [ 'product' => [ diff --git a/app/lib/acme/ACMEv2.php b/app/lib/acme/ACMEv2.php index b1fb5b8..08ad00d 100644 --- a/app/lib/acme/ACMEv2.php +++ b/app/lib/acme/ACMEv2.php @@ -308,26 +308,7 @@ class ACMEv2 )); if ($this->proxy) { - $proxy_server = config_get('proxy_server'); - $proxy_port = intval(config_get('proxy_port')); - $proxy_userpwd = config_get('proxy_user').':'.config_get('proxy_pwd'); - $proxy_type = config_get('proxy_type'); - if ($proxy_type == 'https') { - $proxy_type = CURLPROXY_HTTPS; - } elseif ($proxy_type == 'sock4') { - $proxy_type = CURLPROXY_SOCKS4; - } elseif ($proxy_type == 'sock5') { - $proxy_type = CURLPROXY_SOCKS5; - } else { - $proxy_type = CURLPROXY_HTTP; - } - curl_setopt($this->ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); - curl_setopt($this->ch, CURLOPT_PROXY, $proxy_server); - curl_setopt($this->ch, CURLOPT_PROXYPORT, $proxy_port); - if ($proxy_userpwd != ':') { - curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, $proxy_userpwd); - } - curl_setopt($this->ch, CURLOPT_PROXYTYPE, $proxy_type); + curl_set_proxy($this->ch); } $took = microtime(true); diff --git a/app/lib/cert/aliyun.php b/app/lib/cert/aliyun.php index 7aff3c1..ff4e6a6 100644 --- a/app/lib/cert/aliyun.php +++ b/app/lib/cert/aliyun.php @@ -20,7 +20,8 @@ class aliyun implements CertInterface { $this->AccessKeyId = $config['AccessKeyId']; $this->AccessKeySecret = $config['AccessKeySecret']; - $this->client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $this->Endpoint, $this->Version); + $proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; + $this->client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $this->Endpoint, $this->Version, $proxy); $this->config = $config; } diff --git a/app/lib/cert/huoshan.php b/app/lib/cert/huoshan.php index b391a10..0e0b912 100644 --- a/app/lib/cert/huoshan.php +++ b/app/lib/cert/huoshan.php @@ -21,7 +21,8 @@ class huoshan implements CertInterface { $this->AccessKeyId = $config['AccessKeyId']; $this->SecretAccessKey = $config['SecretAccessKey']; - $this->client = new Volcengine($this->AccessKeyId, $this->SecretAccessKey, $this->endpoint, $this->service, $this->version, $this->region); + $proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; + $this->client = new Volcengine($this->AccessKeyId, $this->SecretAccessKey, $this->endpoint, $this->service, $this->version, $this->region, $proxy); } public function register() diff --git a/app/lib/cert/tencent.php b/app/lib/cert/tencent.php index fc339d9..1c0dc28 100644 --- a/app/lib/cert/tencent.php +++ b/app/lib/cert/tencent.php @@ -21,7 +21,8 @@ class tencent implements CertInterface { $this->SecretId = $config['SecretId']; $this->SecretKey = $config['SecretKey']; - $this->client = new TencentCloud($this->SecretId, $this->SecretKey, $this->endpoint, $this->service, $this->version); + $proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; + $this->client = new TencentCloud($this->SecretId, $this->SecretKey, $this->endpoint, $this->service, $this->version, null, $proxy); $this->email = $config['email']; } diff --git a/app/lib/client/AWS.php b/app/lib/client/AWS.php index 4c7d5cf..06fdd34 100644 --- a/app/lib/client/AWS.php +++ b/app/lib/client/AWS.php @@ -16,8 +16,9 @@ class AWS private $version; private $region; private $etag; + private $proxy = false; - public function __construct($AccessKeyId, $SecretAccessKey, $endpoint, $service, $version, $region) + public function __construct($AccessKeyId, $SecretAccessKey, $endpoint, $service, $version, $region, $proxy = false) { $this->AccessKeyId = $AccessKeyId; $this->SecretAccessKey = $SecretAccessKey; @@ -25,6 +26,7 @@ class AWS $this->service = $service; $this->version = $version; $this->region = $region; + $this->proxy = $proxy; } /** @@ -252,6 +254,9 @@ class AWS private function curl($method, $url, $body, $header, $xml = false, $etag = false) { $ch = curl_init($url); + if ($this->proxy) { + curl_set_proxy($ch); + } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); diff --git a/app/lib/client/Aliyun.php b/app/lib/client/Aliyun.php index f617e23..a2c34b1 100644 --- a/app/lib/client/Aliyun.php +++ b/app/lib/client/Aliyun.php @@ -13,13 +13,15 @@ class Aliyun private $AccessKeySecret; private $Endpoint; private $Version; + private $proxy = false; - public function __construct($AccessKeyId, $AccessKeySecret, $Endpoint, $Version) + public function __construct($AccessKeyId, $AccessKeySecret, $Endpoint, $Version, $proxy = false) { $this->AccessKeyId = $AccessKeyId; $this->AccessKeySecret = $AccessKeySecret; $this->Endpoint = $Endpoint; $this->Version = $Version; + $this->proxy = $proxy; } /** @@ -45,6 +47,9 @@ class Aliyun $url .= '?' . http_build_query($data); } $ch = curl_init($url); + if ($this->proxy) { + curl_set_proxy($ch); + } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); diff --git a/app/lib/client/AliyunNew.php b/app/lib/client/AliyunNew.php index d37f358..b4c27ba 100644 --- a/app/lib/client/AliyunNew.php +++ b/app/lib/client/AliyunNew.php @@ -13,13 +13,15 @@ class AliyunNew private $AccessKeySecret; private $Endpoint; private $Version; + private $proxy = false; - public function __construct($AccessKeyId, $AccessKeySecret, $Endpoint, $Version) + public function __construct($AccessKeyId, $AccessKeySecret, $Endpoint, $Version, $proxy = false) { $this->AccessKeyId = $AccessKeyId; $this->AccessKeySecret = $AccessKeySecret; $this->Endpoint = $Endpoint; $this->Version = $Version; + $this->proxy = $proxy; } /** @@ -138,6 +140,9 @@ class AliyunNew private function curl($method, $url, $body, $header) { $ch = curl_init($url); + if ($this->proxy) { + curl_set_proxy($ch); + } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); diff --git a/app/lib/client/AliyunOss.php b/app/lib/client/AliyunOss.php index ab2f5b8..c1993aa 100644 --- a/app/lib/client/AliyunOss.php +++ b/app/lib/client/AliyunOss.php @@ -9,12 +9,14 @@ class AliyunOSS private $AccessKeyId; private $AccessKeySecret; private $Endpoint; + private $proxy = false; - public function __construct($AccessKeyId, $AccessKeySecret, $Endpoint) + public function __construct($AccessKeyId, $AccessKeySecret, $Endpoint, $proxy = false) { $this->AccessKeyId = $AccessKeyId; $this->AccessKeySecret = $AccessKeySecret; $this->Endpoint = $Endpoint; + $this->proxy = $proxy; } public function addBucketCnameCert($bucket, $domain, $cert_id) @@ -101,6 +103,9 @@ class AliyunOSS private function curl($method, $url, $body, $header) { $ch = curl_init($url); + if ($this->proxy) { + curl_set_proxy($ch); + } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); diff --git a/app/lib/client/BaiduCloud.php b/app/lib/client/BaiduCloud.php index 551dcd8..3dc9b21 100644 --- a/app/lib/client/BaiduCloud.php +++ b/app/lib/client/BaiduCloud.php @@ -12,12 +12,14 @@ class BaiduCloud private $AccessKeyId; private $SecretAccessKey; private $endpoint; + private $proxy = false; - public function __construct($AccessKeyId, $SecretAccessKey, $endpoint) + public function __construct($AccessKeyId, $SecretAccessKey, $endpoint, $proxy = false) { $this->AccessKeyId = $AccessKeyId; $this->SecretAccessKey = $SecretAccessKey; $this->endpoint = $endpoint; + $this->proxy = $proxy; } /** @@ -140,6 +142,9 @@ class BaiduCloud private function curl($method, $url, $body, $header) { $ch = curl_init($url); + if ($this->proxy) { + curl_set_proxy($ch); + } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); diff --git a/app/lib/client/HuaweiCloud.php b/app/lib/client/HuaweiCloud.php index c9db988..eb2ac3d 100644 --- a/app/lib/client/HuaweiCloud.php +++ b/app/lib/client/HuaweiCloud.php @@ -12,12 +12,14 @@ class HuaweiCloud private $AccessKeyId; private $SecretAccessKey; private $endpoint; + private $proxy = false; - public function __construct($AccessKeyId, $SecretAccessKey, $endpoint) + public function __construct($AccessKeyId, $SecretAccessKey, $endpoint, $proxy = false) { $this->AccessKeyId = $AccessKeyId; $this->SecretAccessKey = $SecretAccessKey; $this->endpoint = $endpoint; + $this->proxy = $proxy; } /** @@ -135,6 +137,9 @@ class HuaweiCloud private function curl($method, $url, $body, $header) { $ch = curl_init($url); + if ($this->proxy) { + curl_set_proxy($ch); + } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); diff --git a/app/lib/client/Qiniu.php b/app/lib/client/Qiniu.php index 20feabf..3d2680f 100644 --- a/app/lib/client/Qiniu.php +++ b/app/lib/client/Qiniu.php @@ -12,11 +12,13 @@ class Qiniu private $ApiUrl = 'https://api.qiniu.com'; private $AccessKey; private $SecretKey; + private $proxy = false; - public function __construct($AccessKey, $SecretKey) + public function __construct($AccessKey, $SecretKey, $proxy = false) { $this->AccessKey = $AccessKey; $this->SecretKey = $SecretKey; + $this->proxy = $proxy; } /** @@ -69,6 +71,9 @@ class Qiniu private function curl($method, $url, $body, $header) { $ch = curl_init($url); + if ($this->proxy) { + curl_set_proxy($ch); + } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); diff --git a/app/lib/client/TencentCloud.php b/app/lib/client/TencentCloud.php index a167b30..05b0e68 100644 --- a/app/lib/client/TencentCloud.php +++ b/app/lib/client/TencentCloud.php @@ -15,8 +15,9 @@ class TencentCloud private $service; private $version; private $region; + private $proxy = false; - public function __construct($SecretId, $SecretKey, $endpoint, $service, $version, $region = null) + public function __construct($SecretId, $SecretKey, $endpoint, $service, $version, $region = null, $proxy = false) { $this->SecretId = $SecretId; $this->SecretKey = $SecretKey; @@ -24,6 +25,7 @@ class TencentCloud $this->service = $service; $this->version = $version; $this->region = $region; + $this->proxy = $proxy; } /** @@ -98,6 +100,9 @@ class TencentCloud { $url = 'https://'.$this->endpoint.'/'; $ch = curl_init($url); + if ($this->proxy) { + curl_set_proxy($ch); + } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); diff --git a/app/lib/client/Volcengine.php b/app/lib/client/Volcengine.php index 928e599..90f4a16 100644 --- a/app/lib/client/Volcengine.php +++ b/app/lib/client/Volcengine.php @@ -15,8 +15,9 @@ class Volcengine private $service; private $version; private $region; + private $proxy = false; - public function __construct($AccessKeyId, $SecretAccessKey, $endpoint, $service, $version, $region) + public function __construct($AccessKeyId, $SecretAccessKey, $endpoint, $service, $version, $region, $proxy = false) { $this->AccessKeyId = $AccessKeyId; $this->SecretAccessKey = $SecretAccessKey; @@ -24,6 +25,7 @@ class Volcengine $this->service = $service; $this->version = $version; $this->region = $region; + $this->proxy = $proxy; } /** @@ -157,6 +159,9 @@ class Volcengine private function curl($method, $url, $body, $header) { $ch = curl_init($url); + if ($this->proxy) { + curl_set_proxy($ch); + } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); diff --git a/app/lib/deploy/aliyun.php b/app/lib/deploy/aliyun.php index 66d2b0a..6427268 100644 --- a/app/lib/deploy/aliyun.php +++ b/app/lib/deploy/aliyun.php @@ -13,17 +13,19 @@ class aliyun implements DeployInterface private $logger; private $AccessKeyId; private $AccessKeySecret; + private $proxy; public function __construct($config) { $this->AccessKeyId = $config['AccessKeyId']; $this->AccessKeySecret = $config['AccessKeySecret']; + $this->proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; } public function check() { if (empty($this->AccessKeyId) || empty($this->AccessKeySecret)) throw new Exception('必填参数不能为空'); - $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, 'cas.aliyuncs.com', '2020-04-07'); + $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, 'cas.aliyuncs.com', '2020-04-07', $this->proxy); $param = ['Action' => 'ListUserCertificateOrder']; $client->request($param); return true; @@ -79,7 +81,7 @@ class aliyun implements DeployInterface $cert_name = str_replace('*.', '', $certInfo['subject']['CN']) . '-' . $certInfo['validFrom_time_t']; $serial_no = strtolower($certInfo['serialNumberHex']); - $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, 'cas.aliyuncs.com', '2020-04-07'); + $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, 'cas.aliyuncs.com', '2020-04-07', $this->proxy); $param = [ 'Action' => 'ListUserCertificateOrder', 'Keyword' => $certInfo['subject']['CN'], @@ -125,7 +127,7 @@ class aliyun implements DeployInterface { $domain = $config['domain']; if (empty($domain)) throw new Exception('CDN绑定域名不能为空'); - $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, 'cdn.aliyuncs.com', '2018-05-10'); + $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, 'cdn.aliyuncs.com', '2018-05-10', $this->proxy); $param = [ 'Action' => 'SetCdnDomainSSLCertificate', 'DomainName' => $domain, @@ -142,7 +144,7 @@ class aliyun implements DeployInterface { $domain = $config['domain']; if (empty($domain)) throw new Exception('DCDN绑定域名不能为空'); - $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, 'dcdn.aliyuncs.com', '2018-01-15'); + $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, 'dcdn.aliyuncs.com', '2018-01-15', $this->proxy); $param = [ 'Action' => 'SetDcdnDomainSSLCertificate', 'DomainName' => $domain, @@ -239,7 +241,7 @@ class aliyun implements DeployInterface $endpoint = 'wafopenapi.' . $config['region'] . '.aliyuncs.com'; - $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $endpoint, '2021-10-01'); + $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $endpoint, '2021-10-01', $this->proxy); $param = [ 'Action' => 'DescribeInstance', @@ -298,7 +300,7 @@ class aliyun implements DeployInterface $endpoint = 'wafopenapi.' . $config['region'] . '.aliyuncs.com'; - $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $endpoint, '2019-09-10'); + $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $endpoint, '2019-09-10', $this->proxy); $param = [ 'Action' => 'DescribeInstanceInfo', @@ -337,7 +339,7 @@ class aliyun implements DeployInterface $endpoint = 'apigateway.' . $config['regionid'] . '.aliyuncs.com'; - $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $endpoint, '2016-07-14'); + $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $endpoint, '2016-07-14', $this->proxy); $param = [ 'Action' => 'SetDomainCertificate', @@ -359,7 +361,7 @@ class aliyun implements DeployInterface $endpoint = 'ddoscoo.' . $config['region'] . '.aliyuncs.com'; - $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $endpoint, '2020-01-01'); + $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $endpoint, '2020-01-01', $this->proxy); $param = [ 'Action' => 'AssociateWebCert', @@ -375,7 +377,7 @@ class aliyun implements DeployInterface { $domain = $config['domain']; if (empty($domain)) throw new Exception('视频直播绑定域名不能为空'); - $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, 'live.aliyuncs.com', '2016-11-01'); + $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, 'live.aliyuncs.com', '2016-11-01', $this->proxy); $param = [ 'Action' => 'SetLiveDomainCertificate', 'DomainName' => $domain, @@ -392,7 +394,7 @@ class aliyun implements DeployInterface { $domain = $config['domain']; if (empty($domain)) throw new Exception('视频点播绑定域名不能为空'); - $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, 'vod.cn-shanghai.aliyuncs.com', '2017-03-21'); + $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, 'vod.cn-shanghai.aliyuncs.com', '2017-03-21', $this->proxy); $param = [ 'Action' => 'SetVodDomainCertificate', 'DomainName' => $domain, @@ -415,7 +417,7 @@ class aliyun implements DeployInterface if (!$certInfo) throw new Exception('证书解析失败'); $cert_name = str_replace('*.', '', $certInfo['subject']['CN']) . '-' . $certInfo['validFrom_time_t']; - $client = new AliyunNewClient($this->AccessKeyId, $this->AccessKeySecret, $fc_cname, '2023-03-30'); + $client = new AliyunNewClient($this->AccessKeyId, $this->AccessKeySecret, $fc_cname, '2023-03-30', $this->proxy); try { $data = $client->request('GET', 'GetCustomDomain', '/2023-03-30/custom-domains/' . $domain); @@ -458,7 +460,7 @@ class aliyun implements DeployInterface if (!$certInfo) throw new Exception('证书解析失败'); $cert_name = str_replace('*.', '', $certInfo['subject']['CN']) . '-' . $certInfo['validFrom_time_t']; - $client = new AliyunNewClient($this->AccessKeyId, $this->AccessKeySecret, $fc_cname, '2021-04-06'); + $client = new AliyunNewClient($this->AccessKeyId, $this->AccessKeySecret, $fc_cname, '2021-04-06', $this->proxy); try { $data = $client->request('GET', 'GetCustomDomain', '/2021-04-06/custom-domains/' . $domain); @@ -495,7 +497,7 @@ class aliyun implements DeployInterface if (empty($config['clb_port'])) throw new Exception('HTTPS监听端口不能为空'); $endpoint = 'slb.' . $config['regionid'] . '.aliyuncs.com'; - $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $endpoint, '2014-05-15'); + $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $endpoint, '2014-05-15', $this->proxy); $param = [ 'Action' => 'DescribeServerCertificates', @@ -570,7 +572,7 @@ class aliyun implements DeployInterface if (empty($config['alb_listener_id'])) throw new Exception('负载均衡监听ID不能为空'); $endpoint = 'alb.' . $config['regionid'] . '.aliyuncs.com'; - $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $endpoint, '2020-06-16'); + $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $endpoint, '2020-06-16', $this->proxy); $param = [ 'Action' => 'ListListenerCertificates', @@ -605,7 +607,7 @@ class aliyun implements DeployInterface if (empty($config['nlb_listener_id'])) throw new Exception('负载均衡监听ID不能为空'); $endpoint = 'nlb.' . $config['regionid'] . '.aliyuncs.com'; - $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $endpoint, '2022-04-30'); + $client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $endpoint, '2022-04-30', $this->proxy); $param = [ 'Action' => 'ListListenerCertificates', diff --git a/app/lib/deploy/aws.php b/app/lib/deploy/aws.php index b721d22..74773ff 100644 --- a/app/lib/deploy/aws.php +++ b/app/lib/deploy/aws.php @@ -11,17 +11,19 @@ class aws implements DeployInterface private $logger; private $AccessKeyId; private $SecretAccessKey; + private $proxy; public function __construct($config) { $this->AccessKeyId = $config['AccessKeyId']; $this->SecretAccessKey = $config['SecretAccessKey']; + $this->proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; } public function check() { if (empty($this->AccessKeyId) || empty($this->SecretAccessKey)) throw new Exception('必填参数不能为空'); - $client = new AWSClient($this->AccessKeyId, $this->SecretAccessKey, 'iam.amazonaws.com', 'iam', '2010-05-08', 'us-east-1'); + $client = new AWSClient($this->AccessKeyId, $this->SecretAccessKey, 'iam.amazonaws.com', 'iam', '2010-05-08', 'us-east-1', $this->proxy); $client->requestXml('GET', 'GetUser'); return true; } @@ -44,7 +46,7 @@ class aws implements DeployInterface usleep(500000); } - $client = new \app\lib\client\AWS($this->AccessKeyId, $this->SecretAccessKey, 'cloudfront.amazonaws.com', 'cloudfront', '2020-05-31', 'us-east-1'); + $client = new AWSClient($this->AccessKeyId, $this->SecretAccessKey, 'cloudfront.amazonaws.com', 'cloudfront', '2020-05-31', 'us-east-1', $this->proxy); try { $data = $client->requestXmlN('GET', '/distribution/' . $config['distribution_id'] . '/config', [], null, true); } catch (Exception $e) { @@ -66,7 +68,7 @@ class aws implements DeployInterface 'PrivateKey' => base64_encode($privatekey), ]; - $client = new \app\lib\client\AWS($this->AccessKeyId, $this->SecretAccessKey, 'acm.us-east-1.amazonaws.com', 'acm', '', 'us-east-1'); + $client = new AWSClient($this->AccessKeyId, $this->SecretAccessKey, 'acm.us-east-1.amazonaws.com', 'acm', '', 'us-east-1', $this->proxy); try { $data = $client->request('POST', 'CertificateManager.ImportCertificate', $param); $cert_id = $data['CertificateArn']; diff --git a/app/lib/deploy/baidu.php b/app/lib/deploy/baidu.php index 366c106..a1423c7 100644 --- a/app/lib/deploy/baidu.php +++ b/app/lib/deploy/baidu.php @@ -11,17 +11,19 @@ class baidu implements DeployInterface private $logger; private $AccessKeyId; private $SecretAccessKey; + private $proxy; public function __construct($config) { $this->AccessKeyId = $config['AccessKeyId']; $this->SecretAccessKey = $config['SecretAccessKey']; + $this->proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; } public function check() { if (empty($this->AccessKeyId) || empty($this->SecretAccessKey)) throw new Exception('必填参数不能为空'); - $client = new BaiduCloud($this->AccessKeyId, $this->SecretAccessKey, 'cdn.baidubce.com'); + $client = new BaiduCloud($this->AccessKeyId, $this->SecretAccessKey, 'cdn.baidubce.com', $this->proxy); $client->request('GET', '/v2/domain'); return true; } @@ -33,7 +35,7 @@ class baidu implements DeployInterface if (!$certInfo) throw new Exception('证书解析失败'); $config['cert_name'] = str_replace('*.', '', $certInfo['subject']['CN']) . '-' . $certInfo['validFrom_time_t']; - $client = new BaiduCloud($this->AccessKeyId, $this->SecretAccessKey, 'cdn.baidubce.com'); + $client = new BaiduCloud($this->AccessKeyId, $this->SecretAccessKey, 'cdn.baidubce.com', $this->proxy); try { $data = $client->request('GET', '/v2/' . $config['domain'] . '/certificates'); if (isset($data['certName']) && $data['certName'] == $config['cert_name']) { diff --git a/app/lib/deploy/doge.php b/app/lib/deploy/doge.php index 93b1253..bcbc0f6 100644 --- a/app/lib/deploy/doge.php +++ b/app/lib/deploy/doge.php @@ -10,11 +10,13 @@ class doge implements DeployInterface private $logger; private $AccessKey; private $SecretKey; + private $proxy; public function __construct($config) { $this->AccessKey = $config['AccessKey']; $this->SecretKey = $config['SecretKey']; + $this->proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; } public function check() @@ -95,7 +97,7 @@ class doge implements DeployInterface $headers = ['Authorization: ' . $authorization]; if($body && $json) $headers[] = 'Content-Type: application/json'; $url = 'https://api.dogecloud.com'.$path; - $response = curl_client($url, $body, null, null, $headers); + $response = curl_client($url, $body, null, null, $headers, $this->proxy); $result = json_decode($response['body'], true); if(isset($result['code']) && $result['code'] == 200){ return isset($result['data']) ? $result['data'] : true; diff --git a/app/lib/deploy/huawei.php b/app/lib/deploy/huawei.php index da390a9..0006248 100644 --- a/app/lib/deploy/huawei.php +++ b/app/lib/deploy/huawei.php @@ -11,17 +11,19 @@ class huawei implements DeployInterface private $logger; private $AccessKeyId; private $SecretAccessKey; + private $proxy; public function __construct($config) { $this->AccessKeyId = $config['AccessKeyId']; $this->SecretAccessKey = $config['SecretAccessKey']; + $this->proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; } public function check() { if (empty($this->AccessKeyId) || empty($this->SecretAccessKey)) throw new Exception('必填参数不能为空'); - $client = new HuaweiCloud($this->AccessKeyId, $this->SecretAccessKey, 'scm.cn-north-4.myhuaweicloud.com'); + $client = new HuaweiCloud($this->AccessKeyId, $this->SecretAccessKey, 'scm.cn-north-4.myhuaweicloud.com', $this->proxy); $client->request('GET', '/v3/scm/certificates'); return true; } @@ -43,7 +45,7 @@ class huawei implements DeployInterface private function deploy_cdn($fullchain, $privatekey, $config) { if (empty($config['domain'])) throw new Exception('绑定的域名不能为空'); - $client = new HuaweiCloud($this->AccessKeyId, $this->SecretAccessKey, 'cdn.myhuaweicloud.com'); + $client = new HuaweiCloud($this->AccessKeyId, $this->SecretAccessKey, 'cdn.myhuaweicloud.com', $this->proxy); $param = [ 'configs' => [ 'https' => [ @@ -66,7 +68,7 @@ class huawei implements DeployInterface if (empty($config['region_id'])) throw new Exception('区域ID不能为空'); if (empty($config['cert_id'])) throw new Exception('证书ID不能为空'); $endpoint = 'elb.' . $config['region_id'] . '.myhuaweicloud.com'; - $client = new HuaweiCloud($this->AccessKeyId, $this->SecretAccessKey, $endpoint); + $client = new HuaweiCloud($this->AccessKeyId, $this->SecretAccessKey, $endpoint, $this->proxy); try { $data = $client->request('GET', '/v3/' . $config['project_id'] . '/elb/certificates/' . $config['cert_id']); } catch (Exception $e) { @@ -93,7 +95,7 @@ class huawei implements DeployInterface if (empty($config['region_id'])) throw new Exception('区域ID不能为空'); if (empty($config['cert_id'])) throw new Exception('证书ID不能为空'); $endpoint = 'waf.' . $config['region_id'] . '.myhuaweicloud.com'; - $client = new HuaweiCloud($this->AccessKeyId, $this->SecretAccessKey, $endpoint); + $client = new HuaweiCloud($this->AccessKeyId, $this->SecretAccessKey, $endpoint, $this->proxy); try { $data = $client->request('GET', '/v1/' . $config['project_id'] . '/waf/certificates/' . $config['cert_id']); } catch (Exception $e) { @@ -118,7 +120,7 @@ class huawei implements DeployInterface if (!$certInfo) throw new Exception('证书解析失败'); $cert_name = str_replace('*.', '', $certInfo['subject']['CN']) . '-' . $certInfo['validFrom_time_t']; - $client = new HuaweiCloud($this->AccessKeyId, $this->SecretAccessKey, 'scm.cn-north-4.myhuaweicloud.com'); + $client = new HuaweiCloud($this->AccessKeyId, $this->SecretAccessKey, 'scm.cn-north-4.myhuaweicloud.com', $this->proxy); $param = [ 'name' => $cert_name, 'certificate' => $fullchain, diff --git a/app/lib/deploy/huoshan.php b/app/lib/deploy/huoshan.php index dd35579..9d00d9a 100644 --- a/app/lib/deploy/huoshan.php +++ b/app/lib/deploy/huoshan.php @@ -11,17 +11,19 @@ class huoshan implements DeployInterface private $logger; private $AccessKeyId; private $SecretAccessKey; + private $proxy; public function __construct($config) { $this->AccessKeyId = $config['AccessKeyId']; $this->SecretAccessKey = $config['SecretAccessKey']; + $this->proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; } public function check() { if (empty($this->AccessKeyId) || empty($this->SecretAccessKey)) throw new Exception('必填参数不能为空'); - $client = new Volcengine($this->AccessKeyId, $this->SecretAccessKey, 'cdn.volcengineapi.com', 'cdn', '2021-03-01', 'cn-north-1'); + $client = new Volcengine($this->AccessKeyId, $this->SecretAccessKey, 'cdn.volcengineapi.com', 'cdn', '2021-03-01', 'cn-north-1', $this->proxy); $client->request('POST', 'ListCertInfo', ['Source' => 'volc_cert_center']); return true; } @@ -38,7 +40,7 @@ class huoshan implements DeployInterface private function deploy_cdn($cert_id, $config) { if (empty($config['domain'])) throw new Exception('绑定的域名不能为空'); - $client = new Volcengine($this->AccessKeyId, $this->SecretAccessKey, 'cdn.volcengineapi.com', 'cdn', '2021-03-01', 'cn-north-1'); + $client = new Volcengine($this->AccessKeyId, $this->SecretAccessKey, 'cdn.volcengineapi.com', 'cdn', '2021-03-01', 'cn-north-1', $this->proxy); $param = [ 'CertId' => $cert_id, 'Domain' => $config['domain'], @@ -60,7 +62,7 @@ class huoshan implements DeployInterface if (!$certInfo) throw new Exception('证书解析失败'); $cert_name = str_replace('*.', '', $certInfo['subject']['CN']) . '-' . $certInfo['validFrom_time_t']; - $client = new Volcengine($this->AccessKeyId, $this->SecretAccessKey, 'cdn.volcengineapi.com', 'cdn', '2021-03-01', 'cn-north-1'); + $client = new Volcengine($this->AccessKeyId, $this->SecretAccessKey, 'cdn.volcengineapi.com', 'cdn', '2021-03-01', 'cn-north-1', $this->proxy); $param = [ 'Source' => 'volc_cert_center', 'Certificate' => $fullchain, diff --git a/app/lib/deploy/qiniu.php b/app/lib/deploy/qiniu.php index 5a25dde..9abbaa6 100644 --- a/app/lib/deploy/qiniu.php +++ b/app/lib/deploy/qiniu.php @@ -17,7 +17,7 @@ class qiniu implements DeployInterface { $this->AccessKey = $config['AccessKey']; $this->SecretKey = $config['SecretKey']; - $this->client = new QiniuClient($this->AccessKey, $this->SecretKey); + $this->client = new QiniuClient($this->AccessKey, $this->SecretKey, isset($config['proxy']) ? $config['proxy'] == 1 : false); } public function check() diff --git a/app/lib/deploy/tencent.php b/app/lib/deploy/tencent.php index 9e6e561..a3f7d82 100644 --- a/app/lib/deploy/tencent.php +++ b/app/lib/deploy/tencent.php @@ -12,12 +12,14 @@ class tencent implements DeployInterface private $SecretId; private $SecretKey; private TencentCloud $client; + private $proxy; public function __construct($config) { $this->SecretId = $config['SecretId']; $this->SecretKey = $config['SecretKey']; - $this->client = new TencentCloud($this->SecretId, $this->SecretKey, 'ssl.tencentcloudapi.com', 'ssl', '2019-12-05'); + $this->proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; + $this->client = new TencentCloud($this->SecretId, $this->SecretKey, 'ssl.tencentcloudapi.com', 'ssl', '2019-12-05', null, $this->proxy); } public function check() @@ -36,20 +38,20 @@ class tencent implements DeployInterface if (empty($config['cos_bucket'])) throw new Exception('存储桶名称不能为空'); if (empty($config['domain'])) throw new Exception('绑定的域名不能为空'); $instance_id = $config['regionid'] . '#' . $config['cos_bucket'] . '#' . $config['domain']; - $this->client = new TencentCloud($this->SecretId, $this->SecretKey, 'ssl.tencentcloudapi.com', 'ssl', '2019-12-05', $config['regionid']); + $this->client = new TencentCloud($this->SecretId, $this->SecretKey, 'ssl.tencentcloudapi.com', 'ssl', '2019-12-05', $config['regionid'], $this->proxy); } elseif ($config['product'] == 'tke') { if (empty($config['regionid'])) throw new Exception('所属地域ID不能为空'); if (empty($config['tke_cluster_id'])) throw new Exception('集群ID不能为空'); if (empty($config['tke_namespace'])) throw new Exception('命名空间不能为空'); if (empty($config['tke_secret'])) throw new Exception('secret名称不能为空'); $instance_id = $config['tke_cluster_id'] . '|' . $config['tke_namespace'] . '|' . $config['tke_secret']; - $this->client = new TencentCloud($this->SecretId, $this->SecretKey, 'ssl.tencentcloudapi.com', 'ssl', '2019-12-05', $config['regionid']); + $this->client = new TencentCloud($this->SecretId, $this->SecretKey, 'ssl.tencentcloudapi.com', 'ssl', '2019-12-05', $config['regionid'], $this->proxy); } elseif ($config['product'] == 'lighthouse') { if (empty($config['regionid'])) throw new Exception('所属地域ID不能为空'); if (empty($config['lighthouse_id'])) throw new Exception('实例ID不能为空'); if (empty($config['domain'])) throw new Exception('绑定的域名不能为空'); $instance_id = $config['regionid'] . '|' . $config['lighthouse_id'] . '|' . $config['domain']; - $this->client = new TencentCloud($this->SecretId, $this->SecretKey, 'ssl.tencentcloudapi.com', 'ssl', '2019-12-05', $config['regionid']); + $this->client = new TencentCloud($this->SecretId, $this->SecretKey, 'ssl.tencentcloudapi.com', 'ssl', '2019-12-05', $config['regionid'], $this->proxy); } elseif ($config['product'] == 'clb') { return $this->deploy_clb($cert_id, $config); } elseif ($config['product'] == 'scf') { @@ -57,10 +59,10 @@ class tencent implements DeployInterface } else { if (empty($config['domain'])) throw new Exception('绑定的域名不能为空'); if ($config['product'] == 'waf') { - $this->client = new TencentCloud($this->SecretId, $this->SecretKey, 'ssl.tencentcloudapi.com', 'ssl', '2019-12-05', $config['region']); + $this->client = new TencentCloud($this->SecretId, $this->SecretKey, 'ssl.tencentcloudapi.com', 'ssl', '2019-12-05', $config['region'], $this->proxy); } elseif (in_array($config['product'], ['tse', 'scf'])) { if (empty($config['regionid'])) throw new Exception('所属地域ID不能为空'); - $this->client = new TencentCloud($this->SecretId, $this->SecretKey, 'ssl.tencentcloudapi.com', 'ssl', '2019-12-05', $config['regionid']); + $this->client = new TencentCloud($this->SecretId, $this->SecretKey, 'ssl.tencentcloudapi.com', 'ssl', '2019-12-05', $config['regionid'], $this->proxy); } $instance_id = $config['domain']; } @@ -149,7 +151,7 @@ class tencent implements DeployInterface if (empty($config['clb_id'])) throw new Exception('负载均衡ID不能为空'); $sni_switch = !empty($config['clb_domain']) ? 1 : 0; - $client = new TencentCloud($this->SecretId, $this->SecretKey, 'clb.tencentcloudapi.com', 'clb', '2018-03-17', $config['regionid']); + $client = new TencentCloud($this->SecretId, $this->SecretKey, 'clb.tencentcloudapi.com', 'clb', '2018-03-17', $config['regionid'], $this->proxy); $param = [ 'LoadBalancerId' => $config['clb_id'], 'Protocol' => 'HTTPS', @@ -214,7 +216,7 @@ class tencent implements DeployInterface if (empty($config['regionid'])) throw new Exception('所属地域ID不能为空'); if (empty($config['domain'])) throw new Exception('绑定的域名不能为空'); - $client = new TencentCloud($this->SecretId, $this->SecretKey, 'scf.tencentcloudapi.com', 'scf', '2018-04-16', $config['regionid']); + $client = new TencentCloud($this->SecretId, $this->SecretKey, 'scf.tencentcloudapi.com', 'scf', '2018-04-16', $config['regionid'], $this->proxy); $param = [ 'Domain' => $config['domain'], ]; diff --git a/app/lib/dns/aliyun.php b/app/lib/dns/aliyun.php index df8cd1f..d22ae6c 100644 --- a/app/lib/dns/aliyun.php +++ b/app/lib/dns/aliyun.php @@ -22,7 +22,8 @@ class aliyun implements DnsInterface { $this->AccessKeyId = $config['ak']; $this->AccessKeySecret = $config['sk']; - $this->client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $this->Endpoint, $this->Version); + $proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; + $this->client = new AliyunClient($this->AccessKeyId, $this->AccessKeySecret, $this->Endpoint, $this->Version, $proxy); $this->domain = $config['domain']; } diff --git a/app/lib/dns/baidu.php b/app/lib/dns/baidu.php index 4f0e500..28adbab 100644 --- a/app/lib/dns/baidu.php +++ b/app/lib/dns/baidu.php @@ -20,7 +20,8 @@ class baidu implements DnsInterface { $this->AccessKeyId = $config['ak']; $this->SecretAccessKey = $config['sk']; - $this->client = new BaiduCloud($this->AccessKeyId, $this->SecretAccessKey, $this->endpoint); + $proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; + $this->client = new BaiduCloud($this->AccessKeyId, $this->SecretAccessKey, $this->endpoint, $proxy); $this->domain = $config['domain']; $this->domainid = $config['domainid']; } diff --git a/app/lib/dns/cloudflare.php b/app/lib/dns/cloudflare.php index be82b6a..e806198 100644 --- a/app/lib/dns/cloudflare.php +++ b/app/lib/dns/cloudflare.php @@ -12,6 +12,7 @@ class cloudflare implements DnsInterface private $error; private $domain; private $domainid; + private $proxy; function __construct($config) { @@ -19,6 +20,7 @@ class cloudflare implements DnsInterface $this->ApiKey = $config['sk']; $this->domain = $config['domain']; $this->domainid = $config['domainid']; + $this->proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; } public function getError() @@ -261,6 +263,9 @@ class cloudflare implements DnsInterface } $ch = curl_init($url); + if ($this->proxy) { + curl_set_proxy($ch); + } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); diff --git a/app/lib/dns/dnsla.php b/app/lib/dns/dnsla.php index 9ac6fef..b6dfaf6 100644 --- a/app/lib/dns/dnsla.php +++ b/app/lib/dns/dnsla.php @@ -13,6 +13,7 @@ class dnsla implements DnsInterface private $error; private $domain; private $domainid; + private $proxy; public function __construct($config) { @@ -20,6 +21,7 @@ class dnsla implements DnsInterface $this->apisecret = $config['sk']; $this->domain = $config['domain']; $this->domainid = $config['domainid']; + $this->proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; } public function getError() @@ -249,10 +251,13 @@ class dnsla implements DnsInterface } } - private function curl($method, $path, $header, $body = null, $isPut = false) + private function curl($method, $path, $header, $body = null) { $url = $this->baseUrl . $path; $ch = curl_init($url); + if ($this->proxy) { + curl_set_proxy($ch); + } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); diff --git a/app/lib/dns/dnspod.php b/app/lib/dns/dnspod.php index 78ddc31..c3cda81 100644 --- a/app/lib/dns/dnspod.php +++ b/app/lib/dns/dnspod.php @@ -23,7 +23,8 @@ class dnspod implements DnsInterface { $this->SecretId = $config['ak']; $this->SecretKey = $config['sk']; - $this->client = new TencentCloud($this->SecretId, $this->SecretKey, $this->endpoint, $this->service, $this->version); + $proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; + $this->client = new TencentCloud($this->SecretId, $this->SecretKey, $this->endpoint, $this->service, $this->version, null, $proxy); $this->domain = $config['domain']; } diff --git a/app/lib/dns/huawei.php b/app/lib/dns/huawei.php index b709118..7406d35 100644 --- a/app/lib/dns/huawei.php +++ b/app/lib/dns/huawei.php @@ -20,7 +20,8 @@ class huawei implements DnsInterface { $this->AccessKeyId = $config['ak']; $this->SecretAccessKey = $config['sk']; - $this->client = new HuaweiCloud($this->AccessKeyId, $this->SecretAccessKey, $this->endpoint); + $proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; + $this->client = new HuaweiCloud($this->AccessKeyId, $this->SecretAccessKey, $this->endpoint, $proxy); $this->domain = $config['domain']; $this->domainid = $config['domainid']; } diff --git a/app/lib/dns/huoshan.php b/app/lib/dns/huoshan.php index 71dd792..043f4be 100644 --- a/app/lib/dns/huoshan.php +++ b/app/lib/dns/huoshan.php @@ -32,7 +32,8 @@ class huoshan implements DnsInterface { $this->AccessKeyId = $config['ak']; $this->SecretAccessKey = $config['sk']; - $this->client = new Volcengine($this->AccessKeyId, $this->SecretAccessKey, $this->endpoint, $this->service, $this->version, $this->region); + $proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; + $this->client = new Volcengine($this->AccessKeyId, $this->SecretAccessKey, $this->endpoint, $this->service, $this->version, $this->region, $proxy); $this->domain = $config['domain']; $this->domainid = $config['domainid']; } diff --git a/app/lib/dns/namesilo.php b/app/lib/dns/namesilo.php index 7b0eaa6..68c1746 100644 --- a/app/lib/dns/namesilo.php +++ b/app/lib/dns/namesilo.php @@ -12,11 +12,13 @@ class namesilo implements DnsInterface private $version = '1'; private $error; private $domain; + private $proxy; function __construct($config) { $this->apikey = $config['sk']; $this->domain = $config['domain']; + $this->proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; } public function getError() @@ -193,7 +195,7 @@ class namesilo implements DnsInterface $url .= '?' . http_build_query($params); try{ - $response = curl_client($url); + $response = curl_client($url, null, null, null, null, $this->proxy); }catch(Exception $e){ $this->setError($e->getMessage()); return false; diff --git a/app/lib/dns/west.php b/app/lib/dns/west.php index 9303f2a..db174ab 100644 --- a/app/lib/dns/west.php +++ b/app/lib/dns/west.php @@ -15,12 +15,14 @@ class west implements DnsInterface private $error; private $domain; private $domainid; + private $proxy; public function __construct($config) { $this->username = $config['ak']; $this->api_password = $config['sk']; $this->domain = $config['domain']; + $this->proxy = isset($config['proxy']) ? $config['proxy'] == 1 : false; } public function getError() @@ -179,8 +181,13 @@ class west implements DnsInterface $params['username'] = $this->username; $params['time'] = $this->getMillisecond(); $params['token'] = md5($this->username.$this->api_password.$params['time']); - $response = $this->curl($path, $params); - $response = mb_convert_encoding($response, 'UTF-8', 'GBK'); + try{ + $response = curl_client($this->baseUrl . $path, http_build_query($params), null, null, null, $this->proxy); + }catch(\Exception $e){ + $this->setError($e->getMessage()); + return false; + } + $response = mb_convert_encoding($response['body'], 'UTF-8', 'GBK'); $arr = json_decode($response, true); if ($arr) { if ($arr['result'] == 200) { @@ -195,28 +202,6 @@ class west implements DnsInterface } } - private function curl($path, $params = null) - { - $url = $this->baseUrl . $path; - $ch = curl_init($url); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_TIMEOUT, 10); - if ($params) { - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); - } - $response = curl_exec($ch); - $errno = curl_errno($ch); - if ($errno) { - $this->setError('Curl error: ' . curl_error($ch)); - } - curl_close($ch); - if ($errno) return false; - return $response; - } - private function getMillisecond() { list($s1, $s2) = explode(' ', microtime()); diff --git a/app/sql/install.sql b/app/sql/install.sql index da5f7c5..6a2a092 100644 --- a/app/sql/install.sql +++ b/app/sql/install.sql @@ -18,6 +18,7 @@ CREATE TABLE `dnsmgr_account` ( `ak` varchar(256) DEFAULT NULL, `sk` varchar(256) DEFAULT NULL, `ext` varchar(256) DEFAULT NULL, + `proxy` tinyint(1) NOT NULL DEFAULT '0', `remark` varchar(100) DEFAULT NULL, `addtime` datetime DEFAULT NULL, PRIMARY KEY (`id`) diff --git a/app/sql/update.sql b/app/sql/update.sql index cd3e3d9..05d3ac7 100644 --- a/app/sql/update.sql +++ b/app/sql/update.sql @@ -149,4 +149,7 @@ CREATE TABLE IF NOT EXISTS `dnsmgr_cert_cname` ( `addtime` datetime DEFAULT NULL, `status` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +ALTER TABLE `dnsmgr_account` +ADD COLUMN `proxy` tinyint(1) NOT NULL DEFAULT '0'; \ No newline at end of file diff --git a/app/utils/MsgNotice.php b/app/utils/MsgNotice.php index 9c1fd66..ddccb58 100644 --- a/app/utils/MsgNotice.php +++ b/app/utils/MsgNotice.php @@ -253,26 +253,7 @@ class MsgNotice { $ch = curl_init(); if (config_get('tgbot_proxy') == 1) { - $proxy_server = config_get('proxy_server'); - $proxy_port = intval(config_get('proxy_port')); - $proxy_userpwd = config_get('proxy_user').':'.config_get('proxy_pwd'); - $proxy_type = config_get('proxy_type'); - if ($proxy_type == 'https') { - $proxy_type = CURLPROXY_HTTPS; - } elseif ($proxy_type == 'sock4') { - $proxy_type = CURLPROXY_SOCKS4; - } elseif ($proxy_type == 'sock5') { - $proxy_type = CURLPROXY_SOCKS5; - } else { - $proxy_type = CURLPROXY_HTTP; - } - curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); - curl_setopt($ch, CURLOPT_PROXY, $proxy_server); - curl_setopt($ch, CURLOPT_PROXYPORT, $proxy_port); - if ($proxy_userpwd != ':') { - curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_userpwd); - } - curl_setopt($ch, CURLOPT_PROXYTYPE, $proxy_type); + curl_set_proxy($ch); } curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 10); diff --git a/app/view/cert/account_form.html b/app/view/cert/account_form.html index 764b0c1..752f88b 100644 --- a/app/view/cert/account_form.html +++ b/app/view/cert/account_form.html @@ -150,7 +150,6 @@ new Vue({ }) return {label: classList[key], children: tempList} }) - console.log(this.typeOption); if(this.action == 'edit'){ Object.keys(info).forEach((key) => { this.set[key] = info[key] @@ -159,7 +158,9 @@ new Vue({ this.inputs = typeList[this.set.type].inputs; this.note = typeList[this.set.type].note; $.each(this.inputs, (name, item) => { - item.value = config[name]; + if(typeof config[name] != 'undefined'){ + item.value = config[name]; + } if(typeof item.value == 'undefined'){ if(item.type == 'checkbox'){ item.value = false; diff --git a/app/view/cert/deploy_form.html b/app/view/cert/deploy_form.html index e2011e1..499976f 100644 --- a/app/view/cert/deploy_form.html +++ b/app/view/cert/deploy_form.html @@ -160,7 +160,9 @@ new Vue({ this.inputs = typeList[this.set.type].taskinputs; this.note = typeList[this.set.type].tasknote; $.each(this.inputs, (name, item) => { - item.value = config[name]; + if(typeof config[name] != 'undefined'){ + item.value = config[name]; + } if(typeof item.value == 'undefined'){ if(item.type == 'checkbox'){ item.value = false; @@ -183,7 +185,7 @@ new Vue({ if(document.referrer.indexOf('&oid=') > 0){ var oid = document.referrer.split('&oid=')[1].split('&')[0]; if(oid){ - $('select[name=oid]').val(20).trigger('change'); + $('select[name=oid]').val(oid).trigger('change'); that.set.oid = oid; } } diff --git a/app/view/domain/account.html b/app/view/domain/account.html index 3e8675b..0145563 100644 --- a/app/view/domain/account.html +++ b/app/view/domain/account.html @@ -36,12 +36,20 @@ -
+ +
+ +
+ +
+
@@ -137,8 +145,12 @@ $(document).ready(function(){ if(dnsconfig[type] == undefined) return; $("#ak_name").html(dnsconfig[type].config.ak); $("#sk_name").html(dnsconfig[type].config.sk); - if(dnsconfig[type].config.ext == undefined) dnsconfig[type].config.ext = '扩展字段'; - else $("#ext_name").html(dnsconfig[type].config.ext); + if(dnsconfig[type].config.ext == undefined){ + $("#ext_name_div").hide(); + }else{ + $("#ext_name_div").show(); + $("#ext_name").html(dnsconfig[type].config.ext); + } }); }) function addframe(){ @@ -149,6 +161,7 @@ function addframe(){ $("#form-store input[name=ak]").val(''); $("#form-store input[name=sk]").val(''); $("#form-store input[name=ext]").val(''); + $("#form-store input[name=proxy]").eq(0).prop('checked',true); $("#form-store input[name=remark]").val(''); $("select[name=type]").change(); } @@ -170,6 +183,7 @@ function editframe(id){ $("#form-store input[name=ak]").val(data.data.ak); $("#form-store input[name=sk]").val(data.data.sk); $("#form-store input[name=ext]").val(data.data.ext); + $("#form-store input[name=proxy]").eq(data.data.proxy).prop('checked',true); $("#form-store input[name=remark]").val(data.data.remark); $("select[name=type]").change(); }else{ diff --git a/config/app.php b/config/app.php index 12b3569..eaf9dea 100644 --- a/config/app.php +++ b/config/app.php @@ -31,7 +31,7 @@ return [ 'show_error_msg' => true, 'exception_tmpl' => \think\facade\App::getAppPath() . 'view/exception.tpl', - 'version' => '1022', + 'version' => '1023', - 'dbversion' => '1021' + 'dbversion' => '1023' ];