WayVR: Update IPC, send runtime info, update deps
This commit is contained in:
73
Cargo.lock
generated
73
Cargo.lock
generated
@@ -432,15 +432,6 @@ dependencies = [
|
|||||||
"syn 2.0.89",
|
"syn 2.0.89",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "atomic-polyfill"
|
|
||||||
version = "1.0.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4"
|
|
||||||
dependencies = [
|
|
||||||
"critical-section",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atomic-waker"
|
name = "atomic-waker"
|
||||||
version = "1.1.2"
|
version = "1.1.2"
|
||||||
@@ -912,12 +903,6 @@ dependencies = [
|
|||||||
"cc",
|
"cc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cobs"
|
|
||||||
version = "0.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "codespan-reporting"
|
name = "codespan-reporting"
|
||||||
version = "0.11.1"
|
version = "0.11.1"
|
||||||
@@ -1114,12 +1099,6 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "critical-section"
|
|
||||||
version = "1.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-deque"
|
name = "crossbeam-deque"
|
||||||
version = "0.8.5"
|
version = "0.8.5"
|
||||||
@@ -1832,15 +1811,6 @@ dependencies = [
|
|||||||
"crunchy",
|
"crunchy",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hash32"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67"
|
|
||||||
dependencies = [
|
|
||||||
"byteorder",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.12.3"
|
version = "0.12.3"
|
||||||
@@ -1872,20 +1842,6 @@ dependencies = [
|
|||||||
"hashbrown 0.14.5",
|
"hashbrown 0.14.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "heapless"
|
|
||||||
version = "0.7.17"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f"
|
|
||||||
dependencies = [
|
|
||||||
"atomic-polyfill",
|
|
||||||
"hash32",
|
|
||||||
"rustc_version",
|
|
||||||
"serde",
|
|
||||||
"spin",
|
|
||||||
"stable_deref_trait",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
@@ -3284,17 +3240,6 @@ dependencies = [
|
|||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "postcard"
|
|
||||||
version = "1.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "170a2601f67cc9dba8edd8c4870b15f71a6a2dc196daec8c83f72b59dff628a8"
|
|
||||||
dependencies = [
|
|
||||||
"cobs",
|
|
||||||
"heapless",
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
version = "0.2.20"
|
version = "0.2.20"
|
||||||
@@ -3688,9 +3633,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.133"
|
version = "1.0.135"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377"
|
checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"memchr",
|
"memchr",
|
||||||
@@ -3888,15 +3833,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "spin"
|
|
||||||
version = "0.9.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
|
||||||
dependencies = [
|
|
||||||
"lock_api",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stable_deref_trait"
|
name = "stable_deref_trait"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
@@ -4604,13 +4540,13 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "wayvr_ipc"
|
name = "wayvr_ipc"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/olekolek1000/wayvr-ipc.git?rev=c2a6438ffdcc78ff9c0637d914df1bc673723824#c2a6438ffdcc78ff9c0637d914df1bc673723824"
|
source = "git+https://github.com/olekolek1000/wayvr-ipc.git?rev=b484d1f0607b3f67e2c9e49797819738344bcb5c#b484d1f0607b3f67e2c9e49797819738344bcb5c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bytes",
|
"bytes",
|
||||||
"log",
|
"log",
|
||||||
"postcard",
|
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -5094,7 +5030,6 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
"openxr",
|
"openxr",
|
||||||
"ovr_overlay",
|
"ovr_overlay",
|
||||||
"postcard",
|
|
||||||
"regex",
|
"regex",
|
||||||
"rodio",
|
"rodio",
|
||||||
"rosc",
|
"rosc",
|
||||||
|
|||||||
@@ -84,9 +84,8 @@ uuid = { version = "1.10.0", features = ["v4", "fast-rng"], optional = true }
|
|||||||
wayland-client = { version = "0.31.6", optional = true }
|
wayland-client = { version = "0.31.6", optional = true }
|
||||||
wayland-egl = { version = "0.32.4", optional = true }
|
wayland-egl = { version = "0.32.4", optional = true }
|
||||||
interprocess = { version = "2.2.2", optional = true }
|
interprocess = { version = "2.2.2", optional = true }
|
||||||
postcard = { version = "1.1.1", optional = true }
|
|
||||||
bytes = { version = "1.9.0", optional = true }
|
bytes = { version = "1.9.0", optional = true }
|
||||||
wayvr_ipc = { git = "https://github.com/olekolek1000/wayvr-ipc.git", rev = "c2a6438ffdcc78ff9c0637d914df1bc673723824", default-features = false, optional = true }
|
wayvr_ipc = { git = "https://github.com/olekolek1000/wayvr-ipc.git", rev = "b484d1f0607b3f67e2c9e49797819738344bcb5c", default-features = false, optional = true }
|
||||||
################################
|
################################
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
@@ -109,7 +108,6 @@ wayvr = [
|
|||||||
"dep:wayland-client",
|
"dep:wayland-client",
|
||||||
"dep:wayland-egl",
|
"dep:wayland-egl",
|
||||||
"dep:interprocess",
|
"dep:interprocess",
|
||||||
"dep:postcard",
|
|
||||||
"dep:bytes",
|
"dep:bytes",
|
||||||
"dep:wayvr_ipc",
|
"dep:wayvr_ipc",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -4,16 +4,21 @@ use interprocess::local_socket::{self, traits::Listener, ToNsName};
|
|||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use wayvr_ipc::{
|
use wayvr_ipc::{
|
||||||
ipc::{self, binary_decode, binary_encode},
|
ipc::{self},
|
||||||
packet_client::{self, PacketClient},
|
packet_client::{self, PacketClient},
|
||||||
packet_server::{self, PacketServer},
|
packet_server::{self, PacketServer},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub struct AuthInfo {
|
||||||
|
pub client_name: String,
|
||||||
|
pub protocol_version: u32, // client protocol version
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Connection {
|
pub struct Connection {
|
||||||
alive: bool,
|
alive: bool,
|
||||||
conn: local_socket::Stream,
|
conn: local_socket::Stream,
|
||||||
next_packet: Option<u32>,
|
next_packet: Option<u32>,
|
||||||
handshaking: bool,
|
auth: Option<AuthInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_packet(conn: &mut local_socket::Stream, data: &[u8]) -> anyhow::Result<()> {
|
pub fn send_packet(conn: &mut local_socket::Stream, data: &[u8]) -> anyhow::Result<()> {
|
||||||
@@ -71,7 +76,7 @@ pub fn gen_args_vec(input: &str) -> Vec<&str> {
|
|||||||
input.split_whitespace().collect()
|
input.split_whitespace().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn gen_env_vec(input: &Vec<String>) -> Vec<(&str, &str)> {
|
pub fn gen_env_vec(input: &[String]) -> Vec<(&str, &str)> {
|
||||||
let res = input
|
let res = input
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|e| e.as_str().split_once('='))
|
.filter_map(|e| e.as_str().split_once('='))
|
||||||
@@ -84,19 +89,25 @@ impl Connection {
|
|||||||
Self {
|
Self {
|
||||||
conn,
|
conn,
|
||||||
alive: true,
|
alive: true,
|
||||||
handshaking: true,
|
auth: None,
|
||||||
next_packet: None,
|
next_packet: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn kill(&mut self) {
|
fn kill(&mut self, reason: &str) {
|
||||||
|
let _dont_care = send_packet(
|
||||||
|
&mut self.conn,
|
||||||
|
&ipc::data_encode(&PacketServer::Disconnect(packet_server::Disconnect {
|
||||||
|
reason: String::from(reason),
|
||||||
|
})),
|
||||||
|
);
|
||||||
self.alive = false;
|
self.alive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_handshake(&mut self, payload: Payload) -> anyhow::Result<()> {
|
fn process_handshake(&mut self, handshake: &packet_client::Handshake) -> anyhow::Result<()> {
|
||||||
let Ok(handshake) = binary_decode::<ipc::Handshake>(&payload) else {
|
if self.auth.is_some() {
|
||||||
anyhow::bail!("Invalid handshake");
|
anyhow::bail!("You were already authenticated");
|
||||||
};
|
}
|
||||||
|
|
||||||
if handshake.protocol_version != ipc::PROTOCOL_VERSION {
|
if handshake.protocol_version != ipc::PROTOCOL_VERSION {
|
||||||
anyhow::bail!(
|
anyhow::bail!(
|
||||||
@@ -109,8 +120,29 @@ impl Connection {
|
|||||||
anyhow::bail!("Invalid magic");
|
anyhow::bail!("Invalid magic");
|
||||||
}
|
}
|
||||||
|
|
||||||
log::info!("Accepted new connection");
|
match handshake.client_name.len() {
|
||||||
self.handshaking = false;
|
0 => anyhow::bail!("Client name is empty"),
|
||||||
|
1..32 => {}
|
||||||
|
_ => anyhow::bail!("Client name is too long"),
|
||||||
|
}
|
||||||
|
|
||||||
|
log::info!("IPC: Client \"{}\" connected.", handshake.client_name);
|
||||||
|
|
||||||
|
self.auth = Some(AuthInfo {
|
||||||
|
client_name: handshake.client_name.clone(),
|
||||||
|
protocol_version: handshake.protocol_version,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Send auth response
|
||||||
|
send_packet(
|
||||||
|
&mut self.conn,
|
||||||
|
&ipc::data_encode(&PacketServer::HandshakeSuccess(
|
||||||
|
packet_server::HandshakeSuccess {
|
||||||
|
runtime: String::from("wlx-overlay-s"),
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +168,7 @@ impl Connection {
|
|||||||
|
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.conn,
|
&mut self.conn,
|
||||||
&binary_encode(&PacketServer::WvrDisplayListResponse(
|
&ipc::data_encode(&PacketServer::WvrDisplayListResponse(
|
||||||
serial,
|
serial,
|
||||||
packet_server::WvrDisplayList { list },
|
packet_server::WvrDisplayList { list },
|
||||||
)),
|
)),
|
||||||
@@ -165,7 +197,7 @@ impl Connection {
|
|||||||
|
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.conn,
|
&mut self.conn,
|
||||||
&binary_encode(&PacketServer::WvrDisplayCreateResponse(
|
&ipc::data_encode(&PacketServer::WvrDisplayCreateResponse(
|
||||||
serial,
|
serial,
|
||||||
display_handle.as_packet(),
|
display_handle.as_packet(),
|
||||||
)),
|
)),
|
||||||
@@ -193,7 +225,7 @@ impl Connection {
|
|||||||
|
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.conn,
|
&mut self.conn,
|
||||||
&binary_encode(&PacketServer::WvrProcessLaunchResponse(serial, res)),
|
&ipc::data_encode(&PacketServer::WvrProcessLaunchResponse(serial, res)),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -214,7 +246,7 @@ impl Connection {
|
|||||||
|
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.conn,
|
&mut self.conn,
|
||||||
&binary_encode(&PacketServer::WvrDisplayGetResponse(serial, disp)),
|
&ipc::data_encode(&PacketServer::WvrDisplayGetResponse(serial, disp)),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -242,7 +274,7 @@ impl Connection {
|
|||||||
|
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.conn,
|
&mut self.conn,
|
||||||
&binary_encode(&PacketServer::WvrProcessListResponse(
|
&ipc::data_encode(&PacketServer::WvrProcessListResponse(
|
||||||
serial,
|
serial,
|
||||||
packet_server::WvrProcessList { list },
|
packet_server::WvrProcessList { list },
|
||||||
)),
|
)),
|
||||||
@@ -270,13 +302,15 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn process_payload(&mut self, params: &mut TickParams, payload: Payload) -> anyhow::Result<()> {
|
fn process_payload(&mut self, params: &mut TickParams, payload: Payload) -> anyhow::Result<()> {
|
||||||
if self.handshaking {
|
let packet: PacketClient = ipc::data_decode(&payload)?;
|
||||||
self.process_handshake(payload)?;
|
|
||||||
|
if let PacketClient::Handshake(handshake) = &packet {
|
||||||
|
self.process_handshake(handshake)?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let packet: PacketClient = binary_decode(&payload)?;
|
|
||||||
match packet {
|
match packet {
|
||||||
|
PacketClient::Handshake(_) => unreachable!(), // handled previously
|
||||||
PacketClient::WvrDisplayList(serial) => {
|
PacketClient::WvrDisplayList(serial) => {
|
||||||
self.handle_wvr_display_list(params, serial)?;
|
self.handle_wvr_display_list(params, serial)?;
|
||||||
}
|
}
|
||||||
@@ -305,7 +339,8 @@ impl Connection {
|
|||||||
|
|
||||||
if let Err(e) = self.process_payload(params, payload) {
|
if let Err(e) = self.process_payload(params, payload) {
|
||||||
log::error!("Invalid payload from the client, closing connection: {}", e);
|
log::error!("Invalid payload from the client, closing connection: {}", e);
|
||||||
self.kill();
|
// send also error message directly to the client before disconnecting
|
||||||
|
self.kill(format!("{}", e).as_str());
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
@@ -341,7 +376,7 @@ impl Connection {
|
|||||||
"Client sent a packet header with the size over {} bytes, closing connection.",
|
"Client sent a packet header with the size over {} bytes, closing connection.",
|
||||||
size_limit
|
size_limit
|
||||||
);
|
);
|
||||||
self.kill();
|
self.kill("Too big packet received (over 128 KiB)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user