add password to --connect command in flutter, --connect id [passord]

This commit is contained in:
rustdesk 2023-03-20 00:16:06 +08:00
parent 7009d4fa7b
commit 4d827708c3
7 changed files with 35 additions and 15 deletions

View File

@ -1523,6 +1523,11 @@ bool checkArguments() {
} }
String? id = String? id =
kBootArgs.length < connectIndex + 1 ? null : kBootArgs[connectIndex + 1]; kBootArgs.length < connectIndex + 1 ? null : kBootArgs[connectIndex + 1];
String? password =
kBootArgs.length < connectIndex + 2 ? null : kBootArgs[connectIndex + 2];
if (password != null && password.startsWith("--")) {
password = null;
}
final switchUuidIndex = kBootArgs.indexOf("--switch_uuid"); final switchUuidIndex = kBootArgs.indexOf("--switch_uuid");
String? switchUuid = kBootArgs.length < switchUuidIndex + 1 String? switchUuid = kBootArgs.length < switchUuidIndex + 1
? null ? null
@ -1536,7 +1541,8 @@ bool checkArguments() {
kBootArgs.removeAt(connectIndex); kBootArgs.removeAt(connectIndex);
// fallback to peer id // fallback to peer id
Future.delayed(Duration.zero, () { Future.delayed(Duration.zero, () {
rustDeskWinManager.newRemoteDesktop(id, switch_uuid: switchUuid); rustDeskWinManager.newRemoteDesktop(id,
password: password, switch_uuid: switchUuid);
}); });
return true; return true;
} }

View File

@ -25,19 +25,20 @@ import '../../utils/image.dart';
import '../widgets/remote_toolbar.dart'; import '../widgets/remote_toolbar.dart';
import '../widgets/kb_layout_type_chooser.dart'; import '../widgets/kb_layout_type_chooser.dart';
bool _isCustomCursorInited = false;
final SimpleWrapper<bool> _firstEnterImage = SimpleWrapper(false); final SimpleWrapper<bool> _firstEnterImage = SimpleWrapper(false);
class RemotePage extends StatefulWidget { class RemotePage extends StatefulWidget {
RemotePage({ RemotePage({
Key? key, Key? key,
required this.id, required this.id,
required this.password,
required this.menubarState, required this.menubarState,
this.switchUuid, this.switchUuid,
this.forceRelay, this.forceRelay,
}) : super(key: key); }) : super(key: key);
final String id; final String id;
final String? password;
final MenubarState menubarState; final MenubarState menubarState;
final String? switchUuid; final String? switchUuid;
final bool? forceRelay; final bool? forceRelay;
@ -113,6 +114,7 @@ class _RemotePageState extends State<RemotePage>
}); });
_ffi.start( _ffi.start(
widget.id, widget.id,
password: widget.password,
switchUuid: widget.switchUuid, switchUuid: widget.switchUuid,
forceRelay: widget.forceRelay, forceRelay: widget.forceRelay,
); );

View File

