diff --git a/backend/app/dto/request/file.go b/backend/app/dto/request/file.go index d2c4e9b6b..abda45b67 100644 --- a/backend/app/dto/request/file.go +++ b/backend/app/dto/request/file.go @@ -77,9 +77,10 @@ type FilePathCheck struct { } type FileWget struct { - Url string `json:"url" validate:"required"` - Path string `json:"path" validate:"required"` - Name string `json:"name" validate:"required"` + Url string `json:"url" validate:"required"` + Path string `json:"path" validate:"required"` + Name string `json:"name" validate:"required"` + IgnoreCertificate bool `json:"ignoreCertificate"` } type FileMove struct { diff --git a/backend/app/service/file.go b/backend/app/service/file.go index dd9d792dd..ef342dc45 100644 --- a/backend/app/service/file.go +++ b/backend/app/service/file.go @@ -243,7 +243,7 @@ func (f *FileService) ChangeName(req request.FileRename) error { func (f *FileService) Wget(w request.FileWget) (string, error) { fo := files.NewFileOp() key := "file-wget-" + common.GetUuid() - return key, fo.DownloadFileWithProcess(w.Url, filepath.Join(w.Path, w.Name), key) + return key, fo.DownloadFileWithProcess(w.Url, filepath.Join(w.Path, w.Name), key, w.IgnoreCertificate) } func (f *FileService) MvFile(m request.FileMove) error { diff --git a/backend/utils/files/file_op.go b/backend/utils/files/file_op.go index 6860abc54..0a87d0af4 100644 --- a/backend/utils/files/file_op.go +++ b/backend/utils/files/file_op.go @@ -216,11 +216,12 @@ func (w *WriteCounter) SaveProcess() { } } -func (f FileOp) DownloadFileWithProcess(url, dst, key string) error { - client := &http.Client{ - Transport: &http.Transport{ +func (f FileOp) DownloadFileWithProcess(url, dst, key string, ignoreCertificate bool) error { + client := &http.Client{} + if ignoreCertificate { + client.Transport = &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, - }, + } } request, err := http.NewRequest("GET", url, nil) if err != nil { diff --git a/frontend/src/api/interface/file.ts b/frontend/src/api/interface/file.ts index f716f9228..79d7b0f21 100644 --- a/frontend/src/api/interface/file.ts +++ b/frontend/src/api/interface/file.ts @@ -109,6 +109,7 @@ export namespace File { path: string; name: string; url: string; + ignoreCertificate?: boolean; } export interface FileWgetRes { diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index c62d28c8e..1c7937fec 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -1105,6 +1105,9 @@ const message = { wordWrap: 'Automatically wrap', deleteHelper2: 'Are you sure you want to delete the selected file? The deletion operation cannot be rolled back', + ignoreCertificate: 'Ignore Certificate', + ignoreCertificateHelper: + 'Ignoring untrusted certificates during downloads may lead to data leakage or tampering. Please use this option with caution, only when trusting the download source.', }, ssh: { autoStart: 'Auto Start', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index cc60422a1..a710ece08 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -1051,6 +1051,9 @@ const message = { fileRecycleBinMsg: '已{0}回收站', wordWrap: '自動換行', deleteHelper2: '確定刪除所選檔案? 刪除操作不可回滾', + ignoreCertificate: '忽略不可信證書', + ignoreCertificateHelper: + '下載時忽略不可信證書可能導致數據洩露或篡改。請謹慎使用此選項,僅在信任下載源的情況下啟用', }, ssh: { autoStart: '開機自啟', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 557694a7b..70c5b3687 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -1052,6 +1052,9 @@ const message = { fileRecycleBinMsg: '已{0}回收站', wordWrap: '自动换行', deleteHelper2: '确定删除所选文件?删除操作不可回滚', + ignoreCertificate: '忽略不可信证书', + ignoreCertificateHelper: + '下载时忽略不可信证书可能导致数据泄露或篡改。请谨慎使用此选项,仅在信任下载源的情况下启用', }, ssh: { autoStart: '开机自启', diff --git a/frontend/src/views/host/file-management/wget/index.vue b/frontend/src/views/host/file-management/wget/index.vue index 1c03b6f0a..f92e3654b 100644 --- a/frontend/src/views/host/file-management/wget/index.vue +++ b/frontend/src/views/host/file-management/wget/index.vue @@ -24,6 +24,12 @@ + + + {{ $t('file.ignoreCertificate') }} + + {{ $t('file.ignoreCertificateHelper') }} + @@ -67,6 +73,7 @@ const addForm = reactive({ url: '', path: '', name: '', + ignoreCertificate: false, }); const em = defineEmits(['close']); @@ -111,6 +118,7 @@ const acceptParams = (props: WgetProps) => { addForm.path = props.path; open.value = true; submitData.value = false; + addForm.ignoreCertificate = false; }; defineExpose({ acceptParams });