clean up calls that use Address::try_into() under the hood

This commit is contained in:
hosted-fornet 2024-10-30 15:52:56 -07:00
parent 530b20c5f7
commit 3f6b94076c
10 changed files with 44 additions and 45 deletions

View File

@ -1126,7 +1126,7 @@ async fn check_for_root_cap(
caps_oracle caps_oracle
.send(CapMessage::Has { .send(CapMessage::Has {
on: process.clone(), on: process.clone(),
cap: Capability::new((our, &ETH_PROCESS_ID.clone()), "{\"root\":true}").unwrap(), cap: Capability::new((our, ETH_PROCESS_ID.clone()), "{\"root\":true}").unwrap(),
responder: send_cap_bool, responder: send_cap_bool,
}) })
.await .await

View File

@ -340,7 +340,7 @@ async fn send_all_fds_limits(our_node: &str, send_to_loop: &MessageSender, state
for (process_id, limit) in &state.fds_limits { for (process_id, limit) in &state.fds_limits {
KernelMessage::builder() KernelMessage::builder()
.id(rand::random()) .id(rand::random())
.source((our_node, &FD_MANAGER_PROCESS_ID.clone())) .source((our_node, FD_MANAGER_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target((our_node, process_id)) .target((our_node, process_id))
.unwrap() .unwrap()
@ -386,7 +386,6 @@ async fn send_to_fd_manager(our: &Address, message: Message, send_to_loop: &Mess
.source(our.clone()) .source(our.clone())
.unwrap() .unwrap()
.target((our.node.clone(), FD_MANAGER_PROCESS_ID.clone())) .target((our.node.clone(), FD_MANAGER_PROCESS_ID.clone()))
//.target((our.node.clone(), &FD_MANAGER_PROCESS_ID.clone()))
.unwrap() .unwrap()
.message(message) .message(message)
.build() .build()

View File

@ -931,7 +931,7 @@ async fn maintain_websocket(
KernelMessage::builder() KernelMessage::builder()
.id(rand::random()) .id(rand::random())
.source((&*our, &HTTP_SERVER_PROCESS_ID.clone())) .source((&*our, HTTP_SERVER_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target((&*our, &app)) .target((&*our, &app))
.unwrap() .unwrap()
@ -1017,7 +1017,7 @@ async fn websocket_close(
ws_senders.remove(&channel_id); ws_senders.remove(&channel_id);
KernelMessage::builder() KernelMessage::builder()
.id(rand::random()) .id(rand::random())
.source(("our", &HTTP_SERVER_PROCESS_ID.clone())) .source(("our", HTTP_SERVER_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target(("our", &process)) .target(("our", &process))
.unwrap() .unwrap()
@ -1384,7 +1384,7 @@ pub async fn send_action_response(
) { ) {
KernelMessage::builder() KernelMessage::builder()
.id(id) .id(id)
.source(("our", &HTTP_SERVER_PROCESS_ID.clone())) .source(("our", HTTP_SERVER_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target(target) .target(target)
.unwrap() .unwrap()

View File

@ -44,9 +44,9 @@ enum ProcessSender {
async fn persist_state(send_to_loop: &t::MessageSender, process_map: &t::ProcessMap) { async fn persist_state(send_to_loop: &t::MessageSender, process_map: &t::ProcessMap) {
t::KernelMessage::builder() t::KernelMessage::builder()
.id(rand::random()) .id(rand::random())
.source(("our", &KERNEL_PROCESS_ID.clone())) .source(("our", KERNEL_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target(("our", &STATE_PROCESS_ID.clone())) .target(("our", STATE_PROCESS_ID.clone()))
.unwrap() .unwrap()
.message(t::Message::Request(t::Request { .message(t::Message::Request(t::Request {
inherit: false, inherit: false,
@ -112,7 +112,7 @@ async fn handle_kernel_request(
sender sender
.send(Ok(t::KernelMessage::builder() .send(Ok(t::KernelMessage::builder()
.id(km.id) .id(km.id)
.source((our_name, &KERNEL_PROCESS_ID.clone())) .source((our_name, KERNEL_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target((our_name, process_id)) .target((our_name, process_id))
.unwrap() .unwrap()
@ -148,7 +148,7 @@ async fn handle_kernel_request(
// fire an error back // fire an error back
t::KernelMessage::builder() t::KernelMessage::builder()
.id(km.id) .id(km.id)
.source((our_name, &KERNEL_PROCESS_ID.clone())) .source((our_name, KERNEL_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target(km.rsvp.unwrap_or(km.source)) .target(km.rsvp.unwrap_or(km.source))
.unwrap() .unwrap()
@ -268,7 +268,7 @@ async fn handle_kernel_request(
}; };
t::KernelMessage::builder() t::KernelMessage::builder()
.id(km.id) .id(km.id)
.source(("our", &KERNEL_PROCESS_ID.clone())) .source(("our", KERNEL_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target(km.rsvp.unwrap_or(km.source)) .target(km.rsvp.unwrap_or(km.source))
.unwrap() .unwrap()
@ -324,7 +324,7 @@ async fn handle_kernel_request(
if let Ok(()) = process_sender if let Ok(()) = process_sender
.send(Ok(t::KernelMessage::builder() .send(Ok(t::KernelMessage::builder()
.id(rand::random()) .id(rand::random())
.source((our_name, &KERNEL_PROCESS_ID.clone())) .source((our_name, KERNEL_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target((our_name, &process_id)) .target((our_name, &process_id))
.unwrap() .unwrap()
@ -351,7 +351,7 @@ async fn handle_kernel_request(
}; };
t::KernelMessage::builder() t::KernelMessage::builder()
.id(km.id) .id(km.id)
.source(("our", &KERNEL_PROCESS_ID.clone())) .source(("our", KERNEL_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target(km.rsvp.unwrap_or(km.source)) .target(km.rsvp.unwrap_or(km.source))
.unwrap() .unwrap()
@ -410,7 +410,7 @@ async fn handle_kernel_request(
.await; .await;
t::KernelMessage::builder() t::KernelMessage::builder()
.id(km.id) .id(km.id)
.source(("our", &KERNEL_PROCESS_ID.clone())) .source(("our", KERNEL_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target(km.rsvp.unwrap_or(km.source)) .target(km.rsvp.unwrap_or(km.source))
.unwrap() .unwrap()
@ -450,7 +450,7 @@ async fn handle_kernel_request(
}; };
t::KernelMessage::builder() t::KernelMessage::builder()
.id(km.id) .id(km.id)
.source(("our", &KERNEL_PROCESS_ID.clone())) .source(("our", KERNEL_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target(km.rsvp.unwrap_or(km.source)) .target(km.rsvp.unwrap_or(km.source))
.unwrap() .unwrap()
@ -689,8 +689,8 @@ pub async fn kernel(
// to turn it on // to turn it on
t::KernelMessage::builder() t::KernelMessage::builder()
.id(rand::random()) .id(rand::random())
.source((&our.name, &KERNEL_PROCESS_ID.clone()))? .source((&our.name, KERNEL_PROCESS_ID.clone()))?
.target((&our.name, &KERNEL_PROCESS_ID.clone()))? .target((&our.name, KERNEL_PROCESS_ID.clone()))?
.message(t::Message::Request(t::Request { .message(t::Message::Request(t::Request {
inherit: true, inherit: true,
expects_response: None, expects_response: None,
@ -706,7 +706,7 @@ pub async fn kernel(
// sending hard coded pki entries into networking for bootstrapped rpc // sending hard coded pki entries into networking for bootstrapped rpc
t::KernelMessage::builder() t::KernelMessage::builder()
.id(rand::random()) .id(rand::random())
.source((&our.name, &KERNEL_PROCESS_ID.clone()))? .source((&our.name, KERNEL_PROCESS_ID.clone()))?
.target((our.name.as_str(), "net", "distro", "sys"))? .target((our.name.as_str(), "net", "distro", "sys"))?
.message(t::Message::Request(t::Request { .message(t::Message::Request(t::Request {
inherit: false, inherit: false,
@ -791,7 +791,7 @@ pub async fn kernel(
continue; continue;
}; };
if !proc.capabilities.contains_key( if !proc.capabilities.contains_key(
&t::Capability::new((&our.name, &KERNEL_PROCESS_ID.clone()), "\"network\"")? &t::Capability::new((&our.name, KERNEL_PROCESS_ID.clone()), "\"network\"")?
) { ) {
// capabilities are not correct! skip this message. // capabilities are not correct! skip this message.
t::Printout::new( t::Printout::new(
@ -832,7 +832,7 @@ pub async fn kernel(
continue; continue;
}; };
if !persisted.capabilities.contains_key( if !persisted.capabilities.contains_key(
&t::Capability::new((&our.name, &KERNEL_PROCESS_ID.clone()), "\"network\"")? &t::Capability::new((&our.name, KERNEL_PROCESS_ID.clone()), "\"network\"")?
) { ) {
// capabilities are not correct! skip this message. // capabilities are not correct! skip this message.
t::Printout::new( t::Printout::new(
@ -868,7 +868,7 @@ pub async fn kernel(
}; };
if !persisted_target.public if !persisted_target.public
&& !persisted_source.capabilities.contains_key( && !persisted_source.capabilities.contains_key(
&t::Capability::messaging((&our.name, &kernel_message.target.process.clone()))? &t::Capability::messaging((&our.name, &kernel_message.target.process))?
) { ) {
// capabilities are not correct! skip this message. // capabilities are not correct! skip this message.
t::Printout::new( t::Printout::new(

View File

@ -370,8 +370,8 @@ pub async fn make_process_loop(
t::OnExit::None => { t::OnExit::None => {
t::KernelMessage::builder() t::KernelMessage::builder()
.id(rand::random()) .id(rand::random())
.source((&our.node, &KERNEL_PROCESS_ID.clone()))? .source((&our.node, KERNEL_PROCESS_ID.clone()))?
.target((&our.node, &KERNEL_PROCESS_ID.clone()))? .target((&our.node, KERNEL_PROCESS_ID.clone()))?
.message(t::Message::Request(t::Request { .message(t::Message::Request(t::Request {
inherit: false, inherit: false,
expects_response: None, expects_response: None,
@ -409,8 +409,8 @@ pub async fn make_process_loop(
// kill, **without** revoking capabilities from others! // kill, **without** revoking capabilities from others!
t::KernelMessage::builder() t::KernelMessage::builder()
.id(rand::random()) .id(rand::random())
.source((&our.node, &KERNEL_PROCESS_ID.clone()))? .source((&our.node, KERNEL_PROCESS_ID.clone()))?
.target((&our.node, &KERNEL_PROCESS_ID.clone()))? .target((&our.node, KERNEL_PROCESS_ID.clone()))?
.message(t::Message::Request(t::Request { .message(t::Message::Request(t::Request {
inherit: false, inherit: false,
expects_response: None, expects_response: None,
@ -428,8 +428,8 @@ pub async fn make_process_loop(
// then re-initialize with same capabilities // then re-initialize with same capabilities
t::KernelMessage::builder() t::KernelMessage::builder()
.id(rand::random()) .id(rand::random())
.source((&our.node, &KERNEL_PROCESS_ID.clone()))? .source((&our.node, KERNEL_PROCESS_ID.clone()))?
.target((&our.node, &KERNEL_PROCESS_ID.clone()))? .target((&our.node, KERNEL_PROCESS_ID.clone()))?
.message(t::Message::Request(t::Request { .message(t::Message::Request(t::Request {
inherit: false, inherit: false,
expects_response: None, expects_response: None,
@ -456,8 +456,8 @@ pub async fn make_process_loop(
// then run // then run
t::KernelMessage::builder() t::KernelMessage::builder()
.id(rand::random()) .id(rand::random())
.source((&our.node, &KERNEL_PROCESS_ID.clone()))? .source((&our.node, KERNEL_PROCESS_ID.clone()))?
.target((&our.node, &KERNEL_PROCESS_ID.clone()))? .target((&our.node, KERNEL_PROCESS_ID.clone()))?
.message(t::Message::Request(t::Request { .message(t::Message::Request(t::Request {
inherit: false, inherit: false,
expects_response: None, expects_response: None,
@ -491,8 +491,8 @@ pub async fn make_process_loop(
} }
t::KernelMessage::builder() t::KernelMessage::builder()
.id(rand::random()) .id(rand::random())
.source((&our.node, &KERNEL_PROCESS_ID.clone()))? .source((&our.node, KERNEL_PROCESS_ID.clone()))?
.target((&our.node, &KERNEL_PROCESS_ID.clone()))? .target((&our.node, KERNEL_PROCESS_ID.clone()))?
.message(t::Message::Request(t::Request { .message(t::Message::Request(t::Request {
inherit: false, inherit: false,
expects_response: None, expects_response: None,

View File

@ -482,9 +482,9 @@ async fn main() {
Ok(()) => { Ok(()) => {
KernelMessage::builder() KernelMessage::builder()
.id(rand::random()) .id(rand::random())
.source((our.name.as_str(), &KERNEL_PROCESS_ID.clone())) .source((our.name.as_str(), KERNEL_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target((our.name.as_str(), &KERNEL_PROCESS_ID.clone())) .target((our.name.as_str(), KERNEL_PROCESS_ID.clone()))
.unwrap() .unwrap()
.message(Message::Request(Request { .message(Message::Request(Request {
inherit: false, inherit: false,

View File

@ -153,7 +153,7 @@ pub async fn state_sender(
{ {
KernelMessage::builder() KernelMessage::builder()
.id(km_id) .id(km_id)
.source((our_node.as_str(), &STATE_PROCESS_ID.clone())) .source((our_node.as_str(), STATE_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target(km_rsvp) .target(km_rsvp)
.unwrap() .unwrap()
@ -290,7 +290,7 @@ async fn handle_request(
if let Some(target) = rsvp.or_else(|| expects_response.map(|_| source)) { if let Some(target) = rsvp.or_else(|| expects_response.map(|_| source)) {
KernelMessage::builder() KernelMessage::builder()
.id(id) .id(id)
.source((our_node, &STATE_PROCESS_ID.clone())) .source((our_node, STATE_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target(target) .target(target)
.unwrap() .unwrap()

View File

@ -837,8 +837,8 @@ async fn handle_key_event(
command_history.add(command.to_string()); command_history.add(command.to_string());
KernelMessage::builder() KernelMessage::builder()
.id(rand::random()) .id(rand::random())
.source((our.name.as_str(), &TERMINAL_PROCESS_ID.clone()))? .source((our.name.as_str(), TERMINAL_PROCESS_ID.clone()))?
.target((our.name.as_str(), &TERMINAL_PROCESS_ID.clone()))? .target((our.name.as_str(), TERMINAL_PROCESS_ID.clone()))?
.message(Message::Request(Request { .message(Message::Request(Request {
inherit: false, inherit: false,
expects_response: None, expects_response: None,

View File

@ -82,7 +82,7 @@ pub async fn timer_service(
if timer_millis == 0 { if timer_millis == 0 {
KernelMessage::builder() KernelMessage::builder()
.id(km.id) .id(km.id)
.source((our.as_str(), &TIMER_PROCESS_ID.clone()))? .source((our.as_str(), TIMER_PROCESS_ID.clone()))?
.target(km.rsvp.unwrap_or(km.source))? .target(km.rsvp.unwrap_or(km.source))?
.message(Message::Response(( .message(Message::Response((
Response { Response {
@ -116,7 +116,7 @@ pub async fn timer_service(
for (id, addr) in timers { for (id, addr) in timers {
KernelMessage::builder() KernelMessage::builder()
.id(id) .id(id)
.source((our.as_str(), &TIMER_PROCESS_ID.clone()))? .source((our.as_str(), TIMER_PROCESS_ID.clone()))?
.target(addr)? .target(addr)?
.message(Message::Response(( .message(Message::Response((
Response { Response {

View File

@ -50,7 +50,7 @@ pub async fn vfs(
let vfs_path = Arc::new(fs::canonicalize(&vfs_path).await?); let vfs_path = Arc::new(fs::canonicalize(&vfs_path).await?);
let mut files = Files::new( let mut files = Files::new(
Address::try_new(our_node.as_str(), &VFS_PROCESS_ID.clone())?, Address::try_new(our_node.as_str(), VFS_PROCESS_ID.clone())?,
send_to_loop, send_to_loop,
); );
@ -112,7 +112,7 @@ pub async fn vfs(
{ {
KernelMessage::builder() KernelMessage::builder()
.id(km_id) .id(km_id)
.source((our_node.as_str(), &VFS_PROCESS_ID.clone())) .source((our_node.as_str(), VFS_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target(km_rsvp) .target(km_rsvp)
.unwrap() .unwrap()
@ -319,7 +319,7 @@ async fn handle_request(
KernelMessage::builder() KernelMessage::builder()
.id(km.id) .id(km.id)
.source((our_node, &VFS_PROCESS_ID.clone())) .source((our_node, VFS_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target(km.source) .target(km.source)
.unwrap() .unwrap()
@ -647,7 +647,7 @@ async fn handle_request(
if let Some(target) = km.rsvp.or_else(|| expects_response.map(|_| km.source)) { if let Some(target) = km.rsvp.or_else(|| expects_response.map(|_| km.source)) {
KernelMessage::builder() KernelMessage::builder()
.id(km.id) .id(km.id)
.source((our_node, &VFS_PROCESS_ID.clone())) .source((our_node, VFS_PROCESS_ID.clone()))
.unwrap() .unwrap()
.target(target) .target(target)
.unwrap() .unwrap()
@ -925,7 +925,7 @@ async fn read_capability(
) -> bool { ) -> bool {
let (send_cap_bool, recv_cap_bool) = tokio::sync::oneshot::channel(); let (send_cap_bool, recv_cap_bool) = tokio::sync::oneshot::channel();
let cap = Capability::new( let cap = Capability::new(
(our_node, &VFS_PROCESS_ID.clone()), (our_node, VFS_PROCESS_ID.clone()),
if root { if root {
"{\"root\":true}".to_string() "{\"root\":true}".to_string()
} else { } else {
@ -954,7 +954,7 @@ async fn add_capability(
send_to_caps_oracle: &CapMessageSender, send_to_caps_oracle: &CapMessageSender,
) -> Result<(), VfsError> { ) -> Result<(), VfsError> {
let cap = Capability::new( let cap = Capability::new(
(our_node, &VFS_PROCESS_ID.clone()), (our_node, VFS_PROCESS_ID.clone()),
format!("{{\"kind\": \"{kind}\", \"drive\": \"{drive}\"}}"), format!("{{\"kind\": \"{kind}\", \"drive\": \"{drive}\"}}"),
) )
.unwrap(); .unwrap();