Skip to content

Commit

Permalink
设置代理忽略域名
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghongenpin committed Sep 30, 2023
1 parent ab12f6e commit 2a7d5e6
Show file tree
Hide file tree
Showing 11 changed files with 430 additions and 209 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Bug report
about: Create reports to help us improve
title: "[系统]xxx"
title: "[Windows、Mac、Android]xxx"
labels: bug
assignees: ''

Expand All @@ -10,6 +10,6 @@ assignees: ''
**描述错误**

**To Reproduce**
重现行为的步骤:
重现行为的步骤: 如具体应用抓包失败,请说明软件名称以及具体操作页面

**屏幕截图*
8 changes: 8 additions & 0 deletions lib/network/bin/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ import 'package:network_proxy/network/host_port.dart';
import 'package:network_proxy/network/util/host_filter.dart';
import 'package:network_proxy/network/util/logger.dart';
import 'package:network_proxy/network/util/request_rewrite.dart';
import 'package:network_proxy/network/util/system_proxy.dart';
import 'package:network_proxy/utils/platform.dart';
import 'package:path_provider/path_provider.dart';

class Configuration {
///代理相关配置
int port = 9099;

//是否启用https抓包
Expand All @@ -33,6 +35,9 @@ class Configuration {
//是否设置系统代理
bool enableSystemProxy = true;

//代理忽略域名
String proxyPassDomains = SystemProxy.proxyPassDomains;

//是否显示更新内容公告
bool upgradeNoticeV3 = true;

Expand Down Expand Up @@ -69,6 +74,7 @@ class Configuration {
}

String? userHome;

Future<File> homeDir() async {
if (userHome != null) {
return File("${userHome!}${Platform.pathSeparator}.proxypin");
Expand Down Expand Up @@ -117,6 +123,7 @@ class Configuration {
port = config['port'] ?? port;
enableSsl = config['enableSsl'] == true;
enableSystemProxy = config['enableSystemProxy'] ?? (config['enableDesktop'] ?? true);
proxyPassDomains = config['proxyPassDomains'] ?? SystemProxy.proxyPassDomains;
upgradeNoticeV3 = config['upgradeNoticeV3'] ?? true;
if (config['externalProxy'] != null) {
externalProxy = ProxyInfo.fromJson(config['externalProxy']);
Expand Down Expand Up @@ -162,6 +169,7 @@ class Configuration {
'port': port,
'enableSsl': enableSsl,
'enableSystemProxy': enableSystemProxy,
'proxyPassDomains': proxyPassDomains,
'externalProxy': externalProxy?.toJson(),
'appWhitelist': appWhitelist,
'whitelist': HostFilter.whitelist.toJson(),
Expand Down
9 changes: 3 additions & 6 deletions lib/network/bin/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

import 'dart:async';
import 'dart:io';

import 'package:network_proxy/network/bin/configuration.dart';
import 'package:network_proxy/network/channel.dart';
Expand Down Expand Up @@ -59,9 +58,7 @@ class ProxyServer {
return;
}

if (Platform.isMacOS) {
SystemProxy.setSslProxyEnableMacOS(enableSsl, port);
}
SystemProxy.setSslProxyEnable(enableSsl, port);
}

/// 启动代理服务
Expand Down Expand Up @@ -100,11 +97,11 @@ class ProxyServer {
setSystemProxyEnable(bool enable) async {
//关闭系统代理 恢复成外部代理地址
if (!enable && configuration.externalProxy?.enabled == true) {
await SystemProxy.setSystemProxy(configuration.externalProxy!.port!, enableSsl);
await SystemProxy.setSystemProxy(configuration.externalProxy!.port!, enableSsl, configuration.proxyPassDomains);
return;
}

await SystemProxy.setSystemProxyEnable(port, enable, enableSsl);
await SystemProxy.setSystemProxyEnable(port, enable, enableSsl, passDomains: configuration.proxyPassDomains);
}

/// 重启代理服务
Expand Down
Loading

0 comments on commit 2a7d5e6

Please sign in to comment.