diff --git a/app/lib/DeployHelper.php b/app/lib/DeployHelper.php index 418632e..d559f88 100644 --- a/app/lib/DeployHelper.php +++ b/app/lib/DeployHelper.php @@ -998,6 +998,24 @@ class DeployHelper 'show' => 'product==\'lighthouse\'||product==\'ddos\'', 'required' => true, ], + 'site_type' => [ + 'name' => '站点类型', + 'type' => 'select', + 'options' => [ + ['value'=>'cn', 'label'=>'国内站'], + ['value'=>'intl', 'label'=>'国际站'], + ], + 'value' => 'cn', + 'show' => 'product==\'teo\'', + 'required' => true, + ], + 'site_id' => [ + 'name' => '站点ID', + 'type' => 'input', + 'placeholder' => '类似于zone-xxxx,在站点列表或概览页面查看', + 'show' => 'product==\'teo\'', + 'required' => true, + ], 'domain' => [ 'name' => '绑定的域名', 'type' => 'input', @@ -1866,6 +1884,12 @@ class DeployHelper 'show' => 'format==\'pfx\'', 'required' => true, ], + 'cmd_pre' => [ + 'name' => '上传前执行命令', + 'type' => 'textarea', + 'show' => 'format==\'pem\'||uptype==0', + 'placeholder' => '可留空,上传前执行脚本命令', + ], 'cmd' => [ 'name' => '上传完执行命令', 'type' => 'textarea', diff --git a/app/lib/deploy/aliyun.php b/app/lib/deploy/aliyun.php index 49f4baf..f547298 100644 --- a/app/lib/deploy/aliyun.php +++ b/app/lib/deploy/aliyun.php @@ -292,6 +292,9 @@ class aliyun implements DeployInterface } catch (Exception $e) { throw new Exception('查询CNAME接入详情失败:' . $e->getMessage()); } + if (!isset($data['Listen'])) { + throw new Exception('没有找到' . $domain . '监听器'); + } if (isset($data['Listen']['CertId'])) { $old_cert_id = $data['Listen']['CertId']; diff --git a/app/lib/deploy/ssh.php b/app/lib/deploy/ssh.php index 3ac10f1..fff72ec 100644 --- a/app/lib/deploy/ssh.php +++ b/app/lib/deploy/ssh.php @@ -23,6 +23,14 @@ class ssh implements DeployInterface public function deploy($fullchain, $privatekey, $config, &$info) { $connection = $this->connect(); + if (isset($config['cmd_pre']) && !empty($config['cmd_pre'])) { + $cmds = explode("\n", $config['cmd_pre']); + foreach ($cmds as $cmd) { + $cmd = trim($cmd); + if (empty($cmd)) continue; + $this->exec($connection, $cmd); + } + } $sftp = ssh2_sftp($connection); if ($config['format'] == 'pem') { $stream = fopen("ssh2.sftp://$sftp{$config['pem_cert_file']}", 'w'); diff --git a/app/lib/deploy/tencent.php b/app/lib/deploy/tencent.php index 078420c..f7fe602 100644 --- a/app/lib/deploy/tencent.php +++ b/app/lib/deploy/tencent.php @@ -60,6 +60,8 @@ class tencent implements DeployInterface return $this->deploy_clb($cert_id, $config); } elseif ($config['product'] == 'scf') { return $this->deploy_scf($cert_id, $config); + } elseif ($config['product'] == 'teo' && isset($config['site_id'])) { + return $this->deploy_teo($cert_id, $config); } else { if (empty($config['domain'])) throw new Exception('绑定的域名不能为空'); if ($config['product'] == 'waf') { @@ -122,11 +124,17 @@ class tencent implements DeployInterface } else { $instance_ids = [$instance_id]; } + if ($product == 'cdn') { + $instance_ids = array_map(function ($id) { + return $id . '|on'; + }, $instance_ids); + } $param = [ 'CertificateId' => $cert_id, 'InstanceIdList' => $instance_ids, 'ResourceType' => $product, ]; + if ($product == 'live') $param['Status'] = 1; $data = $this->client->request('DeployCertificateInstance', $param); $this->log(json_encode($data)); $this->log(strtoupper($product) . '实例 ' . $instance_id . ' 部署证书成功!'); @@ -253,6 +261,26 @@ class tencent implements DeployInterface $this->log('云函数自定义域名 ' . $config['domain'] . ' 部署证书成功!'); } + private function deploy_teo($cert_id, $config) + { + if (empty($config['site_id'])) throw new Exception('站点ID不能为空'); + if (empty($config['domain'])) throw new Exception('绑定的域名不能为空'); + + $endpoint = isset($config['site_type']) && $config['site_type'] == 'intl' ? 'teo.intl.tencentcloudapi.com' : 'teo.tencentcloudapi.com'; + $client = new TencentCloud($this->SecretId, $this->SecretKey, $endpoint, 'teo', '2022-09-01', null, $this->proxy); + $hosts = explode(',', $config['domain']); + $param = [ + 'ZoneId' => $config['site_id'], + 'Hosts' => $hosts, + 'Mode' => 'sslcert', + 'ServerCertInfo' => [[ + 'CertId' => $cert_id + ]] + ]; + $data = $client->request('ModifyHostsCertificate', $param); + $this->log('边缘安全加速域名 ' . $config['domain'] . ' 部署证书成功!'); + } + public function setLogger($func) { $this->logger = $func; diff --git a/app/service/OptimizeService.php b/app/service/OptimizeService.php index 27dabda..5ceac45 100644 --- a/app/service/OptimizeService.php +++ b/app/service/OptimizeService.php @@ -39,9 +39,7 @@ class OptimizeService public function get_ip_address($cdn_type = 1, $ip_type = 'v4') { $api = config_get('optimize_ip_api', 0); - if ($api == 2) { - $url = 'https://api.345673.xyz/get_data'; - } elseif ($api == 1) { + if ($api == 1) { $url = 'https://api.hostmonit.com/get_optimization_ip'; } else { $url = 'https://www.wetest.vip/api/cf2dns/'; @@ -51,6 +49,8 @@ class OptimizeService $url .= 'get_cloudfront_ip'; } elseif ($cdn_type == 3) { $url .= 'get_gcore_ip'; + } elseif ($cdn_type == 4) { + $url .= 'get_edgeone_ip'; } } $params = [ diff --git a/app/view/optimizeip/opipform.html b/app/view/optimizeip/opipform.html index 3cc69ec..343c490 100644 --- a/app/view/optimizeip/opipform.html +++ b/app/view/optimizeip/opipform.html @@ -129,7 +129,7 @@ new Vue({ cdntypeList: { 1:'CloudFlare', 2:"CloudFront", - 3:'Gcore' + 4:'EdgeOne' }, }, watch: { diff --git a/app/view/optimizeip/opiplist.html b/app/view/optimizeip/opiplist.html index c6f78c5..c5ec43e 100644 --- a/app/view/optimizeip/opiplist.html +++ b/app/view/optimizeip/opiplist.html @@ -75,6 +75,8 @@ $(document).ready(function(){ return 'CloudFront'; }else if(value == 3){ return 'Gcore'; + }else if(value == 4){ + return 'EdgeOne'; }else{ return '未知'; } diff --git a/app/view/optimizeip/opipset.html b/app/view/optimizeip/opipset.html index 875afd9..63cac5d 100644 --- a/app/view/optimizeip/opipset.html +++ b/app/view/optimizeip/opipset.html @@ -14,7 +14,7 @@
cd {:app()->getRootPath()} && php think opiptask