mirror of https://github.com/certd/certd
				
				
				
			perf: 支持选择运行策略设置
							parent
							
								
									c67a9215e3
								
							
						
					
					
						commit
						60f055f293
					
				| 
						 | 
				
			
			@ -11,6 +11,7 @@ export type PageSearch = {
 | 
			
		|||
  // sortOrder?: "asc" | "desc";
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export type PageRes = {
 | 
			
		||||
  pageNo?: number;
 | 
			
		||||
  pageSize?: number;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -264,6 +264,18 @@ export default {
 | 
			
		|||
    bulkImport: "Bulk Import",
 | 
			
		||||
    basicLimitError: "Basic version allows only one monitoring site. Please upgrade to the Pro version.",
 | 
			
		||||
    limitExceeded: "Sorry, you can only create up to {max} monitoring records. Please purchase or upgrade your plan.",
 | 
			
		||||
    setting: {
 | 
			
		||||
      siteMonitorSettings: "Site Monitor Settings",
 | 
			
		||||
      notificationChannel: "Notification Channel",
 | 
			
		||||
      setNotificationChannel: "Set the notification channel",
 | 
			
		||||
      retryTimes: "Retry Times",
 | 
			
		||||
      monitorRetryTimes: "Number of retry attempts for monitoring requests",
 | 
			
		||||
      monitorCronSetting: "Monitoring Schedule",
 | 
			
		||||
      cronTrigger: "Scheduled trigger for monitoring",
 | 
			
		||||
      dnsServer: "DNS Server",
 | 
			
		||||
      // dnsServerHelper: "使用自定义的域名解析服务器,如:1.1.1.1,8.8.8.8",
 | 
			
		||||
      dnsServerHelper: "Use a custom domain name resolution server, such as: 1.1.1.1,8.8.8.8",
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  checkStatus: {
 | 
			
		||||
    success: "Success",
 | 
			
		||||
| 
						 | 
				
			
			@ -302,13 +314,6 @@ export default {
 | 
			
		|||
  nickName: "Nickname",
 | 
			
		||||
  max50Chars: "Maximum 50 characters",
 | 
			
		||||
  myInfo: "My Information",
 | 
			
		||||
  siteMonitorSettings: "Site Monitor Settings",
 | 
			
		||||
  notificationChannel: "Notification Channel",
 | 
			
		||||
  setNotificationChannel: "Set the notification channel",
 | 
			
		||||
  retryTimes: "Retry Times",
 | 
			
		||||
  monitorRetryTimes: "Number of retry attempts for monitoring requests",
 | 
			
		||||
  monitorCronSetting: "Monitoring Schedule",
 | 
			
		||||
  cronTrigger: "Scheduled trigger for monitoring",
 | 
			
		||||
  save: "Save",
 | 
			
		||||
  editSchedule: "Edit Schedule",
 | 
			
		||||
  timerTrigger: "Timer Trigger",
 | 
			
		||||
| 
						 | 
				
			
			@ -692,10 +697,16 @@ export default {
 | 
			
		|||
    useTemplate: "Use This Template",
 | 
			
		||||
    batchCreate: "Batch Create Pipeline",
 | 
			
		||||
    singleCreate: "Create Single Pipeline",
 | 
			
		||||
    importCreate: "Batch Import Create",
 | 
			
		||||
    templateName: "Template Name",
 | 
			
		||||
    enterTemplateName: "Please enter template name",
 | 
			
		||||
    copyPipelineConfig: "Copy this pipeline configuration as template source",
 | 
			
		||||
    pipeline: "Pipeline",
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  sys: {
 | 
			
		||||
    setting: {
 | 
			
		||||
      showRunStrategy: "Show RunStrategy",
 | 
			
		||||
      showRunStrategyHelper: "Allow modify the run strategy of the task",
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -269,6 +269,17 @@ export default {
 | 
			
		|||
    bulkImport: "批量导入",
 | 
			
		||||
    basicLimitError: "基础版只能添加一个监控站点,请赞助升级专业版",
 | 
			
		||||
    limitExceeded: "对不起,您最多只能创建条{max}监控记录,请购买或升级套餐",
 | 
			
		||||
    setting: {
 | 
			
		||||
      siteMonitorSettings: "站点监控设置",
 | 
			
		||||
      notificationChannel: "通知渠道",
 | 
			
		||||
      setNotificationChannel: "设置通知渠道",
 | 
			
		||||
      retryTimes: "重试次数",
 | 
			
		||||
      monitorRetryTimes: "监控请求重试次数",
 | 
			
		||||
      monitorCronSetting: "监控定时设置",
 | 
			
		||||
      cronTrigger: "定时触发监控",
 | 
			
		||||
      dnsServer: "DNS服务器",
 | 
			
		||||
      dnsServerHelper: "使用自定义的域名解析服务器,如:1.1.1.1,8.8.8.8",
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  checkStatus: {
 | 
			
		||||
    success: "成功",
 | 
			
		||||
| 
						 | 
				
			
			@ -307,13 +318,7 @@ export default {
 | 
			
		|||
  nickName: "昵称",
 | 
			
		||||
  max50Chars: "最大50个字符",
 | 
			
		||||
  myInfo: "我的信息",
 | 
			
		||||
  siteMonitorSettings: "站点监控设置",
 | 
			
		||||
  notificationChannel: "通知渠道",
 | 
			
		||||
  setNotificationChannel: "设置通知渠道",
 | 
			
		||||
  retryTimes: "重试次数",
 | 
			
		||||
  monitorRetryTimes: "监控请求重试次数",
 | 
			
		||||
  monitorCronSetting: "监控定时设置",
 | 
			
		||||
  cronTrigger: "定时触发监控",
 | 
			
		||||
 | 
			
		||||
  save: "保存",
 | 
			
		||||
  editSchedule: "修改定时",
 | 
			
		||||
  timerTrigger: "定时触发",
 | 
			
		||||
| 
						 | 
				
			
			@ -695,10 +700,15 @@ export default {
 | 
			
		|||
    useTemplate: "使用此模板",
 | 
			
		||||
    batchCreate: "批量创建流水线",
 | 
			
		||||
    singleCreate: "创建单个流水线",
 | 
			
		||||
    importCreate: "批量导入创建",
 | 
			
		||||
    templateName: "模板名称",
 | 
			
		||||
    enterTemplateName: "请输入模板名称",
 | 
			
		||||
    copyPipelineConfig: "复制该流水线配置作为模板来源",
 | 
			
		||||
    pipeline: "流水线",
 | 
			
		||||
  },
 | 
			
		||||
  sys: {
 | 
			
		||||
    setting: {
 | 
			
		||||
      showRunStrategy: "显示运行策略选择",
 | 
			
		||||
      showRunStrategyHelper: "任务设置中是否允许选择运行策略",
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,6 +43,8 @@ export type SysPublicSetting = {
 | 
			
		|||
  mpsNo?: string;
 | 
			
		||||
  robots?: boolean;
 | 
			
		||||
  aiChatEnabled?: boolean;
 | 
			
		||||
 | 
			
		||||
  showRunStrategy?: boolean;
 | 
			
		||||
};
 | 
			
		||||
export type SuiteSetting = {
 | 
			
		||||
  enabled?: boolean;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,6 +5,7 @@ export type UserSiteMonitorSetting = {
 | 
			
		|||
  notificationId?: number;
 | 
			
		||||
  retryTimes?: number;
 | 
			
		||||
  cron?: string;
 | 
			
		||||
  dnsServer?: string[];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export async function SiteMonitorSettingsGet() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,28 +1,34 @@
 | 
			
		|||
<template>
 | 
			
		||||
  <fs-page class="page-user-settings page-site-monitor-setting">
 | 
			
		||||
    <template #header>
 | 
			
		||||
      <div class="title">{{ t("certd.siteMonitorSettings") }}</div>
 | 
			
		||||
      <div class="title">{{ t("certd.monitor.setting.siteMonitorSettings") }}</div>
 | 
			
		||||
    </template>
 | 
			
		||||
    <div class="user-settings-form settings-form">
 | 
			
		||||
      <a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off">
 | 
			
		||||
        <a-form-item :label="t('certd.notificationChannel')" :name="['notificationId']">
 | 
			
		||||
        <a-form-item :label="t('certd.monitor.setting.notificationChannel')" :name="['notificationId']">
 | 
			
		||||
          <div class="flex">
 | 
			
		||||
            <NotificationSelector v-model="formState.notificationId" />
 | 
			
		||||
          </div>
 | 
			
		||||
          <div class="helper">{{ t("certd.setNotificationChannel") }}</div>
 | 
			
		||||
          <div class="helper">{{ t("certd.monitor.setting.setNotificationChannel") }}</div>
 | 
			
		||||
        </a-form-item>
 | 
			
		||||
        <a-form-item :label="t('certd.retryTimes')" :name="['retryTimes']">
 | 
			
		||||
        <a-form-item :label="t('certd.monitor.setting.retryTimes')" :name="['retryTimes']">
 | 
			
		||||
          <div class="flex">
 | 
			
		||||
            <a-input-number v-model:value="formState.retryTimes" />
 | 
			
		||||
          </div>
 | 
			
		||||
          <div class="helper">{{ t("certd.monitorRetryTimes") }}</div>
 | 
			
		||||
          <div class="helper">{{ t("certd.monitor.setting.monitorRetryTimes") }}</div>
 | 
			
		||||
        </a-form-item>
 | 
			
		||||
        <a-form-item :label="t('certd.monitorCronSetting')" :name="['cron']">
 | 
			
		||||
        <a-form-item :label="t('certd.monitor.setting.dnsServer')" :name="['dnsServer']">
 | 
			
		||||
          <div class="flex">
 | 
			
		||||
            <a-select v-model:value="formState.dnsServer" mode="tags" :open="false" />
 | 
			
		||||
          </div>
 | 
			
		||||
          <div class="helper">{{ t("certd.monitor.setting.dnsServerHelper") }}</div>
 | 
			
		||||
        </a-form-item>
 | 
			
		||||
        <a-form-item :label="t('certd.monitor.setting.monitorCronSetting')" :name="['cron']">
 | 
			
		||||
          <div class="flex flex-baseline">
 | 
			
		||||
            <cron-editor v-model="formState.cron" :disabled="!settingsStore.isPlus" :allow-every-min="userStore.isAdmin" />
 | 
			
		||||
            <vip-button class="ml-5" mode="button"></vip-button>
 | 
			
		||||
          </div>
 | 
			
		||||
          <div class="helper">{{ t("certd.cronTrigger") }}</div>
 | 
			
		||||
          <div class="helper">{{ t("certd.monitor.setting.cronTrigger") }}</div>
 | 
			
		||||
        </a-form-item>
 | 
			
		||||
        <a-form-item label=" " :colon="false" :wrapper-col="{ span: 16 }">
 | 
			
		||||
          <loading-button type="primary" html-type="button" :click="doSave">{{ t("certd.save") }}</loading-button>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -100,7 +100,7 @@
 | 
			
		|||
              <fs-form-item v-if="item.show !== false" v-model="currentStep.input[key]" :item="item" :get-context-fn="getScopeFunc" />
 | 
			
		||||
            </template>
 | 
			
		||||
 | 
			
		||||
            <fs-form-item v-if="currentPlugin.showRunStrategy" v-model="currentStep.strategy.runStrategy" :item="runStrategyProps" :get-context-fn="getScopeFunc" />
 | 
			
		||||
            <fs-form-item v-if="settingStore.sysPublic.showRunStrategy || currentPlugin.showRunStrategy" v-model="currentStep.strategy.runStrategy" :item="runStrategyProps" :get-context-fn="getScopeFunc" />
 | 
			
		||||
          </a-form>
 | 
			
		||||
        </div>
 | 
			
		||||
        <template #footer>
 | 
			
		||||
| 
						 | 
				
			
			@ -143,6 +143,8 @@ function transformDesc(desc: string = "") {
 | 
			
		|||
  return utils.transformLink(desc);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const settingStore = useSettingStore();
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *  step drawer
 | 
			
		||||
 * @returns
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,6 +37,11 @@
 | 
			
		|||
        <div class="helper">{{ t("certd.dualStackNetworkHelper") }}</div>
 | 
			
		||||
      </a-form-item>
 | 
			
		||||
 | 
			
		||||
      <a-form-item :label="t('certd.sys.setting.showRunStrategy')" :name="['public', 'showRunStrategy']">
 | 
			
		||||
        <a-switch v-model:checked="formState.public.showRunStrategy" />
 | 
			
		||||
        <div class="helper">{{ t("certd.sys.setting.showRunStrategyHelper") }}</div>
 | 
			
		||||
      </a-form-item>
 | 
			
		||||
 | 
			
		||||
      <a-form-item :label="t('certd.enableCommonCnameService')" :name="['private', 'commonCnameEnabled']">
 | 
			
		||||
        <a-switch v-model:checked="formState.private.commonCnameEnabled" />
 | 
			
		||||
        <div class="helper" v-html="t('certd.commonCnameHelper')"></div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -82,6 +82,7 @@
 | 
			
		|||
    "cross-env": "^7.0.3",
 | 
			
		||||
    "crypto-js": "^4.2.0",
 | 
			
		||||
    "dayjs": "^1.11.7",
 | 
			
		||||
    "dns2": "^2.1.0",
 | 
			
		||||
    "form-data": "^4.0.0",
 | 
			
		||||
    "glob": "^11.0.0",
 | 
			
		||||
    "https-proxy-agent": "^7.0.5",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,7 @@ import { logger, safePromise, utils } from "@certd/basic";
 | 
			
		|||
import { merge } from "lodash-es";
 | 
			
		||||
import https from "https";
 | 
			
		||||
import { PeerCertificate } from "tls";
 | 
			
		||||
import { TCPClient } from "dns2";
 | 
			
		||||
 | 
			
		||||
export type SiteTestReq = {
 | 
			
		||||
  host: string; // 只用域名部分
 | 
			
		||||
| 
						 | 
				
			
			@ -9,6 +10,8 @@ export type SiteTestReq = {
 | 
			
		|||
  method?: string;
 | 
			
		||||
  retryTimes?: number;
 | 
			
		||||
  ipAddress?: string;
 | 
			
		||||
 | 
			
		||||
  dnsServer?: string[];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export type SiteTestRes = {
 | 
			
		||||
| 
						 | 
				
			
			@ -18,7 +21,7 @@ export type SiteTestRes = {
 | 
			
		|||
export class SiteTester {
 | 
			
		||||
  async test(req: SiteTestReq): Promise<SiteTestRes> {
 | 
			
		||||
    logger.info("测试站点:", JSON.stringify(req));
 | 
			
		||||
    const maxRetryTimes = req.retryTimes==null ? 3 : req.retryTimes;
 | 
			
		||||
    const maxRetryTimes = req.retryTimes == null ? 3 : req.retryTimes;
 | 
			
		||||
    let tryCount = 0;
 | 
			
		||||
    let result: SiteTestRes = {};
 | 
			
		||||
    while (true) {
 | 
			
		||||
| 
						 | 
				
			
			@ -52,14 +55,42 @@ export class SiteTester {
 | 
			
		|||
    if (req.ipAddress) {
 | 
			
		||||
      //使用固定的ip
 | 
			
		||||
      const ipAddress = req.ipAddress;
 | 
			
		||||
      options.headers={
 | 
			
		||||
      options.headers = {
 | 
			
		||||
        host: options.host,
 | 
			
		||||
        //sni
 | 
			
		||||
        servername: options.host
 | 
			
		||||
      }
 | 
			
		||||
      };
 | 
			
		||||
      options.host = ipAddress;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let dnsClients = [];
 | 
			
		||||
    if (req.dnsServer && req.dnsServer.length > 0) {
 | 
			
		||||
      for (let dns of req.dnsServer) {
 | 
			
		||||
        const dnsClient = TCPClient({ dns });
 | 
			
		||||
        dnsClients.push(dnsClient);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // async function customLookup(hostname, options, callback) {
 | 
			
		||||
    //   for (let client of dnsClients) {
 | 
			
		||||
    //     try {
 | 
			
		||||
    //       const result = await client.resolve(hostname, options);
 | 
			
		||||
    //       return callback(null, result);
 | 
			
		||||
    //     } catch (e) {
 | 
			
		||||
    //       this.logger.error(e);
 | 
			
		||||
    //     }
 | 
			
		||||
    //   }
 | 
			
		||||
    //   try {
 | 
			
		||||
    //     // 使用自定义DNS解析
 | 
			
		||||
    //     const response = await dnsClients
 | 
			
		||||
    //     const address = response.answers[0].address;
 | 
			
		||||
    //     callback(null, address, 4);
 | 
			
		||||
    //   } catch (err) {
 | 
			
		||||
    //     // 解析失败时回退到系统DNS
 | 
			
		||||
    //     require('dns').lookup(hostname, options, callback);
 | 
			
		||||
    //   }
 | 
			
		||||
    // }
 | 
			
		||||
 | 
			
		||||
    options.agent = new https.Agent({ keepAlive: false });
 | 
			
		||||
 | 
			
		||||
    // 创建 HTTPS 请求
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1599,6 +1599,9 @@ importers:
 | 
			
		|||
      dayjs:
 | 
			
		||||
        specifier: ^1.11.7
 | 
			
		||||
        version: 1.11.13
 | 
			
		||||
      dns2:
 | 
			
		||||
        specifier: ^2.1.0
 | 
			
		||||
        version: 2.1.0
 | 
			
		||||
      form-data:
 | 
			
		||||
        specifier: ^4.0.0
 | 
			
		||||
        version: 4.0.2
 | 
			
		||||
| 
						 | 
				
			
			@ -7135,6 +7138,9 @@ packages:
 | 
			
		|||
    resolution: {integrity: sha512-SIEkjrG7cZ9GWZQYk/mH+mWtcRPly/3ibVuXO/tP/MFoWz6KiRK77tSMq6YQBPl7RljPtXPQ/JhxbNuCdi1bNw==}
 | 
			
		||||
    engines: {node: '>=12'}
 | 
			
		||||
 | 
			
		||||
  dns2@2.1.0:
 | 
			
		||||
    resolution: {integrity: sha512-m27K11aQalRbmUs7RLaz6aPyceLjAoqjPRNTdE7qUouQpl+PC8Bi67O+i9SuJUPbQC8dxFrczAxfmTPuTKHNkw==}
 | 
			
		||||
 | 
			
		||||
  doctrine@2.1.0:
 | 
			
		||||
    resolution: {integrity: sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==}
 | 
			
		||||
    engines: {node: '>=0.10.0'}
 | 
			
		||||
| 
						 | 
				
			
			@ -21024,6 +21030,8 @@ snapshots:
 | 
			
		|||
      test-value: 3.0.0
 | 
			
		||||
      walk-back: 5.1.1
 | 
			
		||||
 | 
			
		||||
  dns2@2.1.0: {}
 | 
			
		||||
 | 
			
		||||
  doctrine@2.1.0:
 | 
			
		||||
    dependencies:
 | 
			
		||||
      esutils: 2.0.3
 | 
			
		||||
| 
						 | 
				
			
			@ -21506,13 +21514,13 @@ snapshots:
 | 
			
		|||
      resolve: 1.22.10
 | 
			
		||||
      semver: 6.3.1
 | 
			
		||||
 | 
			
		||||
  eslint-plugin-prettier@3.4.1(eslint-config-prettier@8.10.0(eslint@8.57.0))(eslint@7.32.0)(prettier@2.8.8):
 | 
			
		||||
  eslint-plugin-prettier@3.4.1(eslint-config-prettier@8.10.0(eslint@7.32.0))(eslint@7.32.0)(prettier@2.8.8):
 | 
			
		||||
    dependencies:
 | 
			
		||||
      eslint: 7.32.0
 | 
			
		||||
      prettier: 2.8.8
 | 
			
		||||
      prettier-linter-helpers: 1.0.0
 | 
			
		||||
    optionalDependencies:
 | 
			
		||||
      eslint-config-prettier: 8.10.0(eslint@8.57.0)
 | 
			
		||||
      eslint-config-prettier: 8.10.0(eslint@7.32.0)
 | 
			
		||||
 | 
			
		||||
  eslint-plugin-prettier@4.2.1(eslint-config-prettier@8.10.0(eslint@8.57.0))(eslint@8.57.0)(prettier@2.8.8):
 | 
			
		||||
    dependencies:
 | 
			
		||||
| 
						 | 
				
			
			@ -24220,7 +24228,7 @@ snapshots:
 | 
			
		|||
      eslint: 7.32.0
 | 
			
		||||
      eslint-config-prettier: 8.10.0(eslint@7.32.0)
 | 
			
		||||
      eslint-plugin-node: 11.1.0(eslint@7.32.0)
 | 
			
		||||
      eslint-plugin-prettier: 3.4.1(eslint-config-prettier@8.10.0(eslint@8.57.0))(eslint@7.32.0)(prettier@2.8.8)
 | 
			
		||||
      eslint-plugin-prettier: 3.4.1(eslint-config-prettier@8.10.0(eslint@7.32.0))(eslint@7.32.0)(prettier@2.8.8)
 | 
			
		||||
      execa: 5.1.1
 | 
			
		||||
      inquirer: 7.3.3
 | 
			
		||||
      json5: 2.2.3
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue