mirror of https://github.com/1Panel-dev/1Panel
feat: 远程下载文件增加是否忽略不可信证书选项 (#3324)
Refs **https://github.com/1Panel-dev/1Panel/issues/3307**pull/3335/head
parent
18cbcb7f13
commit
f91831a5ea
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -109,6 +109,7 @@ export namespace File {
|
|||
path: string;
|
||||
name: string;
|
||||
url: string;
|
||||
ignoreCertificate?: boolean;
|
||||
}
|
||||
|
||||
export interface FileWgetRes {
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -1051,6 +1051,9 @@ const message = {
|
|||
fileRecycleBinMsg: '已{0}回收站',
|
||||
wordWrap: '自動換行',
|
||||
deleteHelper2: '確定刪除所選檔案? 刪除操作不可回滾',
|
||||
ignoreCertificate: '忽略不可信證書',
|
||||
ignoreCertificateHelper:
|
||||
'下載時忽略不可信證書可能導致數據洩露或篡改。請謹慎使用此選項,僅在信任下載源的情況下啟用',
|
||||
},
|
||||
ssh: {
|
||||
autoStart: '開機自啟',
|
||||
|
|
|
@ -1052,6 +1052,9 @@ const message = {
|
|||
fileRecycleBinMsg: '已{0}回收站',
|
||||
wordWrap: '自动换行',
|
||||
deleteHelper2: '确定删除所选文件?删除操作不可回滚',
|
||||
ignoreCertificate: '忽略不可信证书',
|
||||
ignoreCertificateHelper:
|
||||
'下载时忽略不可信证书可能导致数据泄露或篡改。请谨慎使用此选项,仅在信任下载源的情况下启用',
|
||||
},
|
||||
ssh: {
|
||||
autoStart: '开机自启',
|
||||
|
|
|
@ -24,6 +24,12 @@
|
|||
<el-form-item :label="$t('commons.table.name')" prop="name">
|
||||
<el-input v-model="addForm.name"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-checkbox v-model="addForm.ignoreCertificate">
|
||||
{{ $t('file.ignoreCertificate') }}
|
||||
</el-checkbox>
|
||||
<span class="input-help">{{ $t('file.ignoreCertificateHelper') }}</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
@ -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 });
|
||||
|
|
Loading…
Reference in New Issue