mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-03-15 04:23:17 +08:00
script context add deviceId param
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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<LogHandler> _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<String, dynamic> scriptContext(ScriptItem item) {
|
||||
return {
|
||||
'scriptName': item.name,
|
||||
'os': Platform.operatingSystem,
|
||||
'session': scriptSession,
|
||||
};
|
||||
return {'scriptName': item.name, 'os': Platform.operatingSystem, 'session': scriptSession, "deviceId": deviceId};
|
||||
}
|
||||
|
||||
///运行脚本
|
||||
|
||||
31
lib/ui/component/device.dart
Normal file
31
lib/ui/component/device.dart
Normal file
@@ -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<String?> 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<String?> 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;
|
||||
}
|
||||
}
|
||||
@@ -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';
|
||||
});
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ class _RewriteReplaceState extends State<RewriteReplaceWidget> {
|
||||
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)
|
||||
|
||||
@@ -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"))
|
||||
|
||||
24
pubspec.yaml
24
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:
|
||||
|
||||
Reference in New Issue
Block a user