api: nodes: rustfmt
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
957133077f
commit
a332040a7f
|
@ -17,8 +17,8 @@ use proxmox::api::{
|
||||||
api, schema::*, ApiHandler, ApiMethod, ApiResponseFuture, Permission, RpcEnvironment,
|
api, schema::*, ApiHandler, ApiMethod, ApiResponseFuture, Permission, RpcEnvironment,
|
||||||
};
|
};
|
||||||
use proxmox::list_subdirs_api_method;
|
use proxmox::list_subdirs_api_method;
|
||||||
use proxmox_http::websocket::WebSocket;
|
|
||||||
use proxmox::{identity, sortable};
|
use proxmox::{identity, sortable};
|
||||||
|
use proxmox_http::websocket::WebSocket;
|
||||||
|
|
||||||
use pbs_api_types::{Authid, NODE_SCHEMA, PRIV_SYS_CONSOLE};
|
use pbs_api_types::{Authid, NODE_SCHEMA, PRIV_SYS_CONSOLE};
|
||||||
use pbs_tools::auth::private_auth_key;
|
use pbs_tools::auth::private_auth_key;
|
||||||
|
@ -33,17 +33,17 @@ pub mod config;
|
||||||
pub mod disks;
|
pub mod disks;
|
||||||
pub mod dns;
|
pub mod dns;
|
||||||
pub mod network;
|
pub mod network;
|
||||||
pub mod tasks;
|
|
||||||
pub mod subscription;
|
pub mod subscription;
|
||||||
|
pub mod tasks;
|
||||||
|
|
||||||
pub(crate) mod rrd;
|
pub(crate) mod rrd;
|
||||||
|
|
||||||
mod journal;
|
mod journal;
|
||||||
|
mod report;
|
||||||
pub(crate) mod services;
|
pub(crate) mod services;
|
||||||
mod status;
|
mod status;
|
||||||
mod syslog;
|
mod syslog;
|
||||||
mod time;
|
mod time;
|
||||||
mod report;
|
|
||||||
|
|
||||||
pub const SHELL_CMD_SCHEMA: Schema = StringSchema::new("The command to run.")
|
pub const SHELL_CMD_SCHEMA: Schema = StringSchema::new("The command to run.")
|
||||||
.format(&ApiStringFormat::Enum(&[
|
.format(&ApiStringFormat::Enum(&[
|
||||||
|
@ -93,10 +93,7 @@ pub const SHELL_CMD_SCHEMA: Schema = StringSchema::new("The command to run.")
|
||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
/// Call termproxy and return shell ticket
|
/// Call termproxy and return shell ticket
|
||||||
async fn termproxy(
|
async fn termproxy(cmd: Option<String>, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||||
cmd: Option<String>,
|
|
||||||
rpcenv: &mut dyn RpcEnvironment,
|
|
||||||
) -> Result<Value, Error> {
|
|
||||||
// intentionally user only for now
|
// intentionally user only for now
|
||||||
let auth_id: Authid = rpcenv
|
let auth_id: Authid = rpcenv
|
||||||
.get_auth_id()
|
.get_auth_id()
|
||||||
|
@ -119,8 +116,7 @@ async fn termproxy(
|
||||||
let listener = TcpListener::bind("localhost:0")?;
|
let listener = TcpListener::bind("localhost:0")?;
|
||||||
let port = listener.local_addr()?.port();
|
let port = listener.local_addr()?.port();
|
||||||
|
|
||||||
let ticket = Ticket::new(ticket::TERM_PREFIX, &Empty)?
|
let ticket = Ticket::new(ticket::TERM_PREFIX, &Empty)?.sign(
|
||||||
.sign(
|
|
||||||
private_auth_key(),
|
private_auth_key(),
|
||||||
Some(&tools::ticket::term_aad(&userid, &path, port)),
|
Some(&tools::ticket::term_aad(&userid, &path, port)),
|
||||||
)?;
|
)?;
|
||||||
|
@ -291,8 +287,7 @@ fn upgrade_to_websocket(
|
||||||
let port: u16 = pbs_tools::json::required_integer_param(¶m, "port")? as u16;
|
let port: u16 = pbs_tools::json::required_integer_param(¶m, "port")? as u16;
|
||||||
|
|
||||||
// will be checked again by termproxy
|
// will be checked again by termproxy
|
||||||
Ticket::<Empty>::parse(ticket)?
|
Ticket::<Empty>::parse(ticket)?.verify(
|
||||||
.verify(
|
|
||||||
crate::auth_helpers::public_auth_key(),
|
crate::auth_helpers::public_auth_key(),
|
||||||
ticket::TERM_PREFIX,
|
ticket::TERM_PREFIX,
|
||||||
Some(&tools::ticket::term_aad(&userid, "/system", port)),
|
Some(&tools::ticket::term_aad(&userid, "/system", port)),
|
||||||
|
@ -301,7 +296,10 @@ fn upgrade_to_websocket(
|
||||||
let (ws, response) = WebSocket::new(parts.headers.clone())?;
|
let (ws, response) = WebSocket::new(parts.headers.clone())?;
|
||||||
|
|
||||||
crate::server::spawn_internal_task(async move {
|
crate::server::spawn_internal_task(async move {
|
||||||
let conn: Upgraded = match hyper::upgrade::on(Request::from_parts(parts, req_body)).map_err(Error::from).await {
|
let conn: Upgraded = match hyper::upgrade::on(Request::from_parts(parts, req_body))
|
||||||
|
.map_err(Error::from)
|
||||||
|
.await
|
||||||
|
{
|
||||||
Ok(upgraded) => upgraded,
|
Ok(upgraded) => upgraded,
|
||||||
_ => bail!("error"),
|
_ => bail!("error"),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue