Skip to content

Commit

Permalink
improved for webOS 1.x TV/emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Oct 5, 2023
1 parent 3062620 commit c1c71e8
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 13 deletions.
6 changes: 2 additions & 4 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,7 @@ default = ["custom-protocol"]
# DO NOT remove this
custom-protocol = ["tauri/custom-protocol"]
vendored-openssl = ["libssh-rs-sys/vendored-openssl", "reqwest/native-tls-vendored"]

[patch.crates-io]
libssh-rs = { git = "https://github.com/mariotaku/libssh-rs.git", branch = "feature/more-auth-options" }
libssh-rs-sys = { git = "https://github.com/mariotaku/libssh-rs.git", branch = "feature/more-auth-options" }
40 changes: 37 additions & 3 deletions src-tauri/src/conn_pool/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::ops::{Deref, DerefMut};
use std::sync::Mutex;
use std::time::Duration;

use libssh_rs::{AuthStatus, Session, SshKey, SshOption};
use libssh_rs::{AuthStatus, LogLevel, Session, SshKey, SshOption};
use tauri::regex::Regex;
use uuid::Uuid;

Expand All @@ -14,13 +14,47 @@ use crate::error::Error;

impl DeviceConnection {
pub(crate) fn new(device: Device) -> Result<DeviceConnection, Error> {
let kex = vec![
"curve25519-sha256",
"curve25519-sha256@libssh.org",
"ecdh-sha2-nistp256",
"ecdh-sha2-nistp384",
"ecdh-sha2-nistp521",
"diffie-hellman-group18-sha512",
"diffie-hellman-group16-sha512",
"diffie-hellman-group-exchange-sha256",
"diffie-hellman-group14-sha256",
"diffie-hellman-group1-sha1",
"diffie-hellman-group14-sha1",
];
let hmac = vec![
"hmac-sha2-256-etm@openssh.com",
"hmac-sha2-512-etm@openssh.com",
"hmac-sha2-256",
"hmac-sha2-512",
"hmac-sha1-96",
"hmac-sha1",
"hmac-md5",
];
let key_types = vec![
"ssh-ed25519",
"ecdsa-sha2-nistp521",
"ecdsa-sha2-nistp384",
"ecdsa-sha2-nistp256",
"rsa-sha2-512",
"rsa-sha2-256",
"ssh-rsa",
];
let session = Session::new()?;
session.set_option(SshOption::Timeout(Duration::from_secs(10)))?;
session.set_option(SshOption::Hostname(device.host.clone()))?;
session.set_option(SshOption::Port(device.port.clone()))?;
session.set_option(SshOption::User(Some(device.username.clone())))?;
session.set_option(SshOption::HostKeys(format!("ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa")))?;
session.set_option(SshOption::PublicKeyAcceptedTypes(format!("ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa")))?;
session.set_option(SshOption::KeyExchange(kex.join(",")))?;
session.set_option(SshOption::HmacCS(hmac.join(",")))?;
session.set_option(SshOption::HmacSC(hmac.join(",")))?;
session.set_option(SshOption::HostKeys(key_types.join(",")))?;
session.set_option(SshOption::PublicKeyAcceptedTypes(key_types.join(",")))?;
session.set_option(SshOption::ProcessConfig(false))?;
#[cfg(windows)]
{
Expand Down
10 changes: 8 additions & 2 deletions src/app/core/services/app-manager.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Injectable} from '@angular/core';
import {BehaviorSubject, catchError, firstValueFrom, lastValueFrom, mergeMap, noop, Observable, Subject} from 'rxjs';
import {Device, PackageInfo, RawPackageInfo} from '../../types';
import {LunaResponse, LunaResponseError, RemoteLunaService} from "./remote-luna.service";
import {LunaResponse, LunaResponseError, LunaUnknownMethodError, RemoteLunaService} from "./remote-luna.service";
import {escapeSingleQuoteString, RemoteCommandService} from "./remote-command.service";
import {filter, map} from "rxjs/operators";
import * as path from "path";
Expand Down Expand Up @@ -44,6 +44,12 @@ export class AppManagerService {

async list(device: Device): Promise<PackageInfo[]> {
return this.luna.call(device, 'luna://com.webos.applicationManager/dev/listApps')
.catch((e) => {
if (e instanceof LunaUnknownMethodError) {
return this.luna.call(device, 'luna://com.webos.applicationManager/listApps', undefined, false);
}
throw e;
})
.then(resp => resp['apps'] as RawPackageInfo[])
.then((result) => Promise.all(result.map(item => this.completeIcon(device, item))));
}
Expand Down Expand Up @@ -142,7 +148,7 @@ export class AppManagerService {
await this.file.put(device, path, location);
break;
default:
await this.cmd.exec(device, `curl -sL ${escapeSingleQuoteString(location)} --output ${escapeSingleQuoteString(path)}`);
await this.cmd.exec(device, `curl -ksL ${escapeSingleQuoteString(location)} --output ${escapeSingleQuoteString(path)}`);
break;
}
return path;
Expand Down
4 changes: 1 addition & 3 deletions src/app/core/services/device-manager.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ export class DeviceManagerService extends BackendClient {
const param: Record<string, any> = {
path: tmpPath,
method: method,
format: "PNG",
width: 1920,
height: 1080
format: "PNG"
};
await (this.luna.call(device, 'luna://com.webos.service.capture/executeOneShot', param, false)
.catch((e) => {
Expand Down
9 changes: 9 additions & 0 deletions src/app/core/services/remote-luna.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export class RemoteLunaService {
throw new Error(`Bad response ${out}`);
}
if (typed.returnValue === false) {
if (typed['errorText']?.startsWith('Unknown method')) {
throw new LunaUnknownMethodError(typed);
}
throw new LunaResponseError(typed);
}
return typed;
Expand Down Expand Up @@ -134,3 +137,9 @@ export class LunaResponseError extends Error {
}

}

export class LunaUnknownMethodError extends LunaResponseError {
constructor(payload: Record<string, any>) {
super(payload);
}
}
2 changes: 1 addition & 1 deletion src/app/debug/pmlog/pmlog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class PmLogComponent {
const info = await this.deviceManager.getSystemInfo(device);
if (semver.satisfies(info.sdkVersion || '', '>=4.0')) {
await this.luna.call(device, 'luna://com.webos.service.config/setConfigs', {configs: {"system.collectDevLogs": true}}, false);
} else {
} else if (semver.satisfies(info.sdkVersion || '', '>=2.0')) {
await this.luna.call(device, 'luna://com.webos.pmlogd/setdevlogstatus', {recordDevLogs: true}, false);
}
return this.log.logread(device, LogReaderComponent.retainLogs);
Expand Down

0 comments on commit c1c71e8

Please sign in to comment.