@ -23,9 +23,6 @@ import '../../models/platform_model.dart';
class _MenuTheme { class _MenuTheme {
static const Color blueColor = MyTheme.button; static const Color blueColor = MyTheme.button;
static const Color hoverBlueColor = MyTheme.accent;
static const Color redColor = Colors.redAccent;
static const Color hoverRedColor = Colors.red;
// kMinInteractiveDimension // kMinInteractiveDimension
static const double height = 20.0; static const double height = 20.0;
static const double dividerHeight = 12.0; static const double dividerHeight = 12.0;
@ -71,6 +68,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
page: RemotePage( page: RemotePage(
key: ValueKey(peerId), key: ValueKey(peerId),
id: peerId, id: peerId,
password: params['password'],
menubarState: _menubarState, menubarState: _menubarState,
switchUuid: params['switch_uuid'], switchUuid: params['switch_uuid'],
forceRelay: params['forceRelay'], forceRelay: params['forceRelay'],
@ -106,6 +104,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
page: RemotePage( page: RemotePage(
key: ValueKey(id), key: ValueKey(id),
id: id, id: id,
password: args['password'],
menubarState: _menubarState, menubarState: _menubarState,
switchUuid: switchUuid, switchUuid: switchUuid,
forceRelay: args['forceRelay'], forceRelay: args['forceRelay'],

View File

@ -1,12 +1,9 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:ffi' hide Size;
import 'dart:io'; import 'dart:io';
import 'dart:math'; import 'dart:math';
import 'dart:typed_data';
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'package:ffi/ffi.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_hbb/consts.dart'; import 'package:flutter_hbb/consts.dart';
@ -1534,6 +1531,7 @@ class FFI {
{bool isFileTransfer = false, {bool isFileTransfer = false,
bool isPortForward = false, bool isPortForward = false,
String? switchUuid, String? switchUuid,
String? password,
bool? forceRelay}) { bool? forceRelay}) {
assert(!(isFileTransfer && isPortForward), 'more than one connect type'); assert(!(isFileTransfer && isPortForward), 'more than one connect type');
if (isFileTransfer) { if (isFileTransfer) {
@ -1550,11 +1548,13 @@ class FFI {
} }
// ignore: unused_local_variable // ignore: unused_local_variable
final addRes = bind.sessionAddSync( final addRes = bind.sessionAddSync(
id: id, id: id,
isFileTransfer: isFileTransfer, isFileTransfer: isFileTransfer,
isPortForward: isPortForward, isPortForward: isPortForward,
switchUuid: switchUuid ?? "", switchUuid: switchUuid ?? "",
forceRelay: forceRelay ?? false); forceRelay: forceRelay ?? false,
password: password ?? "",
);
final stream = bind.sessionStart(id: id); final stream = bind.sessionStart(id: id);
final cb = ffiModel.startEventListener(id); final cb = ffiModel.startEventListener(id);
() async { () async {

View File

@ -43,12 +43,14 @@ class RustDeskMultiWindowManager {
Future<dynamic> newRemoteDesktop( Future<dynamic> newRemoteDesktop(
String remoteId, { String remoteId, {
String? password,
String? switch_uuid, String? switch_uuid,
bool? forceRelay, bool? forceRelay,
}) async { }) async {
var params = { var params = {
"type": WindowType.RemoteDesktop.index, "type": WindowType.RemoteDesktop.index,
"id": remoteId, "id": remoteId,
"password": password,
"forceRelay": forceRelay "forceRelay": forceRelay
}; };
if (switch_uuid != null) { if (switch_uuid != null) {

View File

@ -420,7 +420,14 @@ impl InvokeUiSession for FlutterHandler {
// unused in flutter // TEST flutter // unused in flutter // TEST flutter
fn confirm_delete_files(&self, _id: i32, _i: i32, _name: String) {} fn confirm_delete_files(&self, _id: i32, _i: i32, _name: String) {}
fn override_file_confirm(&self, id: i32, file_num: i32, to: String, is_upload: bool, is_identical: bool) { fn override_file_confirm(
&self,
id: i32,
file_num: i32,
to: String,
is_upload: bool,
is_identical: bool,
) {
self.push_event( self.push_event(
"override_file_confirm", "override_file_confirm",
vec![ vec![
@ -428,7 +435,7 @@ impl InvokeUiSession for FlutterHandler {
("file_num", &file_num.to_string()), ("file_num", &file_num.to_string()),
("read_path", &to), ("read_path", &to),
("is_upload", &is_upload.to_string()), ("is_upload", &is_upload.to_string()),
("is_identical", &is_identical.to_string()) ("is_identical", &is_identical.to_string()),
], ],
); );
} }
@ -632,12 +639,14 @@ pub fn session_add(
is_port_forward: bool, is_port_forward: bool,
switch_uuid: &str, switch_uuid: &str,
force_relay: bool, force_relay: bool,
password: String,
) -> ResultType<()> { ) -> ResultType<()> {
let session_id = get_session_id(id.to_owned()); let session_id = get_session_id(id.to_owned());
LocalConfig::set_remote_id(&session_id); LocalConfig::set_remote_id(&session_id);
let session: Session<FlutterHandler> = Session { let session: Session<FlutterHandler> = Session {
id: session_id.clone(), id: session_id.clone(),
password,
server_keyboard_enabled: Arc::new(RwLock::new(true)), server_keyboard_enabled: Arc::new(RwLock::new(true)),
server_file_transfer_enabled: Arc::new(RwLock::new(true)), server_file_transfer_enabled: Arc::new(RwLock::new(true)),
server_clipboard_enabled: Arc::new(RwLock::new(true)), server_clipboard_enabled: Arc::new(RwLock::new(true)),

View File

@ -87,6 +87,7 @@ pub fn session_add_sync(
is_port_forward: bool, is_port_forward: bool,
switch_uuid: String, switch_uuid: String,
force_relay: bool, force_relay: bool,
password: String,
) -> SyncReturn<String> { ) -> SyncReturn<String> {
if let Err(e) = session_add( if let Err(e) = session_add(
&id, &id,
@ -94,6 +95,7 @@ pub fn session_add_sync(
is_port_forward, is_port_forward,
&switch_uuid, &switch_uuid,
force_relay, force_relay,
password,
) { ) {
SyncReturn(format!("Failed to add session with id {}, {}", &id, e)) SyncReturn(format!("Failed to add session with id {}, {}", &id, e))
} else { } else {