mirror of
https://github.com/netcccyun/dnsmgr.git
synced 2026-02-21 15:31:12 +08:00
部分SSL部署支持批量
This commit is contained in:
parent
079a142b40
commit
cf36b4bd51
@ -998,7 +998,7 @@ class DeployHelper
|
||||
'domain' => [
|
||||
'name' => '绑定的域名',
|
||||
'type' => 'input',
|
||||
'placeholder' => '',
|
||||
'placeholder' => '多个域名可使用,分隔',
|
||||
'required' => true,
|
||||
],
|
||||
],
|
||||
@ -1035,7 +1035,7 @@ class DeployHelper
|
||||
'domain' => [
|
||||
'name' => 'CDN域名',
|
||||
'type' => 'input',
|
||||
'placeholder' => '',
|
||||
'placeholder' => '多个域名可使用,分隔',
|
||||
'required' => true,
|
||||
],
|
||||
],
|
||||
|
||||
@ -28,8 +28,8 @@ class doge implements DeployInterface
|
||||
|
||||
public function deploy($fullchain, $privatekey, $config, &$info)
|
||||
{
|
||||
$domain = $config['domain'];
|
||||
if (empty($domain)) throw new Exception('绑定的域名不能为空');
|
||||
$domains = $config['domain'];
|
||||
if (empty($domains)) throw new Exception('绑定的域名不能为空');
|
||||
|
||||
$certInfo = openssl_x509_parse($fullchain, true);
|
||||
if (!$certInfo) throw new Exception('证书解析失败');
|
||||
@ -37,13 +37,14 @@ class doge implements DeployInterface
|
||||
|
||||
$cert_id = $this->get_cert_id($fullchain, $privatekey, $cert_name);
|
||||
|
||||
$param = [
|
||||
'id' => $cert_id,
|
||||
'domain' => $domain,
|
||||
];
|
||||
$this->request('/cdn/cert/bind.json', $param);
|
||||
|
||||
$this->log('CDN域名 ' . $domain . ' 绑定证书成功!');
|
||||
foreach (explode(',', $domains) as $domain) {
|
||||
$param = [
|
||||
'id' => $cert_id,
|
||||
'domain' => $domain,
|
||||
];
|
||||
$this->request('/cdn/cert/bind.json', $param);
|
||||
$this->log('CDN域名 ' . $domain . ' 绑定证书成功!');
|
||||
}
|
||||
$info['cert_id'] = $cert_id;
|
||||
}
|
||||
|
||||
|
||||
@ -29,8 +29,8 @@ class qiniu implements DeployInterface
|
||||
|
||||
public function deploy($fullchain, $privatekey, $config, &$info)
|
||||
{
|
||||
$domain = $config['domain'];
|
||||
if (empty($domain)) throw new Exception('绑定的域名不能为空');
|
||||
$domains = $config['domain'];
|
||||
if (empty($domains)) throw new Exception('绑定的域名不能为空');
|
||||
|
||||
$certInfo = openssl_x509_parse($fullchain, true);
|
||||
if (!$certInfo) throw new Exception('证书解析失败');
|
||||
@ -38,14 +38,16 @@ class qiniu implements DeployInterface
|
||||
|
||||
$cert_id = $this->get_cert_id($fullchain, $privatekey, $certInfo['subject']['CN'], $cert_name);
|
||||
|
||||
if ($config['product'] == 'cdn') {
|
||||
$this->deploy_cdn($domain, $cert_id);
|
||||
} elseif ($config['product'] == 'oss') {
|
||||
$this->deploy_oss($domain, $cert_id);
|
||||
} elseif ($config['product'] == 'pili') {
|
||||
$this->deploy_pili($config['pili_hub'], $domain, $cert_name);
|
||||
} else {
|
||||
throw new Exception('未知的产品类型');
|
||||
foreach (explode(',', $domains) as $domain) {
|
||||
if ($config['product'] == 'cdn') {
|
||||
$this->deploy_cdn($domain, $cert_id);
|
||||
} elseif ($config['product'] == 'oss') {
|
||||
$this->deploy_oss($domain, $cert_id);
|
||||
} elseif ($config['product'] == 'pili') {
|
||||
$this->deploy_pili($config['pili_hub'], $domain, $cert_name);
|
||||
} else {
|
||||
throw new Exception('未知的产品类型');
|
||||
}
|
||||
}
|
||||
$info['cert_id'] = $cert_id;
|
||||
$info['cert_name'] = $cert_name;
|
||||
|
||||
@ -45,9 +45,9 @@ class TaskRunner
|
||||
if ($row['checktype'] == 2) {
|
||||
$result = CheckUtils::curl($row['checkurl'], $row['timeout'], $row['main_value'], $row['proxy'] == 1);
|
||||
} elseif ($row['checktype'] == 1) {
|
||||
$result = CheckUtils::tcp($row['main_value'], $row['tcpport'], $row['timeout']);
|
||||
$result = CheckUtils::tcp($row['main_value'], $row['checkurl'], $row['tcpport'], $row['timeout']);
|
||||
} else {
|
||||
$result = CheckUtils::ping($row['main_value']);
|
||||
$result = CheckUtils::ping($row['main_value'], $row['checkurl']);
|
||||
}
|
||||
|
||||
$action = 0;
|
||||
|
||||
@ -72,8 +72,9 @@ class CheckUtils
|
||||
return ['status' => $status, 'errmsg' => $errmsg, 'usetime' => $usetime];
|
||||
}
|
||||
|
||||
public static function tcp($target, $port, $timeout)
|
||||
public static function tcp($target, $ip, $port, $timeout)
|
||||
{
|
||||
if (!empty($ip) && filter_var($ip, FILTER_VALIDATE_IP)) $target = $ip;
|
||||
if (substr($target, -1) == '.') $target = substr($target, 0, -1);
|
||||
if (!filter_var($target, FILTER_VALIDATE_IP) && checkDomain($target)) {
|
||||
$target = gethostbyname($target);
|
||||
@ -95,9 +96,10 @@ class CheckUtils
|
||||
return ['status' => $status, 'errmsg' => $errStr, 'usetime' => $usetime];
|
||||
}
|
||||
|
||||
public static function ping($target)
|
||||
public static function ping($target, $ip)
|
||||
{
|
||||
if (!function_exists('exec')) return ['status' => false, 'errmsg' => 'exec函数不可用', 'usetime' => 0];
|
||||
if (!empty($ip) && filter_var($ip, FILTER_VALIDATE_IP)) $target = $ip;
|
||||
if (substr($target, -1) == '.') $target = substr($target, 0, -1);
|
||||
if (!filter_var($target, FILTER_VALIDATE_IP) && checkDomain($target)) {
|
||||
$target = gethostbyname($target);
|
||||
|
||||
@ -7,6 +7,11 @@
|
||||
position: absolute;
|
||||
left: 0;
|
||||
}
|
||||
.control-label[is-required]:before {
|
||||
content: "*";
|
||||
color: #f56c6c;
|
||||
margin-right: 4px;
|
||||
}
|
||||
.tips{color: #f6a838; padding-left: 5px;}
|
||||
</style>
|
||||
<div class="row" id="app">
|
||||
@ -16,7 +21,7 @@
|
||||
<div class="panel-body">
|
||||
<form onsubmit="return false" method="post" class="form-horizontal" role="form" id="taskform">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 col-xs-12 control-label no-padding-right">域名选择</label>
|
||||
<label class="col-sm-3 col-xs-12 control-label no-padding-right" is-required>域名选择</label>
|
||||
<div class="col-sm-6">
|
||||
<div class="input-group">
|
||||
<input type="text" name="rr" v-model="set.rr" placeholder="主机记录" class="form-control" required>
|
||||
@ -29,7 +34,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label no-padding-right">解析记录</label>
|
||||
<label class="col-sm-3 control-label no-padding-right" is-required>解析记录</label>
|
||||
<div class="col-sm-6"><div class="input-group">
|
||||
<select name="recordid" v-model="set.recordid" id="recordid" class="form-control" required>
|
||||
<option v-for="option in recordList" :value="option.RecordId">{{option.Value}} (线路:{{option.LineName}})</option>
|
||||
@ -40,7 +45,7 @@
|
||||
</div></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label no-padding-right">切换设置</label>
|
||||
<label class="col-sm-3 control-label no-padding-right" is-required>切换设置</label>
|
||||
<div class="col-sm-6">
|
||||
<label class="radio-inline" v-for="option in typeList">
|
||||
<input type="radio" name="type" :value="option.value" v-model="set.type" :disabled="option.disabled"> {{option.label}}
|
||||
@ -48,7 +53,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" v-show="set.type==2">
|
||||
<label class="col-sm-3 control-label no-padding-right">备用解析记录</label>
|
||||
<label class="col-sm-3 control-label no-padding-right" is-required>备用解析记录</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" name="backup_value" v-model="set.backup_value" placeholder="支持填写IPv4或CNAME地址" class="form-control" required>
|
||||
</div>
|
||||
@ -63,21 +68,27 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" v-show="set.type<=2">
|
||||
<label class="col-sm-3 control-label no-padding-right">检测协议</label>
|
||||
<label class="col-sm-3 control-label no-padding-right" is-required>检测协议</label>
|
||||
<div class="col-sm-6">
|
||||
<label class="radio-inline" v-for="option in checktypeList">
|
||||
<input type="radio" name="checktype" :value="option.value" v-model="set.checktype" :disabled="option.disabled"> {{option.label}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" v-show="set.type<=2&&set.checktype<2">
|
||||
<label class="col-sm-3 control-label no-padding-right">指定检测IP</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" name="checkurl" v-model="set.checkurl" placeholder="留空默认为解析记录值IP" class="form-control" data-bv-uri="true" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" v-show="set.type<=2&&set.checktype==1">
|
||||
<label class="col-sm-3 control-label no-padding-right">TCP检测端口</label>
|
||||
<label class="col-sm-3 control-label no-padding-right" is-required>TCP检测端口</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" name="tcpport" v-model="set.tcpport" placeholder="填写TCP端口号" class="form-control" data-bv-integer="true" min="1" max="65535" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" v-show="set.type<=2&&set.checktype==2">
|
||||
<label class="col-sm-3 control-label no-padding-right">检测URL地址</label>
|
||||
<label class="col-sm-3 control-label no-padding-right" is-required>检测URL地址</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" name="checkurl" v-model="set.checkurl" placeholder="填写以http(s)://开头的完整地址,http状态码须为2xx/3xx" class="form-control" data-bv-uri="true" required>
|
||||
</div>
|
||||
@ -94,7 +105,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" v-show="set.type<=2&&set.checktype>0">
|
||||
<label class="col-sm-3 control-label no-padding-right">最大超时时间</label>
|
||||
<label class="col-sm-3 control-label no-padding-right" is-required>最大超时时间</label>
|
||||
<div class="col-sm-3">
|
||||
<div class="input-group">
|
||||
<input type="text" name="timeout" v-model="set.timeout" placeholder="填写请求最大超时时间" class="form-control" data-bv-integer="true" min="1" required>
|
||||
@ -103,13 +114,13 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" v-show="set.type==3">
|
||||
<label class="col-sm-3 control-label no-padding-right">同域名正常数量<span class="tips" title="" data-toggle="tooltip" data-placement="bottom" data-original-title="与暂停解析配合使用,当同域名正常记录数量<=几条时开启解析"><i class="fa fa-question-circle"></i></span></label>
|
||||
<label class="col-sm-3 control-label no-padding-right" is-required>同域名正常数量<span class="tips" title="" data-toggle="tooltip" data-placement="bottom" data-original-title="与暂停解析配合使用,当同域名正常记录数量<=几条时开启解析"><i class="fa fa-question-circle"></i></span></label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" name="cycle" v-model="set.cycle" placeholder="同域名正常记录数量<=几条时开启解析" class="form-control" data-bv-integer="true" min="0" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label no-padding-right">检测间隔</label>
|
||||
<label class="col-sm-3 control-label no-padding-right" is-required>检测间隔</label>
|
||||
<div class="col-sm-3">
|
||||
<div class="input-group">
|
||||
<input type="text" name="frequency" v-model="set.frequency" placeholder="每次检测的间隔时间" class="form-control" data-bv-integer="true" min="1" required>
|
||||
@ -118,7 +129,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" v-show="set.type<=2">
|
||||
<label class="col-sm-3 control-label no-padding-right">确认次数</label>
|
||||
<label class="col-sm-3 control-label no-padding-right" is-required>确认次数</label>
|
||||
<div class="col-sm-3">
|
||||
<input type="text" name="cycle" v-model="set.cycle" placeholder="连续失败几次后进行切换" class="form-control" data-bv-integer="true" min="1" required>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user