From d5a7a5d655b04676bc1198fb539ef437e54085f3 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Thu, 2 Nov 2023 00:20:48 +0800 Subject: [PATCH] feat: add ignore tls error and make sure get tls info every times --- .../components/modals/monitor/provider/http.tsx | 9 ++++++++- src/server/model/monitor/provider/http.ts | 12 +++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/client/components/modals/monitor/provider/http.tsx b/src/client/components/modals/monitor/provider/http.tsx index 3bbec75..34e7889 100644 --- a/src/client/components/modals/monitor/provider/http.tsx +++ b/src/client/components/modals/monitor/provider/http.tsx @@ -1,4 +1,4 @@ -import { Form, Input, Select } from 'antd'; +import { Form, Input, Select, Switch } from 'antd'; import React from 'react'; import { MonitorOverviewComponent, MonitorProvider } from './types'; import { trpc } from '../../../../api/trpc'; @@ -32,6 +32,13 @@ const MonitorHttp: React.FC = React.memo(() => { OPTIONS + + + = { run: async (monitor) => { if (typeof monitor.payload !== 'object') { @@ -24,6 +26,7 @@ export const http: MonitorProvider<{ contentType, bodyValue, maxRedirects, + ignoreTLS, } = monitor.payload; const config: AxiosRequestConfig = { @@ -45,9 +48,16 @@ export const http: MonitorProvider<{ config.data = bodyValue; } + const httpsAgentOptions = { + maxCachedSessions: 0, // Use Custom agent to disable session reuse (https://github.com/nodejs/node/issues/3940) + rejectUnauthorized: !ignoreTLS, + }; + + config.httpsAgent = new https.Agent(httpsAgentOptions); + try { const startTime = dayjs(); - const res = await axios(config); + const res = await axios({ ...config }); const diff = dayjs().diff(startTime, 'ms');