mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-05-09 00:34:17 +08:00
修改默认端口号,pc根证书安装简化,去除下载步骤
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
**Mac首次打开会提示已损坏,需要到系统偏好设置-安全性与隐私-允许任何来源。**
|
||||
|
||||
国内下载地址:https://gitee.com/wanghongenpin/network-proxy-flutter/releases/tag/0.0.1
|
||||
国内下载地址:https://gitee.com/wanghongenpin/network-proxy-flutter/releases
|
||||
|
||||
> ios个人开发者账号用到VPN没法上架AppStore, 后面可能会上架美版AppStore。
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ Future<void> main() async {
|
||||
/// 代理服务器
|
||||
class ProxyServer {
|
||||
bool init = false;
|
||||
int port = 6666;
|
||||
int port = 9099;
|
||||
bool _enableSsl = false;
|
||||
bool enableDesktop = true;
|
||||
|
||||
|
||||
@@ -39,17 +39,18 @@ class HttpChannelHandler extends ChannelHandler<HttpRequest> {
|
||||
@override
|
||||
void channelRead(Channel channel, HttpRequest msg) async {
|
||||
channel.putAttribute(AttributeKeys.request, msg);
|
||||
//请求本服务
|
||||
if ((await localIp()) == msg.hostAndPort?.host) {
|
||||
localRequest(msg, channel);
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.uri == 'http://proxy.pin/ssl' || msg.requestUrl == 'http://127.0.0.1:${channel.socket.port}/ssl') {
|
||||
_crtDownload(channel, msg);
|
||||
return;
|
||||
}
|
||||
|
||||
//请求本服务
|
||||
if ((await localIp()) == msg.hostAndPort?.host) {
|
||||
localRequest(msg, channel);
|
||||
return;
|
||||
}
|
||||
|
||||
//转发请求
|
||||
forward(channel, msg).catchError((error, trace) {
|
||||
channel.close();
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:file_selector/file_selector.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:network_proxy/network/bin/server.dart';
|
||||
import 'package:network_proxy/utils/ip.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class SslWidget extends StatefulWidget {
|
||||
final ProxyServer proxyServer;
|
||||
@@ -82,20 +83,27 @@ class _SslState extends State<SslWidget> {
|
||||
title: const Text("电脑HTTPS抓包配置", style: TextStyle(fontSize: 16)),
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
const Text("1. 下载根证书安装到本系统(已完成忽略)"),
|
||||
FilledButton(onPressed: () => _downloadCert(), child: const Text("下载证书")),
|
||||
Text(
|
||||
" 安装证书到本系统,${Platform.isMacOS ? "“安装完选择“始终信任此证书”" : "选择“受信任的根证书颁发机构”"}"),
|
||||
const SizedBox(height: 10),
|
||||
Text("2. 双击安装证书,${Platform.isMacOS ? "“Mac安装完选择“始终信任此证书”" : "Windows选择“受信任的根证书颁发机构”"}"),
|
||||
FilledButton(
|
||||
onPressed: _installCert, child: const Text("安装证书")),
|
||||
const SizedBox(height: 10),
|
||||
Platform.isMacOS
|
||||
? Image.network("https://foruda.gitee.com/images/1689323260158189316/c2d881a4_1073801.png",
|
||||
width: 800, height: 500)
|
||||
? Image.network(
|
||||
"https://foruda.gitee.com/images/1689323260158189316/c2d881a4_1073801.png",
|
||||
width: 800,
|
||||
height: 500)
|
||||
: Row(children: [
|
||||
Image.network("https://foruda.gitee.com/images/1689335589122168223/c904a543_1073801.png",
|
||||
width: 400, height: 400),
|
||||
Image.network(
|
||||
"https://foruda.gitee.com/images/1689335589122168223/c904a543_1073801.png",
|
||||
width: 400,
|
||||
height: 400),
|
||||
const SizedBox(width: 10),
|
||||
Image.network("https://foruda.gitee.com/images/1689335334688878324/f6aa3a3a_1073801.png",
|
||||
width: 400, height: 400)
|
||||
Image.network(
|
||||
"https://foruda.gitee.com/images/1689335334688878324/f6aa3a3a_1073801.png",
|
||||
width: 400,
|
||||
height: 400)
|
||||
])
|
||||
]);
|
||||
});
|
||||
@@ -112,34 +120,36 @@ class _SslState extends State<SslWidget> {
|
||||
children: [
|
||||
const Text("1. 根证书安装到本系统(已完成忽略)"),
|
||||
const SizedBox(height: 10),
|
||||
SelectableText.rich(TextSpan(text: "2. 配置手机Wifi代理 Host:$host Port:${widget.proxyServer.port}")),
|
||||
SelectableText.rich(TextSpan(
|
||||
text:
|
||||
"2. 配置手机Wifi代理 Host:$host Port:${widget.proxyServer.port}")),
|
||||
const SizedBox(height: 10),
|
||||
const Row(
|
||||
children: [
|
||||
Text("3. 打开手机系统自带浏览器访问:\t"),
|
||||
SelectableText.rich(
|
||||
TextSpan(text: "http://proxy.pin/ssl", style: TextStyle(decoration: TextDecoration.underline)))
|
||||
SelectableText.rich(TextSpan(
|
||||
text: "http://proxy.pin/ssl",
|
||||
style: TextStyle(decoration: TextDecoration.underline)))
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Text("4. 打开手机设置下载安装证书信任证书\n\t 设置 > 通用 > 关于本机 > 证书信任设置"),
|
||||
const SizedBox(height: 20),
|
||||
const Text(" 抓微信小程序ios需要开启本地网络权限", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
const Text(" 抓微信小程序ios需要开启本地网络权限",
|
||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
void _downloadCert() async {
|
||||
final FileSaveLocation? location = await getSaveLocation(suggestedName: "ProxyPinCA.crt");
|
||||
if (location != null) {
|
||||
const String fileMimeType = 'application/x-x509-ca-cert';
|
||||
void _installCert() async {
|
||||
final String appPath =
|
||||
await getApplicationSupportDirectory().then((value) => value.path);
|
||||
var caFile = File("$appPath${Platform.pathSeparator}ProxyPinCA.crt");
|
||||
if (!(await caFile.exists())) {
|
||||
var body = await rootBundle.load('assets/certs/ca.crt');
|
||||
final XFile xFile = XFile.fromData(
|
||||
body.buffer.asUint8List(),
|
||||
mimeType: fileMimeType,
|
||||
);
|
||||
await xFile.saveTo(location.path);
|
||||
await caFile.writeAsBytes(body.buffer.asUint8List());
|
||||
}
|
||||
launchUrl(Uri.file(caFile.path));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +157,9 @@ class _Switch extends StatefulWidget {
|
||||
final ProxyServer proxyServer;
|
||||
final Function(bool val) onEnableChange;
|
||||
|
||||
const _Switch({Key? key, required this.proxyServer, required this.onEnableChange}) : super(key: key);
|
||||
const _Switch(
|
||||
{Key? key, required this.proxyServer, required this.onEnableChange})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<_Switch> createState() => _SwitchState();
|
||||
|
||||
@@ -15,7 +15,8 @@ String? ip;
|
||||
|
||||
Future<String> localIp() async {
|
||||
ip ??= await NetworkInterface.list().then((interfaces) {
|
||||
return interfaces.firstWhere((it) => it.name == "en0", orElse: () => interfaces.first).addresses.first.address;
|
||||
return interfaces.firstWhere((it) => it.name == "en0" || it.name == 'WLAN',
|
||||
orElse: () => interfaces.first).addresses.first.address;
|
||||
});
|
||||
return ip!;
|
||||
}
|
||||
|
||||
@@ -6,16 +6,12 @@
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <file_selector_linux/file_selector_plugin.h>
|
||||
#include <proxy_manager/proxy_manager_plugin.h>
|
||||
#include <screen_retriever/screen_retriever_plugin.h>
|
||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||
#include <window_manager/window_manager_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
|
||||
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
|
||||
g_autoptr(FlPluginRegistrar) proxy_manager_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "ProxyManagerPlugin");
|
||||
proxy_manager_plugin_register_with_registrar(proxy_manager_registrar);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
file_selector_linux
|
||||
proxy_manager
|
||||
screen_retriever
|
||||
url_launcher_linux
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import file_selector_macos
|
||||
import path_provider_foundation
|
||||
import proxy_manager
|
||||
import screen_retriever
|
||||
@@ -15,7 +14,6 @@ import url_launcher_macos
|
||||
import window_manager
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
ProxyManagerPlugin.register(with: registry.registrar(forPlugin: "ProxyManagerPlugin"))
|
||||
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
|
||||
|
||||
64
pubspec.lock
64
pubspec.lock
@@ -153,70 +153,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.0.0"
|
||||
file_selector:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: file_selector
|
||||
sha256: "59b35aa4af7988be7ec88f9ddaa6c71c5b54bf0f8b35009389d9343b10e9c3af"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
file_selector_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_android
|
||||
sha256: "59e694afad4609d689185a608958c85fbccb3e6feab12a6b8c95a2c0f90ad2f7"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.0+1"
|
||||
file_selector_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_ios
|
||||
sha256: "54542b6b35e3ced6246df5fae13cf0b879d14669d0fdff1a53a098f16e23328b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.1+4"
|
||||
file_selector_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_linux
|
||||
sha256: "770eb1ab057b5ae4326d1c24cc57710758b9a46026349d021d6311bd27580046"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.2"
|
||||
file_selector_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_macos
|
||||
sha256: "4ada532862917bf16e3adb3891fe3a5917a58bae03293e497082203a80909412"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.3+1"
|
||||
file_selector_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_platform_interface
|
||||
sha256: "412705a646a0ae90f33f37acfae6a0f7cbc02222d6cd34e479421c3e74d3853c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.6.0"
|
||||
file_selector_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_web
|
||||
sha256: e292740c469df0aeeaba0895bf622bea351a05e87d22864c826bf21c4780e1d7
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.2"
|
||||
file_selector_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_windows
|
||||
sha256: "1372760c6b389842b77156203308940558a2817360154084368608413835fc26"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.3"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
|
||||
@@ -14,7 +14,6 @@ dependencies:
|
||||
basic_utils:
|
||||
logger: ^1.4.0
|
||||
date_format: ^2.0.7
|
||||
file_selector: ^1.0.0
|
||||
window_manager: ^0.3.5
|
||||
path_provider: ^2.0.15
|
||||
url_launcher: ^6.1.11
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <file_selector_windows/file_selector_windows.h>
|
||||
#include <proxy_manager/proxy_manager_plugin.h>
|
||||
#include <screen_retriever/screen_retriever_plugin.h>
|
||||
#include <share_plus/share_plus_windows_plugin_c_api.h>
|
||||
@@ -14,8 +13,6 @@
|
||||
#include <window_manager/window_manager_plugin.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
FileSelectorWindowsRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FileSelectorWindows"));
|
||||
ProxyManagerPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("ProxyManagerPlugin"));
|
||||
ScreenRetrieverPluginRegisterWithRegistrar(
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
file_selector_windows
|
||||
proxy_manager
|
||||
screen_retriever
|
||||
share_plus
|
||||
|
||||
Reference in New Issue
Block a user