Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(http): add option to skip SSL certificate verification #801

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

26 changes: 25 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,23 @@ class CreateView extends GetView<CreateController> {
decoration: const InputDecoration(
labelText: 'Referer',
)),
Padding(
padding:
const EdgeInsets.only(top: 10),
child: CompactCheckbox(
label:
'Skip Certificate Verification',
monkeyWie marked this conversation as resolved.
Show resolved Hide resolved
value:
_skipVerifyCertController.value,
onChanged: (bool? value) {
_skipVerifyCertController.value =
value ?? false;
},
textStyle: const TextStyle(
color: Colors.grey,
),
),
),
],
),
Column(
Expand Down Expand Up @@ -578,7 +597,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 +615,7 @@ class CreateView extends GetView<CreateController> {
url: submitUrl,
extra: parseReqExtra(_urlController.text),
proxy: parseProxy(),
skipVerifyCert: _skipVerifyCertController.value,
));
await _showResolveDialog(rr);
}
Expand Down
Loading