Skip to content

Commit

Permalink
feat(http): add option to skip SSL certificate verification (#801)
Browse files Browse the repository at this point in the history
  • Loading branch information
doraemonkeys authored Nov 12, 2024
1 parent 3384f51 commit 2523282
Show file tree
Hide file tree
Showing 19 changed files with 48 additions and 1 deletion.
4 changes: 4 additions & 0 deletions internal/protocol/http/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package http
import (
"bytes"
"context"
"crypto/tls"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -449,6 +450,9 @@ func (f *Fetcher) splitChunk() (chunks []*chunk) {
func (f *Fetcher) buildClient() *http.Client {
transport := &http.Transport{
Proxy: f.ctl.GetProxy(f.meta.Req.Proxy),
TLSClientConfig: &tls.Config{
InsecureSkipVerify: f.meta.Req.SkipVerifyCert,
},
}
// Cookie handle
jar, _ := cookiejar.New(nil)
Expand Down
2 changes: 2 additions & 0 deletions pkg/base/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type Request struct {
Labels map[string]string `json:"labels"`
// Proxy is special proxy config for request
Proxy *RequestProxy `json:"proxy"`
// SkipVerifyCert is the flag that skip verify cert
SkipVerifyCert bool `json:"skipVerifyCert"`
}

func (r *Request) Validate() error {
Expand Down
2 changes: 2 additions & 0 deletions ui/flutter/lib/api/model/request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ class Request {
Object? extra;
Map<String, String>? labels = {};
RequestProxy? proxy;
bool skipVerifyCert = false;

Request({
required this.url,
this.extra,
this.labels,
this.proxy,
this.skipVerifyCert = false,
});

factory Request.fromJson(Map<String, dynamic> json) =>
Expand Down
2 changes: 2 additions & 0 deletions ui/flutter/lib/api/model/request.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 24 additions & 1 deletion ui/flutter/lib/app/modules/create/views/create_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class CreateView extends GetView<CreateController> {

final _availableSchemes = ["http:", "https:", "magnet:"];

final _skipVerifyCertController = false.obs;

CreateView({Key? key}) : super(key: key);

@override
Expand Down Expand Up @@ -454,6 +456,22 @@ class CreateView extends GetView<CreateController> {
decoration: const InputDecoration(
labelText: 'Referer',
)),
Padding(
padding:
const EdgeInsets.only(top: 10),
child: CompactCheckbox(
label: 'skipVerifyCert'.tr,
value:
_skipVerifyCertController.value,
onChanged: (bool? value) {
_skipVerifyCertController.value =
value ?? false;
},
textStyle: const TextStyle(
color: Colors.grey,
),
),
),
],
),
Column(
Expand Down Expand Up @@ -578,7 +596,11 @@ class CreateView extends GetView<CreateController> {
await Future.wait(urls.map((url) {
return createTask(CreateTask(
req: Request(
url: url, extra: parseReqExtra(url), proxy: parseProxy()),
url: url,
extra: parseReqExtra(url),
proxy: parseProxy(),
skipVerifyCert: _skipVerifyCertController.value,
),
opt: Options(
name: isMultiLine ? "" : _renameController.text,
path: _pathController.text,
Expand All @@ -592,6 +614,7 @@ class CreateView extends GetView<CreateController> {
url: submitUrl,
extra: parseReqExtra(_urlController.text),
proxy: parseProxy(),
skipVerifyCert: _skipVerifyCertController.value,
));
await _showResolveDialog(rr);
}
Expand Down
1 change: 1 addition & 0 deletions ui/flutter/lib/i18n/langs/en_us.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,6 @@ const enUS = {
'taskName': 'Task Name',
'taskUrl': 'Task URL',
'downloadPath': 'Download Path',
'skipVerifyCert': 'Skip Certificate Verification',
},
};
1 change: 1 addition & 0 deletions ui/flutter/lib/i18n/langs/es_es.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,6 @@ const esES = {
'taskName': 'Nombre de la Tarea',
'taskUrl': 'URL de la Tarea',
'downloadPath': 'Ruta de Descarga',
'skipVerifyCert': 'Omitir Verificación de Certificado',
},
};
1 change: 1 addition & 0 deletions ui/flutter/lib/i18n/langs/fa_ir.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@ const faIR = {
'thanksDesc':
'از تمامی افرادی که در ساخت و توسعه‌ی جامعه‌ی Gopeed مشارکت کرده‌اند، سپاسگزاری می‌کنیم!',
'browserExtension': 'فایل های دانلود شده را نگه دارد',
'skipVerifyCert': 'رد کردن تأیید گواهینامه',
}
};
1 change: 1 addition & 0 deletions ui/flutter/lib/i18n/langs/fr_fr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,6 @@ const frFR = {
'thanksDesc': 'Merci à tous les contributeurs qui ont aidé à construire et développer la communauté Gopeed !',
'browserExtension': 'Extension du navigateur',
'launchAtStartup': 'Lancer au démarrage',
'skipVerifyCert': 'Bypass Verifikasi Sertifikat',
},
};
1 change: 1 addition & 0 deletions ui/flutter/lib/i18n/langs/id_id.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,6 @@ const idID = {
'taskName': 'Nama Tugas',
'taskUrl': 'URL Tugas',
'downloadPath': 'Direktori Unduhan',
'skipVerifyCert': 'Lupakan verifikasi sertifikat',
},
};
1 change: 1 addition & 0 deletions ui/flutter/lib/i18n/langs/it_it.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,6 @@ const itIT = {
'Grazie a tutti i contributori che hanno contribuito a costruire e sviluppare la comunità Gopeed!',
'browserExtension': 'Estensione del browser',
'launchAtStartup': "Lancia all'avvio",
'skipVerifyCert': 'Salta la verifica del certificato',
},
};
1 change: 1 addition & 0 deletions ui/flutter/lib/i18n/langs/ja_jp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ const jaJP = {
'thanks': '感謝',
'thanksDesc': 'Gopeedコミュニティの建設に協力してくださったすべての貢献者の方々に感謝します!',
'browserExtension': 'ブラウザ拡張機能',
'skipVerifyCert': '証明書の検証をスキップ',
}
};
1 change: 1 addition & 0 deletions ui/flutter/lib/i18n/langs/pl_pl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@ const plPL = {
'Dziękuję wszystkim za pomoc przy powstawaniu aplikacji Gopeed!',
'browserExtension': 'Wtyczka dla przeglądarki',
'launchAtStartup': 'Uruchom na starcie',
'skipVerifyCert': 'Pomiń weryfikację certyfikatu',
},
};
1 change: 1 addition & 0 deletions ui/flutter/lib/i18n/langs/ru_ru.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@ const ruRU = {
'thanksDesc':
'Благодарим всех участников за их вклад в строительство и развитие сообщества Gopeed!',
'browserExtension': 'Расширение браузера',
'skipVerifyCert': 'Пропустить проверку сертификата',
}
};
1 change: 1 addition & 0 deletions ui/flutter/lib/i18n/langs/ta_ta.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,6 @@ const taTA = {
'Gopeed சமூகத்தை உருவாக்கவும் மற்றும் மேம்படுத்த உதவிய அனைத்து பங்களிப்பாளர்களுக்கும் நன்றி!',
'browserExtension': 'உலாவி நீட்டிப்பு',
'launchAtStartup': 'தொடக்கத்தின் போது இயங்கு',
'skipVerifyCert': 'திருத்தி சான்று சரிபார்க்கவும்',
},
};
1 change: 1 addition & 0 deletions ui/flutter/lib/i18n/langs/tr_tr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,6 @@ const trTR = {
'taskName': 'Görev adı',
'taskUrl': 'Görev URL',
'downloadPath': 'İndirme yolu',
'skipVerifyCert': 'Sertifika doğrulamasını atla',
},
};
1 change: 1 addition & 0 deletions ui/flutter/lib/i18n/langs/vi_vn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,6 @@ const viVN = {
'thanksDesc':
'Cảm ơn tất cả những người đóng góp đã giúp xây dựng và phát triển cộng đồng Gopeed!',
'browserExtension': 'Tiện ích mở rộng trình duyệt',
'skipVerifyCert': 'Bỏ qua xác thực chứng chỉ',
},
};
1 change: 1 addition & 0 deletions ui/flutter/lib/i18n/langs/zh_cn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,6 @@ const zhCN = {
'taskName': '任务名称',
'taskUrl': '任务链接',
'downloadPath': '下载路径',
'skipVerifyCert': '跳过证书验证',
}
};
1 change: 1 addition & 0 deletions ui/flutter/lib/i18n/langs/zh_tw.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,6 @@ const zhTW = {
'taskName': '任務名稱',
'taskUrl': '任務連結',
'downloadPath': '下載路徑',
'skipVerifyCert': '跳過憑證驗證',
}
};

0 comments on commit 2523282

Please sign in to comment.