diff --git a/app/lib/DeployHelper.php b/app/lib/DeployHelper.php index facd557..418632e 100644 --- a/app/lib/DeployHelper.php +++ b/app/lib/DeployHelper.php @@ -1170,7 +1170,7 @@ class DeployHelper 'doge' => [ 'name' => '多吉云', 'class' => 2, - 'icon' => 'cloud.png', + 'icon' => 'doge.png', 'desc' => '支持部署到多吉云融合CDN', 'note' => '支持部署到多吉云融合CDN', 'inputs' => [ @@ -1578,6 +1578,46 @@ class DeployHelper ], ], ], + 'rainyun' => [ + 'name' => '雨云', + 'class' => 2, + 'icon' => 'waf.png', + 'desc' => '替换雨云证书管理内的证书', + 'note' => null, + 'inputs' => [ + 'account' => [ + 'name' => '账号', + 'type' => 'input', + 'placeholder' => '仅用作标记', + 'required' => true, + ], + 'apikey' => [ + 'name' => 'ApiKey', + 'type' => 'input', + 'placeholder' => '', + 'note' => '在 账户设置->API密钥 页面查看', + 'required' => true, + ], + 'proxy' => [ + 'name' => '使用代理服务器', + 'type' => 'radio', + 'options' => [ + '0' => '否', + '1' => '是', + ], + 'value' => '0' + ], + ], + 'taskinputs' => [ + 'id' => [ + 'name' => '证书ID', + 'type' => 'input', + 'placeholder' => '', + 'note' => '在SSL证书->我的证书页面查看,注意域名是否与证书匹配', + 'required' => true, + ], + ], + ], 'aws' => [ 'name' => 'AWS', 'class' => 2, diff --git a/app/lib/deploy/rainyun.php b/app/lib/deploy/rainyun.php new file mode 100644 index 0000000..c5e3f40 --- /dev/null +++ b/app/lib/deploy/rainyun.php @@ -0,0 +1,78 @@ +apikey = $config['apikey']; + $this->proxy = $config['proxy'] == 1; + } + + public function check() + { + if (empty($this->apikey)) throw new Exception('ApiKey不能为空'); + $this->request('/product/'); + } + + public function deploy($fullchain, $privatekey, $config, &$info) + { + if (empty($config['id'])) throw new Exception('证书ID不能为空'); + + $params = [ + 'cert' => $fullchain, + 'key' => $privatekey, + ]; + try { + $this->request('/product/sslcenter/' . $config['id'], $params, 'PUT'); + } catch (Exception $e) { + throw new Exception($e->getMessage()); + } + + $this->log('证书ID:' . $config['id'] . '更新成功!'); + } + + private function request($path, $params = null, $method = null) + { + $url = $this->url . $path; + $headers = [ + 'x-api-key' => $this->apikey, + ]; + $body = null; + if ($params) { + $headers['Content-Type'] = 'application/json'; + $body = json_encode($params); + } + $response = http_request($url, $body, null, null, $headers, $this->proxy, $method); + $result = json_decode($response['body'], true); + if (isset($result['code']) && $result['code'] == 200) { + return $result; + } elseif (isset($result['message'])) { + throw new Exception($result['message']); + } else { + if (!empty($response['body'])) $this->log('Response:' . $response['body']); + throw new Exception('请求失败(httpCode=' . $response['code'] . ')'); + } + } + + public function setLogger($func) + { + $this->logger = $func; + } + + private function log($txt) + { + if ($this->logger) { + call_user_func($this->logger, $txt); + } + } +} diff --git a/public/static/images/doge.png b/public/static/images/doge.png new file mode 100644 index 0000000..f6a3c41 Binary files /dev/null and b/public/static/images/doge.png differ