diff --git a/android/app/src/main/kotlin/com/network/proxy/vpn/ConnectionManager.kt b/android/app/src/main/kotlin/com/network/proxy/vpn/ConnectionManager.kt index 5d4aac0..4818762 100644 --- a/android/app/src/main/kotlin/com/network/proxy/vpn/ConnectionManager.kt +++ b/android/app/src/main/kotlin/com/network/proxy/vpn/ConnectionManager.kt @@ -6,6 +6,7 @@ import com.network.proxy.vpn.socket.CloseableConnection import com.network.proxy.vpn.socket.Constant import com.network.proxy.vpn.socket.ProtectSocketHolder.Companion.protect import com.network.proxy.vpn.util.PacketUtil +import com.network.proxy.vpn.util.ProcessInfoManager import java.io.IOException import java.net.InetSocketAddress import java.net.SocketAddress @@ -107,6 +108,8 @@ class ConnectionManager private constructor() : CloseableConnection { val connected = channel.connect(socketAddress) connection.isConnected = connected if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + //获取进程信息 + ProcessInfoManager.instance.setConnectionOwnerUid(connection) Log.d( TAG, "Initiate connecting " + channel.localAddress + " to remote tcp server: " + channel.remoteAddress diff --git a/lib/network/components/script_manager.dart b/lib/network/components/script_manager.dart index de17258..2fd8855 100644 --- a/lib/network/components/script_manager.dart +++ b/lib/network/components/script_manager.dart @@ -5,6 +5,7 @@ import 'package:desktop_multi_window/desktop_multi_window.dart'; import 'package:flutter_js/flutter_js.dart'; import 'package:network_proxy/network/http/http.dart'; import 'package:network_proxy/network/http/http_headers.dart'; +import 'package:network_proxy/ui/component/device.dart'; import 'package:network_proxy/network/util/logger.dart'; import 'package:path_provider/path_provider.dart'; @@ -49,6 +50,8 @@ async function onResponse(context, request, response) { static JavascriptRuntime flutterJs = getJavascriptRuntime(); + static String? deviceId; + static final List _logHandlers = []; ScriptManager._(); @@ -62,7 +65,8 @@ async function onResponse(context, request, response) { // register channel callback final channelCallbacks = JavascriptRuntime.channelFunctionsRegistered[flutterJs.getEngineInstanceId()]; channelCallbacks!["ConsoleLog"] = _instance!.consoleLog; - logger.d('init script manager'); + deviceId = await DeviceUtils.deviceId(); + logger.d('init script manager $deviceId'); } return _instance!; } @@ -202,11 +206,7 @@ async function onResponse(context, request, response) { ///脚本上下文 Map scriptContext(ScriptItem item) { - return { - 'scriptName': item.name, - 'os': Platform.operatingSystem, - 'session': scriptSession, - }; + return {'scriptName': item.name, 'os': Platform.operatingSystem, 'session': scriptSession, "deviceId": deviceId}; } ///运行脚本 diff --git a/lib/ui/component/device.dart b/lib/ui/component/device.dart new file mode 100644 index 0000000..badf417 --- /dev/null +++ b/lib/ui/component/device.dart @@ -0,0 +1,31 @@ +import 'dart:io'; + +import 'package:desktop_multi_window/desktop_multi_window.dart'; +import 'package:device_info_plus/device_info_plus.dart'; + +class DeviceUtils { + /// Get the device id + static Future deviceId() async { + var deviceInfoPlugin = DeviceInfoPlugin(); + if (Platform.isAndroid) { + return deviceInfoPlugin.androidInfo.then((it) => it.id); + } else if (Platform.isIOS) { + return deviceInfoPlugin.iosInfo.then((it) => it.identifierForVendor); + } + + return await DesktopMultiWindow.invokeMethod(0, "deviceId", null); + } + + /// Get the desktop device id + static Future desktopDeviceId() async { + var deviceInfoPlugin = DeviceInfoPlugin(); + if (Platform.isWindows) { + return deviceInfoPlugin.windowsInfo.then((it) => it.deviceId); + } else if (Platform.isMacOS) { + return deviceInfoPlugin.macOsInfo.then((it) => it.systemGUID); + } else if (Platform.isLinux) { + return deviceInfoPlugin.linuxInfo.then((it) => it.machineId); + } + return null; + } +} diff --git a/lib/ui/component/multi_window.dart b/lib/ui/component/multi_window.dart index f162d6c..0b41462 100644 --- a/lib/ui/component/multi_window.dart +++ b/lib/ui/component/multi_window.dart @@ -9,6 +9,7 @@ import 'package:network_proxy/network/components/request_rewrite_manager.dart'; import 'package:network_proxy/network/components/script_manager.dart'; import 'package:network_proxy/network/http/http.dart'; import 'package:network_proxy/network/util/logger.dart'; +import 'package:network_proxy/ui/component/device.dart'; import 'package:network_proxy/ui/component/encoder.dart'; import 'package:network_proxy/ui/component/utils.dart'; import 'package:network_proxy/ui/content/body.dart'; @@ -176,6 +177,10 @@ void registerMethodHandler() { return "done"; } + if (call.method == 'deviceId') { + return await DeviceUtils.desktopDeviceId(); + } + return 'done'; }); } diff --git a/lib/ui/mobile/setting/rewrite/rewrite_replace.dart b/lib/ui/mobile/setting/rewrite/rewrite_replace.dart index 6200c44..22d0acc 100644 --- a/lib/ui/mobile/setting/rewrite/rewrite_replace.dart +++ b/lib/ui/mobile/setting/rewrite/rewrite_replace.dart @@ -180,7 +180,7 @@ class _RewriteReplaceState extends State { TextFormField( initialValue: rewriteItem.body, style: const TextStyle(fontSize: 14), - maxLines: 15, + maxLines: 25, decoration: decoration(localizations.replaceBodyWith, hintText: '${localizations.example} {"code":"200","data":{}}'), onChanged: (val) => rewriteItem.body = val) diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 4d1e4a5..6c66687 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -6,6 +6,7 @@ import FlutterMacOS import Foundation import desktop_multi_window +import device_info_plus import file_selector_macos import flutter_desktop_context_menu import flutter_js @@ -18,6 +19,7 @@ import window_manager func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FlutterMultiWindowPlugin.register(with: registry.registrar(forPlugin: "FlutterMultiWindowPlugin")) + DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) FlutterDesktopContextMenuPlugin.register(with: registry.registrar(forPlugin: "FlutterDesktopContextMenuPlugin")) FlutterJsPlugin.register(with: registry.registrar(forPlugin: "FlutterJsPlugin")) diff --git a/pubspec.yaml b/pubspec.yaml index 3679f7c..169ec36 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,29 +39,7 @@ dependencies: file_picker: ^8.0.0 flutter_desktop_context_menu: ^0.2.0 win32audio: ^1.3.1 -# video_player: -# git: -# url: https://github.com/icapps/plugins.git -# ref: feature/ios-pip -# path: packages/video_player/video_player - - -#dependency_overrides: -# video_player_platform_interface: -# git: -# url: https://github.com/icapps/plugins.git -# ref: feature/ios-pip -# path: packages/video_player/video_player_platform_interface -# video_player_avfoundation: -# git: -# url: https://github.com/icapps/plugins.git -# ref: feature/ios-pip -# path: packages/video_player/video_player_avfoundation -# video_player_android: -# git: -# url: https://github.com/icapps/plugins.git -# ref: feature/ios-pip -# path: packages/video_player/video_player_android + device_info_plus: ^10.1.0 dev_dependencies: flutter_test: