record permission

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2022-09-22 09:55:34 +08:00
parent e74f155cb6
commit e7e3494dc9
38 changed files with 126 additions and 21 deletions

View File

@@ -958,6 +958,9 @@ impl<T: InvokeUiSession> Remote<T> {
Permission::Restart => {
self.handler.set_permission("restart", p.enabled);
}
Permission::Recording => {
self.handler.set_permission("recording", p.enabled);
}
}
}
Some(misc::Union::SwitchDisplay(s)) => {

View File

@@ -146,6 +146,7 @@ pub enum Data {
file: bool,
file_transfer_enabled: bool,
restart: bool,
recording: bool,
},
ChatMessage {
text: String,

View File

@@ -352,5 +352,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", "更改"),
("Start session recording", "开始录屏"),
("Stop session recording", "结束录屏"),
("Enable Recording Session", "允许录制会话"),
("Allow recording session", "允许录制会话"),
].iter().cloned().collect();
}

View File

@@ -352,5 +352,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -352,5 +352,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -352,5 +352,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -352,5 +352,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -365,5 +365,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -352,5 +352,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -352,5 +352,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -365,5 +365,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -351,5 +351,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -349,5 +349,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -346,5 +346,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -327,5 +327,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -350,5 +350,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -346,5 +346,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -352,5 +352,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -352,5 +352,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -352,5 +352,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -352,5 +352,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -365,5 +365,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -352,5 +352,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", "變更"),
("Start session recording", "開始錄屏"),
("Stop session recording", "結束錄屏"),
("Enable Recording Session", "允許錄製會話"),
("Allow recording session", "允許錄製會話"),
].iter().cloned().collect();
}

View File

@@ -352,5 +352,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Change", ""),
("Start session recording", ""),
("Stop session recording", ""),
("Enable Recording Session", ""),
("Allow recording session", ""),
].iter().cloned().collect();
}

View File

@@ -81,6 +81,7 @@ pub struct Connection {
audio: bool,
file: bool,
restart: bool,
recording: bool,
last_test_delay: i64,
lock_after_session_end: bool,
show_remote_cursor: bool, // by peer
@@ -169,6 +170,7 @@ impl Connection {
audio: Config::get_option("enable-audio").is_empty(),
file: Config::get_option("enable-file-transfer").is_empty(),
restart: Config::get_option("enable-remote-restart").is_empty(),
recording: Config::get_option("enable-record-session").is_empty(),
last_test_delay: 0,
lock_after_session_end: false,
show_remote_cursor: false,
@@ -210,6 +212,9 @@ impl Connection {
if !conn.restart {
conn.send_permission(Permission::Restart, false).await;
}
if !conn.recording {
conn.send_permission(Permission::Recording, false).await;
}
let mut test_delay_timer =
time::interval_at(Instant::now() + TEST_DELAY_TIMEOUT, TEST_DELAY_TIMEOUT);
let mut last_recv_time = Instant::now();
@@ -290,6 +295,9 @@ impl Connection {
} else if &name == "restart" {
conn.restart = enabled;
conn.send_permission(Permission::Restart, enabled).await;
} else if &name == "recording" {
conn.recording = enabled;
conn.send_permission(Permission::Recording, enabled).await;
}
}
ipc::Data::RawMessage(bytes) => {
@@ -777,6 +785,7 @@ impl Connection {
file: self.file,
file_transfer_enabled: self.file_transfer_enabled(),
restart: self.restart,
recording: self.recording,
});
}

View File

@@ -108,6 +108,10 @@ icon.restart {
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAB7BAAAewQHDaVRTAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAbhJREFUWIXVlrFqFGEUhb+7UYxaWCQKlrKKxaZSQVGDJih2tj6MD2DnMwiWvoAIRnENIpZiYxEro6IooiS7SPwsMgNLkk3mjmYmnmb45/73nMNwz/x/qH3gMu2gH6rAU+Blw+Lngau4jpmGxVF7qp1iPWjaQKnZ2WnXbuP/NqAeUPc3ZkA9XDwvqc+BVWCgPlJ7tRwUKThZce819b46VH+pfXVRXVO/q2cSul3VOgZUl0ejq86r39TXI8mqZKDuDEwCw3IREQvAbWAGmMsQZQ0sAl3gHPB1Q+0e8BuYzRDuy2yOiFVgaUxtRf0ETGc4syk4rc6PqU0Cx9j8Zf6dAeAK8Fi9sUXtFjABvEgxJlNwRP2svlNPjbw/q35U36oTFbnyMSwabxb/gB/qA3VBHagrauV7RW0DRfP1IvMlXqkXkhz1DYyQTKtHa/Z2VVMx3IiI+PI3/bCHjuOpFrSnAMpL6QfgTcMGesDx0kBr2BMzsNyi/vtQu8CJlgwsRbZDnWP90NkKaxHxJMOXMqAeAn5u0ydwMCKGY+qbkB3C2W3EKWoXk5zVoHbUZ+6Mh7tl4G4F8RJ3qvL+AfV3r5Vdpj70AAAAAElFTkSuQmCC');
}
icon.recording {
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAANpJREFUWEftltENAiEMhtsJ1NcynG6gI+gGugEOR591gppeQoIYSDBILxEeydH/57u2FMF4obE+TAOTwLoIhBDOAHBExG2n6rgR0akW640AM0sn4SWMiDycc7s8JjN7Ijro/k8NqAAR5RoeAPZxv2ggP9hCJiWZxtGbq3hqbJiBVHy4gVx8qAER8Yi4JFy6huVAKXemgb8icI+1b5KEitq0DOO/Nm1EEX1TK27p/bVvv36MOhl4EtHHbFF7jq8AoG1z08OAiFycczrkFNe6RrIet26NMQlMAuYEXiayryF/QQktAAAAAElFTkSuQmCC');
}
div.buttons {
width: *;
border-spacing: 0.5em;

View File

@@ -32,7 +32,8 @@ impl InvokeUiCM for SciterHandler {
client.clipboard,
client.audio,
client.file,
client.restart
client.restart,
client.recording
),
);
}

View File

@@ -41,13 +41,16 @@ class Body: Reactor.Component
</div>
<div />
{c.is_file_transfer || c.port_forward ? "" : <div>{translate('Permissions')}</div>}
{c.is_file_transfer || c.port_forward ? "" : <div .permissions>
{c.is_file_transfer || c.port_forward ? "" : <div> <div .permissions>
<div class={!c.keyboard ? "disabled" : ""} title={translate('Allow using keyboard and mouse')}><icon .keyboard /></div>
<div class={!c.clipboard ? "disabled" : ""} title={translate('Allow using clipboard')}><icon .clipboard /></div>
<div class={!c.audio ? "disabled" : ""} title={translate('Allow hearing sound')}><icon .audio /></div>
<div class={!c.file ? "disabled" : ""} title={translate('Allow file copy and paste')}><icon .file /></div>
<div class={!c.restart ? "disabled" : ""} title={translate('Allow remote restart')}><icon .restart /></div>
</div>}
</div> <div .permissions style="margin-top:8px;" >
<div class={!c.recording ? "disabled" : ""} title={translate('Allow recording session')}><icon .recording /></div>
</div></div>
}
{c.port_forward ? <div>Port Forwarding: {c.port_forward}</div> : ""}
<div style="size:*"/>
<div .buttons>
@@ -118,6 +121,15 @@ class Body: Reactor.Component
});
}
event click $(icon.recording) {
var { cid, connection } = this;
checkClickTime(function() {
connection.recording = !connection.recording;
body.update();
handler.switch_permission(cid, "recording", connection.recording);
});
}
event click $(button#accept) {
var { cid, connection } = this;
checkClickTime(function() {
@@ -276,7 +288,7 @@ function bring_to_top(idx=-1) {
}
}
handler.addConnection = function(id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, restart) {
handler.addConnection = function(id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, restart, recording) {
stdout.println("new connection #" + id + ": " + peer_id);
var conn;
connections.map(function(c) {
@@ -293,7 +305,7 @@ handler.addConnection = function(id, is_file_transfer, port_forward, peer_id, na
port_forward: port_forward,
name: name, authorized: authorized, time: new Date(),
keyboard: keyboard, clipboard: clipboard, msgs: [], unreaded: 0,
audio: audio, file: file, restart: restart
audio: audio, file: file, restart: restart, recording: recording
});
body.cur = connections.length - 1;
bring_to_top();

View File

@@ -144,7 +144,7 @@ class Header: Reactor.Component {
<span #action>{svg_action}</span>
<span #display>{svg_display}</span>
<span #keyboard>{svg_keyboard}</span>
<span #recording>{recording ? svg_recording_on : svg_recording_off}</span>
{recording_enabled ? <span #recording>{recording ? svg_recording_on : svg_recording_off}</span> : ""}
{this.renderKeyboardPop()}
{this.renderDisplayPop()}
{this.renderActionPop()}

View File

@@ -236,9 +236,11 @@ class Enhancements: Reactor.Component {
} else if (v == 'screen-recording') {
var dir = handler.get_option("video-save-directory");
if (!dir) dir = handler.default_video_save_directory();
var ts0 = handler.get_option("enable-record-session") == '' ? { checked: true } : {};
var ts1 = handler.get_option("allow-auto-record-incoming") == 'Y' ? { checked: true } : {};
msgbox("custom-recording", translate('Recording'),
<div .form>
<div><button|checkbox(enable_record_session) {ts0}>{translate('Enable Recording Session')}</button></div>
<div><button|checkbox(auto_record_incoming) {ts1}>{translate('Automatically record incoming sessions')}</button></div>
<div>
<div style="word-wrap:break-word"><span>{translate("Directory")}:&nbsp;&nbsp;</span><span #folderPath>{dir}</span></div>
@@ -247,6 +249,7 @@ class Enhancements: Reactor.Component {
</div>
, function(res=null) {
if (!res) return;
handler.set_option("enable-record-session", res.enable_record_session ? '' : 'N');
handler.set_option("allow-auto-record-incoming", res.auto_record_incoming ? 'Y' : '');
handler.set_option("video-save-directory", $(#folderPath).text);
});

View File

@@ -12,6 +12,7 @@ var clipboard_enabled = true; // server side
var audio_enabled = true; // server side
var file_enabled = true; // server side
var restart_enabled = true; // server side
var recording_enabled = true; // server side
var scroll_body = $(body);
handler.setDisplay = function(x, y, w, h) {
@@ -521,6 +522,7 @@ handler.setPermission = function(name, enabled) {
if (name == "file") file_enabled = enabled;
if (name == "clipboard") clipboard_enabled = enabled;
if (name == "restart") restart_enabled = enabled;
if (name == "recording") recording_enabled = enabled;
input_blocked = false;
header.update();
});

View File

@@ -40,6 +40,7 @@ pub struct Client {
pub audio: bool,
pub file: bool,
pub restart: bool,
pub recording: bool,
#[serde(skip)]
tx: UnboundedSender<Data>,
}
@@ -94,6 +95,7 @@ impl<T: InvokeUiCM> ConnectionManager<T> {
audio: bool,
file: bool,
restart: bool,
recording: bool,
tx: mpsc::UnboundedSender<Data>,
) {
let client = Client {
@@ -108,6 +110,7 @@ impl<T: InvokeUiCM> ConnectionManager<T> {
audio,
file,
restart,
recording,
tx,
};
self.ui_handler.add_connection(&client);
@@ -250,11 +253,11 @@ pub async fn start_ipc<T: InvokeUiCM>(cm: ConnectionManager<T>) {
}
Ok(Some(data)) => {
match data {
Data::Login{id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, file_transfer_enabled, restart} => {
Data::Login{id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, file_transfer_enabled, restart, recording} => {
log::debug!("conn_id: {}", id);
conn_id = id;
tx_file.send(ClipboardFileData::Enable((id, file_transfer_enabled))).ok();
cm.add_connection(id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, restart, tx.clone());
cm.add_connection(id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, file, restart, recording, tx.clone());
}
Data::Close => {
tx_file.send(ClipboardFileData::Enable((conn_id, false))).ok();
@@ -349,6 +352,7 @@ pub async fn start_listen<T: InvokeUiCM>(
audio,
file,
restart,
recording,
..
}) => {
current_id = id;
@@ -364,6 +368,7 @@ pub async fn start_listen<T: InvokeUiCM>(
audio,
file,
restart,
recording,
tx.clone(),
);
}