Browse Source

fix: 修改防火墙操作超时时间 (#2268)

pull/2270/head
ssongliu 1 year ago committed by GitHub
parent
commit
e991bbe799
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      backend/app/service/website.go
  2. 3
      frontend/src/api/modules/app.ts
  3. 27
      frontend/src/api/modules/container.ts
  4. 8
      frontend/src/api/modules/cronjob.ts
  5. 7
      frontend/src/api/modules/database.ts
  6. 5
      frontend/src/api/modules/files.ts
  7. 7
      frontend/src/api/modules/host-tool.ts
  8. 15
      frontend/src/api/modules/host.ts
  9. 9
      frontend/src/api/modules/setting.ts
  10. 5
      frontend/src/api/modules/website.ts
  11. 8
      frontend/src/enums/http-enum.ts

9
backend/app/service/website.go

@ -9,9 +9,6 @@ import (
"encoding/pem"
"errors"
"fmt"
"github.com/1Panel-dev/1Panel/backend/i18n"
"github.com/1Panel-dev/1Panel/backend/utils/common"
"github.com/spf13/afero"
"os"
"path"
"reflect"
@ -21,6 +18,10 @@ import (
"syscall"
"time"
"github.com/1Panel-dev/1Panel/backend/i18n"
"github.com/1Panel-dev/1Panel/backend/utils/common"
"github.com/spf13/afero"
"github.com/1Panel-dev/1Panel/backend/utils/compose"
"github.com/1Panel-dev/1Panel/backend/utils/env"
@ -816,7 +817,7 @@ func (w WebsiteService) PreInstallCheck(req request.WebsiteInstallCheckReq) ([]r
checkIds = append(req.InstallIds, appInstall.ID)
}
for _, id := range checkIds {
if err := syncById(id); err != nil {
if err := syncByID(id); err != nil {
return nil, err
}
}

3
frontend/src/api/modules/app.ts

@ -1,6 +1,7 @@
import http from '@/api';
import { ResPage } from '../interface';
import { App } from '../interface/app';
import { TimeoutEnum } from '@/enums/http-enum';
export const SyncApp = () => {
return http.post<any>('apps/sync', {});
@ -67,7 +68,7 @@ export const GetAppInstalled = (search: App.AppInstalledSearch) => {
};
export const InstalledOp = (op: App.AppInstalledOp) => {
return http.post<any>('apps/installed/op', op, 40000);
return http.post<any>('apps/installed/op', op, TimeoutEnum.T_40S);
};
export const SyncInstalledApp = () => {

27
frontend/src/api/modules/container.ts

@ -1,9 +1,10 @@
import http from '@/api';
import { ResPage, SearchWithPage } from '../interface';
import { Container } from '../interface/container';
import { TimeoutEnum } from '@/enums/http-enum';
export const searchContainer = (params: Container.ContainerSearch) => {
return http.post<ResPage<Container.ContainerInfo>>(`/containers/search`, params, 400000);
return http.post<ResPage<Container.ContainerInfo>>(`/containers/search`, params, TimeoutEnum.T_40S);
};
export const listContainer = () => {
return http.post<Array<string>>(`/containers/list`, {});
@ -12,13 +13,13 @@ export const loadResourceLimit = () => {
return http.get<Container.ResourceLimit>(`/containers/limit`);
};
export const createContainer = (params: Container.ContainerHelper) => {
return http.post(`/containers`, params, 3000000);
return http.post(`/containers`, params, TimeoutEnum.T_10M);
};
export const updateContainer = (params: Container.ContainerHelper) => {
return http.post(`/containers/update`, params, 3000000);
return http.post(`/containers/update`, params, TimeoutEnum.T_10M);
};
export const upgradeContainer = (name: string, image: string, forcePull: boolean) => {
return http.post(`/containers/upgrade`, { name: name, image: image, forcePull: forcePull }, 3000000);
return http.post(`/containers/upgrade`, { name: name, image: image, forcePull: forcePull }, TimeoutEnum.T_10M);
};
export const loadContainerInfo = (name: string) => {
return http.post<Container.ContainerHelper>(`/containers/info`, { name: name });
@ -62,10 +63,10 @@ export const imagePush = (params: Container.ImagePush) => {
return http.post<string>(`/containers/image/push`, params);
};
export const imageLoad = (params: Container.ImageLoad) => {
return http.post(`/containers/image/load`, params, 1200000);
return http.post(`/containers/image/load`, params, TimeoutEnum.T_10M);
};
export const imageSave = (params: Container.ImageSave) => {
return http.post(`/containers/image/save`, params, 1200000);
return http.post(`/containers/image/save`, params, TimeoutEnum.T_10M);
};
export const imageTag = (params: Container.ImageTag) => {
return http.post(`/containers/image/tag`, params);
@ -104,7 +105,7 @@ export const createVolume = (params: Container.VolumeCreate) => {
// repo
export const checkRepoStatus = (id: number) => {
return http.post(`/containers/repo/status`, { id: id }, 40000);
return http.post(`/containers/repo/status`, { id: id }, TimeoutEnum.T_40S);
};
export const searchImageRepo = (params: SearchWithPage) => {
return http.post<ResPage<Container.RepoInfo>>(`/containers/repo/search`, params);
@ -113,13 +114,13 @@ export const listImageRepo = () => {
return http.get<Container.RepoOptions>(`/containers/repo`);
};
export const createImageRepo = (params: Container.RepoCreate) => {
return http.post(`/containers/repo`, params, 40000);
return http.post(`/containers/repo`, params, TimeoutEnum.T_40S);
};
export const updateImageRepo = (params: Container.RepoUpdate) => {
return http.post(`/containers/repo/update`, params, 40000);
return http.post(`/containers/repo/update`, params, TimeoutEnum.T_40S);
};
export const deleteImageRepo = (params: Container.RepoDelete) => {
return http.post(`/containers/repo/del`, params, 40000);
return http.post(`/containers/repo/del`, params, TimeoutEnum.T_40S);
};
// composeTemplate
@ -153,7 +154,7 @@ export const composeOperator = (params: Container.ComposeOpration) => {
return http.post(`/containers/compose/operate`, params);
};
export const composeUpdate = (params: Container.ComposeUpdate) => {
return http.post(`/containers/compose/update`, params, 600000);
return http.post(`/containers/compose/update`, params, TimeoutEnum.T_10M);
};
// docker
@ -170,10 +171,10 @@ export const loadDockerStatus = () => {
return http.get<string>(`/containers/docker/status`);
};
export const updateDaemonJson = (key: string, value: string) => {
return http.post(`/containers/daemonjson/update`, { key: key, value: value }, 60000);
return http.post(`/containers/daemonjson/update`, { key: key, value: value }, TimeoutEnum.T_60S);
};
export const updateLogOption = (maxSize: string, maxFile: string) => {
return http.post(`/containers/logoption/update`, { logMaxSize: maxSize, logMaxFile: maxFile }, 60000);
return http.post(`/containers/logoption/update`, { logMaxSize: maxSize, logMaxFile: maxFile }, TimeoutEnum.T_60S);
};
export const updateDaemonJsonByfile = (params: Container.DaemonJsonUpdateByFile) => {
return http.post(`/containers/daemonjson/update/byfile`, params);

8
frontend/src/api/modules/cronjob.ts

@ -1,6 +1,7 @@
import http from '@/api';
import { ResPage, SearchWithPage } from '../interface';
import { Cronjob } from '../interface/cronjob';
import { TimeoutEnum } from '@/enums/http-enum';
export const getCronjobPage = (params: SearchWithPage) => {
return http.post<ResPage<Cronjob.CronjobInfo>>(`/cronjobs/search`, params);
@ -39,10 +40,13 @@ export const updateStatus = (params: Cronjob.UpdateStatus) => {
};
export const downloadRecordCheck = (params: Cronjob.Download) => {
return http.post<string>(`cronjobs/download`, params, 40000);
return http.post<string>(`cronjobs/download`, params, TimeoutEnum.T_40S);
};
export const downloadRecord = (params: Cronjob.Download) => {
return http.download<BlobPart>(`cronjobs/download`, params, { responseType: 'blob', timeout: 40000 });
return http.download<BlobPart>(`cronjobs/download`, params, {
responseType: 'blob',
timeout: TimeoutEnum.T_40S,
});
};
export const handleOnce = (id: number) => {

7
frontend/src/api/modules/database.ts

@ -3,6 +3,7 @@ import { deepCopy } from '@/utils/util';
import { Base64 } from 'js-base64';
import { ResPage, DescriptionUpdate } from '../interface';
import { Database } from '../interface/database';
import { TimeoutEnum } from '@/enums/http-enum';
export const searchMysqlDBs = (params: Database.SearchDBWithPage) => {
return http.post<ResPage<Database.MysqlDBInfo>>(`/databases/search`, params);
@ -101,13 +102,13 @@ export const listDatabases = (type: string) => {
return http.get<Array<Database.DatabaseOption>>(`/databases/db/list/${type}`);
};
export const checkDatabase = (params: Database.DatabaseCreate) => {
return http.post<boolean>(`/databases/db/check`, params, 40000);
return http.post<boolean>(`/databases/db/check`, params, TimeoutEnum.T_40S);
};
export const addDatabase = (params: Database.DatabaseCreate) => {
return http.post(`/databases/db`, params, 40000);
return http.post(`/databases/db`, params, TimeoutEnum.T_40S);
};
export const editDatabase = (params: Database.DatabaseUpdate) => {
return http.post(`/databases/db/update`, params, 40000);
return http.post(`/databases/db/update`, params, TimeoutEnum.T_40S);
};
export const deleteDatabase = (id: number) => {
return http.post(`/databases/db/del`, { id: id });

5
frontend/src/api/modules/files.ts

@ -2,9 +2,10 @@ import { File } from '@/api/interface/file';
import http from '@/api';
import { AxiosRequestConfig } from 'axios';
import { ResPage } from '../interface';
import { TimeoutEnum } from '@/enums/http-enum';
export const GetFilesList = (params: File.ReqFile) => {
return http.post<File.File>('files/search', params, 200000);
return http.post<File.File>('files/search', params, TimeoutEnum.T_5M);
};
export const GetUploadList = (params: File.SearchUploadInfo) => {
@ -76,7 +77,7 @@ export const MoveFile = (params: File.FileMove) => {
};
export const DownloadFile = (params: File.FileDownload) => {
return http.download<BlobPart>('files/download', params, { responseType: 'blob', timeout: 20000 });
return http.download<BlobPart>('files/download', params, { responseType: 'blob', timeout: TimeoutEnum.T_40S });
};
export const ComputeDirSize = (params: File.DirSizeReq) => {

7
frontend/src/api/modules/host-tool.ts

@ -1,5 +1,6 @@
import http from '@/api';
import { HostTool } from '../interface/host-tool';
import { TimeoutEnum } from '@/enums/http-enum';
export const GetSupervisorStatus = () => {
return http.post<HostTool.HostTool>(`/hosts/tool`, { type: 'supervisord', operate: 'status' });
@ -26,11 +27,11 @@ export const CreateSupervisorProcess = (req: HostTool.SupersivorProcess) => {
};
export const OperateSupervisorProcess = (req: HostTool.ProcessReq) => {
return http.post<any>(`/hosts/tool/supervisor/process`, req, 100000);
return http.post<any>(`/hosts/tool/supervisor/process`, req, TimeoutEnum.T_60S);
};
export const LoadProcessStatus = () => {
return http.post<Array<HostTool.ProcessStatus>>(`/hosts/tool/supervisor/process/load`, {}, 40000);
return http.post<Array<HostTool.ProcessStatus>>(`/hosts/tool/supervisor/process/load`, {}, TimeoutEnum.T_40S);
};
export const GetSupervisorProcess = () => {
@ -38,5 +39,5 @@ export const GetSupervisorProcess = () => {
};
export const OperateSupervisorProcessFile = (req: HostTool.ProcessFileReq) => {
return http.post<any>(`/hosts/tool/supervisor/process/file`, req, 100000);
return http.post<any>(`/hosts/tool/supervisor/process/file`, req, TimeoutEnum.T_60S);
};

15
frontend/src/api/modules/host.ts

@ -4,6 +4,7 @@ import { Command } from '../interface/command';
import { Host } from '../interface/host';
import { Base64 } from 'js-base64';
import { deepCopy } from '@/utils/util';
import { TimeoutEnum } from '@/enums/http-enum';
export const searchHosts = (params: Host.SearchWithPage) => {
return http.post<ResPage<Host.Host>>(`/hosts/search`, params);
@ -73,28 +74,28 @@ export const loadFireBaseInfo = () => {
return http.get<Host.FirewallBase>(`/hosts/firewall/base`);
};
export const searchFireRule = (params: Host.RuleSearch) => {
return http.post<ResPage<Host.RuleInfo>>(`/hosts/firewall/search`, params);
return http.post<ResPage<Host.RuleInfo>>(`/hosts/firewall/search`, params, TimeoutEnum.T_40S);
};
export const operateFire = (operation: string) => {
return http.post(`/hosts/firewall/operate`, { operation: operation }, 40000);
return http.post(`/hosts/firewall/operate`, { operation: operation }, TimeoutEnum.T_40S);
};
export const operatePortRule = (params: Host.RulePort) => {
return http.post<Host.RulePort>(`/hosts/firewall/port`, params);
return http.post<Host.RulePort>(`/hosts/firewall/port`, params, TimeoutEnum.T_40S);
};
export const operateIPRule = (params: Host.RuleIP) => {
return http.post<Host.RuleIP>(`/hosts/firewall/ip`, params);
return http.post<Host.RuleIP>(`/hosts/firewall/ip`, params, TimeoutEnum.T_40S);
};
export const updatePortRule = (params: Host.UpdatePortRule) => {
return http.post(`/hosts/firewall/update/port`, params);
return http.post(`/hosts/firewall/update/port`, params, TimeoutEnum.T_40S);
};
export const updateAddrRule = (params: Host.UpdateAddrRule) => {
return http.post(`/hosts/firewall/update/addr`, params);
return http.post(`/hosts/firewall/update/addr`, params, TimeoutEnum.T_40S);
};
export const updateFirewallDescription = (params: Host.UpdateDescription) => {
return http.post(`/hosts/firewall/update/description`, params);
};
export const batchOperateRule = (params: Host.BatchRule) => {
return http.post(`/hosts/firewall/batch`, params);
return http.post(`/hosts/firewall/batch`, params, TimeoutEnum.T_60S);
};
// ssh

9
frontend/src/api/modules/setting.ts

@ -4,6 +4,7 @@ import { Base64 } from 'js-base64';
import { ResPage, SearchWithPage, DescriptionUpdate } from '../interface';
import { Backup } from '../interface/backup';
import { Setting } from '../interface/setting';
import { TimeoutEnum } from '@/enums/http-enum';
export const getSettingInfo = () => {
return http.post<Setting.SettingInfo>(`/settings/search`);
@ -67,16 +68,16 @@ export const loadBaseDir = () => {
// backup
export const handleBackup = (params: Backup.Backup) => {
return http.post(`/settings/backup/backup`, params, 3600000);
return http.post(`/settings/backup/backup`, params, TimeoutEnum.T_1H);
};
export const handleRecover = (params: Backup.Recover) => {
return http.post(`/settings/backup/recover`, params, 86400000);
return http.post(`/settings/backup/recover`, params, TimeoutEnum.T_1D);
};
export const handleRecoverByUpload = (params: Backup.Recover) => {
return http.post(`/settings/backup/recover/byupload`, params, 86400000);
return http.post(`/settings/backup/recover/byupload`, params, TimeoutEnum.T_1D);
};
export const downloadBackupRecord = (params: Backup.RecordDownload) => {
return http.post<string>(`/settings/backup/record/download`, params, 600000);
return http.post<string>(`/settings/backup/record/download`, params, TimeoutEnum.T_10M);
};
export const deleteBackupRecord = (params: { ids: number[] }) => {
return http.post(`/settings/backup/record/del`, params);

5
frontend/src/api/modules/website.ts

@ -2,6 +2,7 @@ import http from '@/api';
import { ReqPage, ResPage } from '../interface';
import { Website } from '../interface/website';
import { File } from '../interface/file';
import { TimeoutEnum } from '@/enums/http-enum';
export const SearchWebsites = (req: Website.WebSiteSearch) => {
return http.post<ResPage<Website.WebsiteDTO>>(`/websites/search`, req);
@ -100,7 +101,7 @@ export const ListSSL = (req: Website.SSLReq) => {
};
export const CreateSSL = (req: Website.SSLCreate) => {
return http.post<Website.SSLCreate>(`/websites/ssl`, req, 100000);
return http.post<Website.SSLCreate>(`/websites/ssl`, req, TimeoutEnum.T_60S);
};
export const DeleteSSL = (req: Website.DelReq) => {
@ -128,7 +129,7 @@ export const UpdateSSL = (req: Website.SSLUpdate) => {
};
export const GetDnsResolve = (req: Website.DNSResolveReq) => {
return http.post<Website.DNSResolve[]>(`/websites/ssl/resolve`, req, 60000);
return http.post<Website.DNSResolve[]>(`/websites/ssl/resolve`, req, TimeoutEnum.T_60S);
};
export const GetHTTPSConfig = (id: number) => {

8
frontend/src/enums/http-enum.ts

@ -13,6 +13,14 @@ export enum ResultEnum {
TYPE = 'success',
}
export enum TimeoutEnum {
T_40S = 40000,
T_60S = 60000,
T_5M = 300000,
T_10M = 600000,
T_1H = 3600000,
T_1D = 86400000,
}
/**
* @description请求方法
*/

Loading…
Cancel
Save