mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-05-26 16:45:48 +08:00
手机版启动默认不再自动开启抓包
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:network_proxy/network/bin/server.dart';
|
||||
import 'package:network_proxy/network/bin/configuration.dart';
|
||||
import 'package:network_proxy/network/util/host_filter.dart';
|
||||
|
||||
|
||||
class FilterDialog extends StatefulWidget {
|
||||
final ProxyServer proxyServer;
|
||||
final Configuration configuration;
|
||||
|
||||
const FilterDialog({super.key, required this.proxyServer});
|
||||
const FilterDialog({super.key, required this.configuration});
|
||||
|
||||
@override
|
||||
State<FilterDialog> createState() => _FilterDialogState();
|
||||
@@ -49,7 +48,7 @@ class _FilterDialogState extends State<FilterDialog> {
|
||||
title: "白名单",
|
||||
subtitle: "只代理白名单中的域名, 白名单启用黑名单将会失效",
|
||||
hostList: HostFilter.whitelist,
|
||||
proxyServer: widget.proxyServer,
|
||||
configuration: widget.configuration,
|
||||
hostEnableNotifier: hostEnableNotifier)),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
@@ -58,7 +57,7 @@ class _FilterDialogState extends State<FilterDialog> {
|
||||
title: "黑名单",
|
||||
subtitle: "黑名单中的域名不会代理",
|
||||
hostList: HostFilter.blacklist,
|
||||
proxyServer: widget.proxyServer,
|
||||
configuration: widget.configuration,
|
||||
hostEnableNotifier: hostEnableNotifier)),
|
||||
],
|
||||
),
|
||||
@@ -70,7 +69,7 @@ class DomainFilter extends StatefulWidget {
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final HostList hostList;
|
||||
final ProxyServer proxyServer;
|
||||
final Configuration configuration;
|
||||
final ValueNotifier<bool> hostEnableNotifier;
|
||||
|
||||
const DomainFilter(
|
||||
@@ -79,7 +78,7 @@ class DomainFilter extends StatefulWidget {
|
||||
required this.subtitle,
|
||||
required this.hostList,
|
||||
required this.hostEnableNotifier,
|
||||
required this.proxyServer});
|
||||
required this.configuration});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -145,7 +144,7 @@ class _DomainFilterState extends State<DomainFilter> {
|
||||
@override
|
||||
void dispose() {
|
||||
if (changed) {
|
||||
widget.proxyServer.flushConfig();
|
||||
widget.configuration.flushConfig();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:network_proxy/network/bin/server.dart';
|
||||
import 'package:network_proxy/network/bin/configuration.dart';
|
||||
import 'package:network_proxy/network/util/request_rewrite.dart';
|
||||
|
||||
class RequestRewrite extends StatefulWidget {
|
||||
final ProxyServer proxyServer;
|
||||
final Configuration configuration;
|
||||
|
||||
const RequestRewrite({super.key, required this.proxyServer});
|
||||
const RequestRewrite({super.key, required this.configuration});
|
||||
|
||||
@override
|
||||
State<RequestRewrite> createState() => _RequestRewriteState();
|
||||
@@ -19,15 +19,15 @@ class _RequestRewriteState extends State<RequestRewrite> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
requestRuleList = RequestRuleList(widget.proxyServer.requestRewrites);
|
||||
enableNotifier = ValueNotifier(widget.proxyServer.requestRewrites.enabled == true);
|
||||
requestRuleList = RequestRuleList(widget.configuration.requestRewrites);
|
||||
enableNotifier = ValueNotifier(widget.configuration.requestRewrites.enabled == true);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
if (changed || enableNotifier.value != widget.proxyServer.requestRewrites.enabled) {
|
||||
widget.proxyServer.requestRewrites.enabled = enableNotifier.value;
|
||||
widget.proxyServer.flushRequestRewriteConfig();
|
||||
if (changed || enableNotifier.value != widget.configuration.requestRewrites.enabled) {
|
||||
widget.configuration.requestRewrites.enabled = enableNotifier.value;
|
||||
widget.configuration.flushRequestRewriteConfig();
|
||||
}
|
||||
|
||||
enableNotifier.dispose();
|
||||
@@ -80,7 +80,7 @@ class _RequestRewriteState extends State<RequestRewrite> {
|
||||
|
||||
changed = true;
|
||||
setState(() {
|
||||
widget.proxyServer.requestRewrites.removeIndex(removeSelected);
|
||||
widget.configuration.requestRewrites.removeIndex(removeSelected);
|
||||
requestRuleList.changeState();
|
||||
});
|
||||
})
|
||||
@@ -97,7 +97,7 @@ class _RequestRewriteState extends State<RequestRewrite> {
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return RuleAddDialog(
|
||||
requestRewrites: widget.proxyServer.requestRewrites,
|
||||
requestRewrites: widget.configuration.requestRewrites,
|
||||
currentIndex: currentIndex,
|
||||
onChange: () {
|
||||
changed = true;
|
||||
@@ -250,7 +250,7 @@ class _RequestRuleListState extends State<RequestRuleList> {
|
||||
border: TableBorder.symmetric(outside: BorderSide(width: 1, color: Theme.of(context).highlightColor)),
|
||||
columns: const <DataColumn>[
|
||||
DataColumn(label: Text('启用')),
|
||||
DataColumn(label: Text('URL')),
|
||||
DataColumn(label: Text('Path')),
|
||||
DataColumn(label: Text('请求体')),
|
||||
DataColumn(label: Text('响应体')),
|
||||
],
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:network_proxy/network/bin/configuration.dart';
|
||||
import 'package:network_proxy/network/bin/server.dart';
|
||||
import 'package:network_proxy/network/util/system_proxy.dart';
|
||||
import 'package:network_proxy/ui/desktop/toolbar/setting/request_rewrite.dart';
|
||||
@@ -20,10 +21,12 @@ class Setting extends StatefulWidget {
|
||||
|
||||
class _SettingState extends State<Setting> {
|
||||
late ValueNotifier<bool> enableDesktopListenable;
|
||||
late Configuration configuration;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
enableDesktopListenable = ValueNotifier<bool>(widget.proxyServer.enableDesktop);
|
||||
configuration = widget.proxyServer.configuration;
|
||||
enableDesktopListenable = ValueNotifier<bool>(configuration.enableDesktop);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@@ -54,12 +57,12 @@ class _SettingState extends State<Setting> {
|
||||
title: const Text("抓取电脑请求"),
|
||||
visualDensity: const VisualDensity(horizontal: -4),
|
||||
dense: true,
|
||||
value: widget.proxyServer.enableDesktop,
|
||||
value: configuration.enableDesktop,
|
||||
onChanged: (val) {
|
||||
SystemProxy.setSystemProxyEnable(widget.proxyServer.port, val, widget.proxyServer.enableSsl);
|
||||
widget.proxyServer.enableDesktop = val;
|
||||
configuration.enableDesktop = val;
|
||||
enableDesktopListenable.value = !enableDesktopListenable.value;
|
||||
widget.proxyServer.flushConfig();
|
||||
configuration.flushConfig();
|
||||
}))),
|
||||
const PopupMenuItem(padding: EdgeInsets.all(0), child: ThemeSetting(dense: true)),
|
||||
menuItem("域名过滤", onTap: () => hostFilter()),
|
||||
@@ -106,7 +109,7 @@ class _SettingState extends State<Setting> {
|
||||
label: const Text("关闭"),
|
||||
onPressed: () => Navigator.of(context).pop())))
|
||||
]),
|
||||
content: RequestRewrite(proxyServer: widget.proxyServer),
|
||||
content: RequestRewrite(configuration: configuration),
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -117,7 +120,7 @@ class _SettingState extends State<Setting> {
|
||||
barrierDismissible: false,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return FilterDialog(proxyServer: widget.proxyServer);
|
||||
return FilterDialog(configuration: configuration);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -146,11 +149,11 @@ class _PortState extends State<PortWidget> {
|
||||
portFocus.addListener(() async {
|
||||
//失去焦点
|
||||
if (!portFocus.hasFocus && textController.text != widget.proxyServer.port.toString()) {
|
||||
widget.proxyServer.port = int.parse(textController.text);
|
||||
widget.proxyServer.configuration.port = int.parse(textController.text);
|
||||
if (widget.proxyServer.isRunning) {
|
||||
widget.proxyServer.restart();
|
||||
}
|
||||
widget.proxyServer.flushConfig();
|
||||
widget.proxyServer.configuration.flushConfig();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user