Connect pipes over Iroh control

This commit is contained in:
Eric Wendland 2026-05-18 18:45:10 +02:00
commit 741bd202a8
8 changed files with 344 additions and 32 deletions

View file

@ -226,6 +226,7 @@ pub enum ControlRequest {
},
PipeConnect {
target: String,
node: Option<String>,
},
ModuleStub {
module: String,
@ -472,6 +473,15 @@ pub enum ControlResponse {
PipeConnected {
connection: PipeConnection,
},
PipeRemoteConnected {
peer_node_id: String,
peer_agent_id: String,
endpoint_id: String,
connection: PipeConnection,
allowed: bool,
reason: String,
note: String,
},
NotImplemented {
module: String,
command: String,
@ -557,6 +567,11 @@ pub enum PeerControlRequest {
message: String,
nonce: String,
},
PipeConnect {
peer_card: PeerCard,
target: String,
nonce: String,
},
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
@ -651,6 +666,18 @@ pub enum PeerControlResponse {
nonce: String,
note: String,
},
PipeConnected {
node_id: String,
agent_id: String,
endpoint_id: String,
remote_endpoint_id: String,
connection: Option<PipeConnection>,
allowed: bool,
reason: String,
evaluated_ops: usize,
nonce: String,
note: String,
},
Error {
message: String,
},
@ -850,6 +877,15 @@ mod tests {
request
);
let request = ControlRequest::PipeConnect {
target: "inbox".to_owned(),
node: Some("node:peer".to_owned()),
};
assert_eq!(
decode_request(&encode_request(&request).expect("encode")).expect("decode"),
request
);
let request = ControlRequest::PubsubPub {
topic: "presence/test".to_owned(),
message: "online".to_owned(),
@ -878,6 +914,25 @@ mod tests {
response
);
let response = ControlResponse::PipeRemoteConnected {
peer_node_id: "node:peer".to_owned(),
peer_agent_id: "agent:peer".to_owned(),
endpoint_id: "endpoint:peer".to_owned(),
connection: PipeConnection {
target: "inbox".to_owned(),
connected_at: geth_types::UnixMillis(1),
local_listener_found: true,
note: "remote".to_owned(),
},
allowed: true,
reason: "direct grant".to_owned(),
note: "pipe connect".to_owned(),
};
assert_eq!(
decode_response(&encode_response(&response).expect("encode")).expect("decode"),
response
);
let request = ControlRequest::DbChanges {
name: "notes".to_owned(),
after_db_version: Some(7),
@ -1068,5 +1123,28 @@ mod tests {
.expect("decode"),
response
);
let response = PeerControlResponse::PipeConnected {
node_id: "node:peer".to_owned(),
agent_id: "agent:peer".to_owned(),
endpoint_id: "endpoint:peer".to_owned(),
remote_endpoint_id: "endpoint:caller".to_owned(),
connection: Some(PipeConnection {
target: "inbox".to_owned(),
connected_at: geth_types::UnixMillis(1),
local_listener_found: true,
note: "remote".to_owned(),
}),
allowed: true,
reason: "direct grant".to_owned(),
evaluated_ops: 1,
nonce: "nonce".to_owned(),
note: "pipe connect".to_owned(),
};
assert_eq!(
decode_peer_response(&encode_peer_response(&response).expect("encode"))
.expect("decode"),
response
);
}
}