feat: rename ALPN prefix from alknet/ to alk/ (v0.1.1)
- CHANNELS_ALPN: b"alknet/channels" → b"alk/channels" - CallAdapter::alpn(): b"alknet/call" → b"alk/call" - derive_alpn_from_op_name: alknet/ prefix → alk/ prefix - All ALPN string literals in src/ and docs/ updated - ADR-004 amended with prefix rename rationale - AGENTS.md, README.md updated - Version bumped to 0.1.1 Review: docs/reviews/003-alpn-prefix-rename.md Verification: - cargo test: 542 passed, 0 failed - cargo clippy --all-targets -- -D warnings: clean - cargo fmt --check: clean - cargo doc --no-deps: clean
This commit is contained in:
1 parent
3cce1410c4
commit
08e7df2aa0
60 files changed
+837
-328
No files matched your search
+19
-19
@@ -1,5 +1,5 @@
|
||||
//! `ChannelsAdapter` — implements `ProtocolHandler` for
|
||||
//! `alknet/channels` (ADR-039). The accept path: receive one
|
||||
//! `alk/channels` (ADR-039). The accept path: receive one
|
||||
//! `Connection`, install channel 0, then run the demux loop — read
|
||||
//! 8-byte chunk headers off the bidi stream and route each chunk's
|
||||
//! payload to the matching `channel_id`'s reassembly buffer.
|
||||
@@ -12,7 +12,7 @@
|
||||
//! The wire format and demux loop are correct for both substrates;
|
||||
//! only the outer `accept_bi()` loop is missing.
|
||||
//!
|
||||
//! Channel 0 is pre-negotiated as `alknet/call` (ADR-036). The
|
||||
//! Channel 0 is pre-negotiated as `alk/call` (ADR-036). The
|
||||
//! `install_channel_zero` hook (ADR-036 amendment — single-stream call
|
||||
//! mode) receives channel 0's `Connection` (already constructed by the
|
||||
//! adapter from the reassembled read half + the mux write half) and
|
||||
@@ -37,7 +37,7 @@ use super::policy::ChannelLifecyclePolicy;
|
||||
use super::wire::CHUNK_HEADER_LEN;
|
||||
|
||||
/// The ALPN the `ChannelsAdapter` registers on.
|
||||
pub const CHANNELS_ALPN: &[u8] = b"alknet/channels";
|
||||
pub const CHANNELS_ALPN: &[u8] = b"alk/channels";
|
||||
|
||||
/// The hook for `channels-call` to install the `CallAdapter` on
|
||||
/// channel 0 (ADR-036 amendment — single-stream call mode). The
|
||||
@@ -46,7 +46,7 @@ pub const CHANNELS_ALPN: &[u8] = b"alknet/channels";
|
||||
/// runs the call dispatch loop on it.
|
||||
///
|
||||
/// The callback receives channel 0's `Connection` (carrying the
|
||||
/// `alknet/call` ALPN) and the `AuthContext` (so the call dispatch
|
||||
/// `alk/call` ALPN) and the `AuthContext` (so the call dispatch
|
||||
/// loop can resolve the peer's identity). The `ChannelManager` is
|
||||
/// accessible via the connection's `BidiStreamSource` (the channel-0
|
||||
/// source closes over it), so the hook does not need it as a separate
|
||||
@@ -56,7 +56,7 @@ pub type InstallChannelZero = Arc<
|
||||
dyn Fn(ChannelManager, Connection, AuthContext) -> tokio::task::JoinHandle<()> + Send + Sync,
|
||||
>;
|
||||
|
||||
/// `ChannelsAdapter` — the `ProtocolHandler` for `alknet/channels`.
|
||||
/// `ChannelsAdapter` — the `ProtocolHandler` for `alk/channels`.
|
||||
/// Its `handle()` receives one `Connection`, installs channel 0 via
|
||||
/// the `install_channel_zero` hook, then runs the demux loop.
|
||||
pub struct ChannelsAdapter {
|
||||
@@ -231,7 +231,7 @@ impl ProtocolHandler for ChannelsAdapter {
|
||||
}
|
||||
});
|
||||
|
||||
// Channel 0 is pre-negotiated as `alknet/call` (ADR-036); the
|
||||
// Channel 0 is pre-negotiated as `alk/call` (ADR-036); the
|
||||
// `install_channel_zero` hook runs the single-stream call
|
||||
// dispatch loop on channel 0's `Connection`.
|
||||
let (channel0_send, channel0_recv) = manager
|
||||
@@ -240,7 +240,7 @@ impl ProtocolHandler for ChannelsAdapter {
|
||||
.map_err(|e| HandlerError::Internal(format!("channel 0 install failed: {e}").into()))?;
|
||||
let channel0_source =
|
||||
super::source::channel_source(channel0_recv, channel0_send, connection.remote_addr());
|
||||
let channel0_conn = Connection::from_source(channel0_source, b"alknet/call".to_vec());
|
||||
let channel0_conn = Connection::from_source(channel0_source, b"alk/call".to_vec());
|
||||
let _handler_task =
|
||||
(self.install_channel_zero)(manager.clone(), channel0_conn, auth.clone());
|
||||
|
||||
@@ -264,7 +264,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn channels_alpn_is_alknet_channels() {
|
||||
assert_eq!(CHANNELS_ALPN, b"alknet/channels");
|
||||
assert_eq!(CHANNELS_ALPN, b"alk/channels");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -276,7 +276,7 @@ mod tests {
|
||||
});
|
||||
let policy = crate::channels::policy::default_policy();
|
||||
let adapter = ChannelsAdapter::new(install, policy);
|
||||
assert_eq!(adapter.alpn(), b"alknet/channels");
|
||||
assert_eq!(adapter.alpn(), b"alk/channels");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -288,13 +288,13 @@ mod tests {
|
||||
});
|
||||
let policy = crate::channels::policy::default_policy();
|
||||
let adapter = ChannelsAdapter::with_limits(install, 128, 32, policy);
|
||||
assert_eq!(adapter.alpn(), b"alknet/channels");
|
||||
assert_eq!(adapter.alpn(), b"alk/channels");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn handle_installs_channel_zero_and_runs_demux_loop() {
|
||||
let (client, server) = tokio::io::duplex(64 * 1024);
|
||||
let conn = Connection::from_bidi(server, b"alknet/channels".to_vec(), None);
|
||||
let conn = Connection::from_bidi(server, b"alk/channels".to_vec(), None);
|
||||
|
||||
let installed = Arc::new(AtomicBool::new(false));
|
||||
let installed_clone = Arc::clone(&installed);
|
||||
@@ -307,7 +307,7 @@ mod tests {
|
||||
let policy = crate::channels::policy::default_policy();
|
||||
let adapter = ChannelsAdapter::new(install_channel_zero, policy);
|
||||
|
||||
let auth = AuthContext::anonymous(b"alknet/channels");
|
||||
let auth = AuthContext::anonymous(b"alk/channels");
|
||||
|
||||
let handle_task = tokio::spawn(async move { adapter.handle(conn, &auth).await });
|
||||
|
||||
@@ -330,7 +330,7 @@ mod tests {
|
||||
#[tokio::test]
|
||||
async fn handle_demux_loop_processes_frames() {
|
||||
let (client, server) = tokio::io::duplex(64 * 1024);
|
||||
let conn = Connection::from_bidi(server, b"alknet/channels".to_vec(), None);
|
||||
let conn = Connection::from_bidi(server, b"alk/channels".to_vec(), None);
|
||||
|
||||
let installed = Arc::new(AtomicBool::new(false));
|
||||
let installed_clone = Arc::clone(&installed);
|
||||
@@ -343,7 +343,7 @@ mod tests {
|
||||
let policy = crate::channels::policy::default_policy();
|
||||
let adapter = ChannelsAdapter::new(install_channel_zero, policy);
|
||||
|
||||
let auth = AuthContext::anonymous(b"alknet/channels");
|
||||
let auth = AuthContext::anonymous(b"alk/channels");
|
||||
|
||||
let handle_task = tokio::spawn(async move { adapter.handle(conn, &auth).await });
|
||||
|
||||
@@ -392,7 +392,7 @@ mod tests {
|
||||
fn close(&self, _code: u32, _reason: &str) {}
|
||||
}
|
||||
|
||||
let conn = Connection::from_source(ClosedSource, b"alknet/channels".to_vec());
|
||||
let conn = Connection::from_source(ClosedSource, b"alk/channels".to_vec());
|
||||
|
||||
let installed = Arc::new(AtomicBool::new(false));
|
||||
let install: InstallChannelZero = Arc::new(move |_m, _c, _a| {
|
||||
@@ -401,7 +401,7 @@ mod tests {
|
||||
});
|
||||
let policy = crate::channels::policy::default_policy();
|
||||
let adapter = ChannelsAdapter::new(install, policy);
|
||||
let auth = AuthContext::anonymous(b"alknet/channels");
|
||||
let auth = AuthContext::anonymous(b"alk/channels");
|
||||
|
||||
let result = adapter.handle(conn, &auth).await;
|
||||
match result {
|
||||
@@ -425,7 +425,7 @@ mod tests {
|
||||
let manager = ChannelManager::with_defaults(mux_handle, None);
|
||||
|
||||
let (id, _send, mut recv) = manager
|
||||
.open_channel("alknet/tty", "alice", None)
|
||||
.open_channel("alk/tty", "alice", None)
|
||||
.await
|
||||
.expect("open");
|
||||
|
||||
@@ -480,11 +480,11 @@ mod tests {
|
||||
let manager = ChannelManager::with_defaults(mux_handle, None);
|
||||
|
||||
let (id_a, _send_a, mut recv_a) = manager
|
||||
.open_channel("alknet/a", "alice", None)
|
||||
.open_channel("alk/a", "alice", None)
|
||||
.await
|
||||
.expect("open a");
|
||||
let (id_b, _send_b, mut recv_b) = manager
|
||||
.open_channel("alknet/b", "bob", None)
|
||||
.open_channel("alk/b", "bob", None)
|
||||
.await
|
||||
.expect("open b");
|
||||
|
||||
|
||||
+31
-31
@@ -37,7 +37,7 @@ use super::reassembly::{MpscRecvStream, MpscSendStream};
|
||||
/// and the `CallConnection` (for calling open ops on channel 0).
|
||||
///
|
||||
/// The consumer dials the transport and establishes the
|
||||
/// `alknet/channels` ALPN, then hands the `Connection` to
|
||||
/// `alk/channels` ALPN, then hands the `Connection` to
|
||||
/// `from_connection`. The client runs the demux/mux in spawned tasks
|
||||
/// and exposes `open_channel` to call the per-ALPN open ops
|
||||
/// (`channels/<alpn>/sub`, `channels/<alpn>/pub`) on channel 0.
|
||||
@@ -48,8 +48,8 @@ pub struct ChannelClient {
|
||||
|
||||
impl ChannelClient {
|
||||
/// Construct from an established `Connection` (the consumer dials
|
||||
/// the transport and establishes the `alknet/channels` ALPN).
|
||||
/// Installs channel 0 (pre-negotiated as `alknet/call`,
|
||||
/// the transport and establishes the `alk/channels` ALPN).
|
||||
/// Installs channel 0 (pre-negotiated as `alk/call`,
|
||||
/// ADR-036), wraps it as a `CallConnection` in single-stream call
|
||||
/// mode (ADR-036 amendment), spawns the demux and mux tasks, and
|
||||
/// returns the client.
|
||||
@@ -93,7 +93,7 @@ impl ChannelClient {
|
||||
// (for `call.requested`) and a read pump (for responses).
|
||||
let channel0_source =
|
||||
super::source::channel_source(channel0_recv, channel0_send, remote_addr);
|
||||
let channel0_conn = Connection::from_source(channel0_source, b"alknet/call".to_vec());
|
||||
let channel0_conn = Connection::from_source(channel0_source, b"alk/call".to_vec());
|
||||
let channel0_bidi = channel0_conn.accept_bi().await?;
|
||||
let (single_stream_writer, single_stream_reader) =
|
||||
crate::protocol::connection::split_single_stream(channel0_bidi);
|
||||
@@ -165,7 +165,7 @@ impl ChannelClient {
|
||||
/// `Connection` from these via `channel_source` and
|
||||
/// `Connection::from_source`.
|
||||
///
|
||||
/// `alpn` is the data-plane ALPN (e.g. `alknet/tty`), used for
|
||||
/// `alpn` is the data-plane ALPN (e.g. `alk/tty`), used for
|
||||
/// observability in the local manager.
|
||||
pub async fn open_channel(
|
||||
&self,
|
||||
@@ -346,15 +346,15 @@ mod tests {
|
||||
|
||||
let (client_end, server_end) = tokio::io::duplex(64 * 1024);
|
||||
let client_conn =
|
||||
Connection::from_bidi(client_end, b"alknet/channels".to_vec(), Some(TEST_ADDR));
|
||||
Connection::from_bidi(client_end, b"alk/channels".to_vec(), Some(TEST_ADDR));
|
||||
let server_conn =
|
||||
Connection::from_bidi(server_end, b"alknet/channels".to_vec(), Some(TEST_ADDR));
|
||||
Connection::from_bidi(server_end, b"alk/channels".to_vec(), Some(TEST_ADDR));
|
||||
|
||||
let adapter = ChannelsAdapter::new(
|
||||
make_install_channel_zero(Arc::clone(®istry)),
|
||||
Arc::new(NoCap),
|
||||
);
|
||||
let auth = AuthContext::anonymous(b"alknet/channels");
|
||||
let auth = AuthContext::anonymous(b"alk/channels");
|
||||
let _server_handle = tokio::spawn(async move {
|
||||
let _ = crate::core::types::ProtocolHandler::handle(&adapter, server_conn, &auth).await;
|
||||
});
|
||||
@@ -388,15 +388,15 @@ mod tests {
|
||||
|
||||
let (client_end, server_end) = tokio::io::duplex(64 * 1024);
|
||||
let client_conn =
|
||||
Connection::from_bidi(client_end, b"alknet/channels".to_vec(), Some(TEST_ADDR));
|
||||
Connection::from_bidi(client_end, b"alk/channels".to_vec(), Some(TEST_ADDR));
|
||||
let server_conn =
|
||||
Connection::from_bidi(server_end, b"alknet/channels".to_vec(), Some(TEST_ADDR));
|
||||
Connection::from_bidi(server_end, b"alk/channels".to_vec(), Some(TEST_ADDR));
|
||||
|
||||
let adapter = ChannelsAdapter::new(
|
||||
make_install_channel_zero(Arc::clone(®istry)),
|
||||
Arc::new(NoCap),
|
||||
);
|
||||
let auth = AuthContext::anonymous(b"alknet/channels");
|
||||
let auth = AuthContext::anonymous(b"alk/channels");
|
||||
let _server_handle = tokio::spawn(async move {
|
||||
let _ = crate::core::types::ProtocolHandler::handle(&adapter, server_conn, &auth).await;
|
||||
});
|
||||
@@ -471,15 +471,15 @@ mod tests {
|
||||
|
||||
let (client_end, server_end) = tokio::io::duplex(64 * 1024);
|
||||
let client_conn =
|
||||
Connection::from_bidi(client_end, b"alknet/channels".to_vec(), Some(TEST_ADDR));
|
||||
Connection::from_bidi(client_end, b"alk/channels".to_vec(), Some(TEST_ADDR));
|
||||
let server_conn =
|
||||
Connection::from_bidi(server_end, b"alknet/channels".to_vec(), Some(TEST_ADDR));
|
||||
Connection::from_bidi(server_end, b"alk/channels".to_vec(), Some(TEST_ADDR));
|
||||
|
||||
let adapter = ChannelsAdapter::new(
|
||||
make_install_channel_zero(Arc::clone(®istry)),
|
||||
Arc::new(NoCap),
|
||||
);
|
||||
let auth = AuthContext::anonymous(b"alknet/channels");
|
||||
let auth = AuthContext::anonymous(b"alk/channels");
|
||||
let _server_handle = tokio::spawn(async move {
|
||||
let _ = crate::core::types::ProtocolHandler::handle(&adapter, server_conn, &auth).await;
|
||||
});
|
||||
@@ -584,15 +584,15 @@ mod tests {
|
||||
|
||||
let (client_end, server_end) = tokio::io::duplex(64 * 1024);
|
||||
let client_conn =
|
||||
Connection::from_bidi(client_end, b"alknet/channels".to_vec(), Some(TEST_ADDR));
|
||||
Connection::from_bidi(client_end, b"alk/channels".to_vec(), Some(TEST_ADDR));
|
||||
let server_conn =
|
||||
Connection::from_bidi(server_end, b"alknet/channels".to_vec(), Some(TEST_ADDR));
|
||||
Connection::from_bidi(server_end, b"alk/channels".to_vec(), Some(TEST_ADDR));
|
||||
|
||||
let adapter = ChannelsAdapter::new(
|
||||
make_install_channel_zero(Arc::clone(®istry)),
|
||||
Arc::new(NoCap),
|
||||
);
|
||||
let auth = AuthContext::anonymous(b"alknet/channels");
|
||||
let auth = AuthContext::anonymous(b"alk/channels");
|
||||
let _server_handle = tokio::spawn(async move {
|
||||
let _ = crate::core::types::ProtocolHandler::handle(&adapter, server_conn, &auth).await;
|
||||
});
|
||||
@@ -819,7 +819,7 @@ mod tests {
|
||||
AccessControl::default(),
|
||||
None,
|
||||
)
|
||||
.with_channel_open(ChannelOpenSpec::new("alknet/tty"));
|
||||
.with_channel_open(ChannelOpenSpec::new("alk/tty"));
|
||||
core.register_openable(
|
||||
spec,
|
||||
Arc::clone(&open_handler),
|
||||
@@ -842,12 +842,12 @@ mod tests {
|
||||
|
||||
let (client_end, server_end) = tokio::io::duplex(64 * 1024);
|
||||
let client_conn =
|
||||
Connection::from_bidi(client_end, b"alknet/channels".to_vec(), Some(TEST_ADDR));
|
||||
Connection::from_bidi(client_end, b"alk/channels".to_vec(), Some(TEST_ADDR));
|
||||
let server_conn =
|
||||
Connection::from_bidi(server_end, b"alknet/channels".to_vec(), Some(TEST_ADDR));
|
||||
Connection::from_bidi(server_end, b"alk/channels".to_vec(), Some(TEST_ADDR));
|
||||
|
||||
let adapter = ChannelsAdapter::new(install_hook, Arc::new(NoCap));
|
||||
let auth = AuthContext::anonymous(b"alknet/channels");
|
||||
let auth = AuthContext::anonymous(b"alk/channels");
|
||||
let _server_handle = tokio::spawn(async move {
|
||||
let _ = crate::core::types::ProtocolHandler::handle(&adapter, server_conn, &auth).await;
|
||||
});
|
||||
@@ -926,12 +926,12 @@ mod tests {
|
||||
|
||||
assert!(dyn_policy.check_open(&alice).is_ok());
|
||||
manager
|
||||
.open_channel("alknet/tty", "alice", None)
|
||||
.open_channel("alk/tty", "alice", None)
|
||||
.await
|
||||
.expect("open alice");
|
||||
assert!(dyn_policy.check_open(&bob).is_ok());
|
||||
manager
|
||||
.open_channel("alknet/tty", "bob", None)
|
||||
.open_channel("alk/tty", "bob", None)
|
||||
.await
|
||||
.expect("open bob");
|
||||
|
||||
@@ -988,9 +988,9 @@ mod tests {
|
||||
let m3 = Arc::clone(&manager);
|
||||
|
||||
let (r1, r2, r3) = tokio::join!(
|
||||
m1.open_channel("alknet/a", "alice", None),
|
||||
m2.open_channel("alknet/b", "bob", None),
|
||||
m3.open_channel("alknet/c", "carol", None),
|
||||
m1.open_channel("alk/a", "alice", None),
|
||||
m2.open_channel("alk/b", "bob", None),
|
||||
m3.open_channel("alk/c", "carol", None),
|
||||
);
|
||||
|
||||
let successes = [r1.is_ok(), r2.is_ok(), r3.is_ok()]
|
||||
@@ -1135,7 +1135,7 @@ mod tests {
|
||||
AccessControl::default(),
|
||||
None,
|
||||
)
|
||||
.with_channel_open(ChannelOpenSpec::new("alknet/tty"));
|
||||
.with_channel_open(ChannelOpenSpec::new("alk/tty"));
|
||||
core.register_openable(
|
||||
spec,
|
||||
Arc::clone(&open_handler),
|
||||
@@ -1157,12 +1157,12 @@ mod tests {
|
||||
|
||||
let (client_end, server_end) = tokio::io::duplex(64 * 1024);
|
||||
let client_conn =
|
||||
Connection::from_bidi(client_end, b"alknet/channels".to_vec(), Some(TEST_ADDR));
|
||||
Connection::from_bidi(client_end, b"alk/channels".to_vec(), Some(TEST_ADDR));
|
||||
let server_conn =
|
||||
Connection::from_bidi(server_end, b"alknet/channels".to_vec(), Some(TEST_ADDR));
|
||||
Connection::from_bidi(server_end, b"alk/channels".to_vec(), Some(TEST_ADDR));
|
||||
|
||||
let adapter = ChannelsAdapter::new(install_hook, Arc::new(NoCap));
|
||||
let auth = AuthContext::anonymous(b"alknet/channels");
|
||||
let auth = AuthContext::anonymous(b"alk/channels");
|
||||
let _server_handle = tokio::spawn(async move {
|
||||
let _ = crate::core::types::ProtocolHandler::handle(&adapter, server_conn, &auth).await;
|
||||
});
|
||||
@@ -1175,7 +1175,7 @@ mod tests {
|
||||
.open_channel(
|
||||
"channels/tty/sub",
|
||||
serde_json::json!({ "container": "abc" }),
|
||||
"alknet/tty",
|
||||
"alk/tty",
|
||||
)
|
||||
.await
|
||||
.expect("open_channel");
|
||||
|
||||
+20
-20
@@ -335,7 +335,7 @@ impl ChannelManager {
|
||||
}
|
||||
}
|
||||
|
||||
/// Install channel 0 (pre-negotiated as `alknet/call`, ADR-036).
|
||||
/// Install channel 0 (pre-negotiated as `alk/call`, ADR-036).
|
||||
/// Channel 0 is special only in that it's pre-allocated (by
|
||||
/// `channels-call`); the `ChannelsAdapter` hands the resulting
|
||||
/// `Connection` to the `CallAdapter`. The `channel_id` is 0.
|
||||
@@ -356,7 +356,7 @@ impl ChannelManager {
|
||||
let state = ChannelState {
|
||||
demux_sender,
|
||||
handler_task,
|
||||
alpn: "alknet/call".to_string(),
|
||||
alpn: "alk/call".to_string(),
|
||||
};
|
||||
{
|
||||
let mut channels = self.inner.channels.lock();
|
||||
@@ -500,11 +500,11 @@ mod tests {
|
||||
async fn open_channel_returns_unique_ids() {
|
||||
let manager = make_manager_with_runner().await;
|
||||
let (id1, _send1, _recv1) = manager
|
||||
.open_channel("alknet/tty", "alice", None)
|
||||
.open_channel("alk/tty", "alice", None)
|
||||
.await
|
||||
.expect("open 1");
|
||||
let (id2, _send2, _recv2) = manager
|
||||
.open_channel("alknet/tty", "alice", None)
|
||||
.open_channel("alk/tty", "alice", None)
|
||||
.await
|
||||
.expect("open 2");
|
||||
assert_ne!(id1, id2, "channel IDs are unique");
|
||||
@@ -515,7 +515,7 @@ mod tests {
|
||||
async fn open_channel_records_opener_in_ledger() {
|
||||
let manager = make_manager_with_runner().await;
|
||||
let (id, _send, _recv) = manager
|
||||
.open_channel("alknet/tty", "alice", None)
|
||||
.open_channel("alk/tty", "alice", None)
|
||||
.await
|
||||
.expect("open");
|
||||
assert_eq!(
|
||||
@@ -529,7 +529,7 @@ mod tests {
|
||||
async fn teardown_channel_removes_state() {
|
||||
let manager = make_manager_with_runner().await;
|
||||
let (id, _send, _recv) = manager
|
||||
.open_channel("alknet/tty", "alice", None)
|
||||
.open_channel("alk/tty", "alice", None)
|
||||
.await
|
||||
.expect("open");
|
||||
assert!(manager.has_channel(id));
|
||||
@@ -543,11 +543,11 @@ mod tests {
|
||||
let manager = make_manager_with_runner().await;
|
||||
assert!(manager.channel_ids().is_empty(), "no channels open yet");
|
||||
let (id1, _send1, _recv1) = manager
|
||||
.open_channel("alknet/tty", "alice", None)
|
||||
.open_channel("alk/tty", "alice", None)
|
||||
.await
|
||||
.expect("open 1");
|
||||
let (id2, _send2, _recv2) = manager
|
||||
.open_channel("alknet/tunnel", "bob", None)
|
||||
.open_channel("alk/tunnel", "bob", None)
|
||||
.await
|
||||
.expect("open 2");
|
||||
let mut ids = manager.channel_ids();
|
||||
@@ -562,7 +562,7 @@ mod tests {
|
||||
async fn route_payload_to_open_channel_succeeds() {
|
||||
let manager = make_manager_with_runner().await;
|
||||
let (id, _send, mut recv) = manager
|
||||
.open_channel("alknet/tty", "alice", None)
|
||||
.open_channel("alk/tty", "alice", None)
|
||||
.await
|
||||
.expect("open");
|
||||
manager
|
||||
@@ -603,7 +603,7 @@ mod tests {
|
||||
async fn route_payload_to_known_channel_does_not_increment_dropped_counter() {
|
||||
let manager = make_manager_with_runner().await;
|
||||
let (id, _send, mut recv) = manager
|
||||
.open_channel("alknet/tty", "alice", None)
|
||||
.open_channel("alk/tty", "alice", None)
|
||||
.await
|
||||
.expect("open");
|
||||
manager
|
||||
@@ -632,11 +632,11 @@ mod tests {
|
||||
async fn clear_all_returns_opener_ids() {
|
||||
let manager = make_manager_with_runner().await;
|
||||
manager
|
||||
.open_channel("alknet/tty", "alice", None)
|
||||
.open_channel("alk/tty", "alice", None)
|
||||
.await
|
||||
.expect("open");
|
||||
manager
|
||||
.open_channel("alknet/tty", "bob", None)
|
||||
.open_channel("alk/tty", "bob", None)
|
||||
.await
|
||||
.expect("open");
|
||||
let drained = manager.clear_all();
|
||||
@@ -703,11 +703,11 @@ mod tests {
|
||||
let accept = ChannelManager::new(connect_handle, 256, 64, None, ChannelSide::Accept);
|
||||
|
||||
let (id_c, _, _) = connect
|
||||
.open_channel("alknet/tty", "alice", None)
|
||||
.open_channel("alk/tty", "alice", None)
|
||||
.await
|
||||
.expect("connect open");
|
||||
let (id_a, _, _) = accept
|
||||
.open_channel("alknet/tty", "bob", None)
|
||||
.open_channel("alk/tty", "bob", None)
|
||||
.await
|
||||
.expect("accept open");
|
||||
|
||||
@@ -727,7 +727,7 @@ mod tests {
|
||||
let manager = ChannelManager::with_defaults(handle, None);
|
||||
|
||||
let (send, mut recv) = manager
|
||||
.adopt_channel(7, "alknet/tty", None)
|
||||
.adopt_channel(7, "alk/tty", None)
|
||||
.await
|
||||
.expect("adopt");
|
||||
|
||||
@@ -751,10 +751,10 @@ mod tests {
|
||||
let manager = ChannelManager::with_defaults(handle, None);
|
||||
|
||||
manager
|
||||
.adopt_channel(7, "alknet/tty", None)
|
||||
.adopt_channel(7, "alk/tty", None)
|
||||
.await
|
||||
.expect("first adopt");
|
||||
match manager.adopt_channel(7, "alknet/tty", None).await {
|
||||
match manager.adopt_channel(7, "alk/tty", None).await {
|
||||
Err(ManagerError::ChannelExists(7)) => {}
|
||||
Err(other) => panic!("expected ChannelExists, got {other}"),
|
||||
Ok(_) => panic!("expected ChannelExists, got Ok"),
|
||||
@@ -772,14 +772,14 @@ mod tests {
|
||||
let manager = ChannelManager::new(handle, 2, 64, None, ChannelSide::Accept);
|
||||
|
||||
manager
|
||||
.open_channel("alknet/tty", "alice", None)
|
||||
.open_channel("alk/tty", "alice", None)
|
||||
.await
|
||||
.expect("open 1");
|
||||
manager
|
||||
.open_channel("alknet/tty", "bob", None)
|
||||
.open_channel("alk/tty", "bob", None)
|
||||
.await
|
||||
.expect("open 2");
|
||||
match manager.open_channel("alknet/tty", "carol", None).await {
|
||||
match manager.open_channel("alk/tty", "carol", None).await {
|
||||
Err(ManagerError::TooManyChannels { count, max }) => {
|
||||
assert_eq!(count, 2);
|
||||
assert_eq!(max, 2);
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
//! Channels protocol: N logical channels over one transport stream
|
||||
//! (ADR-034, amended by ADR-035 — no `stream_type` concept).
|
||||
//!
|
||||
//! Channel 0 is pre-negotiated as `alknet/call` (ADR-036); channels
|
||||
//! Channel 0 is pre-negotiated as `alk/call` (ADR-036); channels
|
||||
//! 1..N are opened dynamically via per-ALPN open ops on channel 0
|
||||
//! (ADR-047). The channels layer is a re-framing proxy: it converts
|
||||
//! between "one transport stream carrying N channels" (the wire) and
|
||||
@@ -18,7 +18,7 @@
|
||||
//! - [`source`]: `ChannelBidiStreamSource` — implements
|
||||
//! `BidiStreamSource` for a single channel (yield-once `accept_bi`).
|
||||
//! - [`adapter`]: `ChannelsAdapter` — `ProtocolHandler` for
|
||||
//! `alknet/channels` (the demux loop).
|
||||
//! `alk/channels` (the demux loop).
|
||||
//! - [`operations`]: `ChannelOperations` — registers `channel/close`,
|
||||
//! `channel/control`, `channel/resources/subscribe` on the call
|
||||
//! `OperationRegistry`; the per-ALPN open ops are registered by the
|
||||
|
||||
+19
-24
@@ -802,7 +802,7 @@ mod tests {
|
||||
async fn resources_subscribe_handler_returns_not_implemented() {
|
||||
let manager = make_manager().await;
|
||||
manager
|
||||
.open_channel("alknet/tty", "alice", None)
|
||||
.open_channel("alk/tty", "alice", None)
|
||||
.await
|
||||
.expect("open tty");
|
||||
let handler = make_resources_subscribe_handler(manager.clone());
|
||||
@@ -908,7 +908,7 @@ mod tests {
|
||||
async fn close_handler_success_path_closes_open_channel() {
|
||||
let manager = make_manager().await;
|
||||
let (id, _send, _recv) = manager
|
||||
.open_channel("alknet/tty", "alice", None)
|
||||
.open_channel("alk/tty", "alice", None)
|
||||
.await
|
||||
.expect("open");
|
||||
assert!(manager.has_channel(id));
|
||||
@@ -938,7 +938,7 @@ mod tests {
|
||||
async fn control_handler_success_path_returns_not_implemented() {
|
||||
let manager = make_manager().await;
|
||||
let (id, _send, _recv) = manager
|
||||
.open_channel("alknet/tty", "alice", None)
|
||||
.open_channel("alk/tty", "alice", None)
|
||||
.await
|
||||
.expect("open");
|
||||
let handler = make_control_handler(manager);
|
||||
@@ -1035,13 +1035,13 @@ mod tests {
|
||||
spawned_clone.store(true, Ordering::SeqCst);
|
||||
tokio::spawn(async {})
|
||||
});
|
||||
let auth = AuthContext::anonymous(b"alknet/call");
|
||||
let auth = AuthContext::anonymous(b"alk/call");
|
||||
let handler = make_open_handler_once(
|
||||
manager.clone(),
|
||||
policy,
|
||||
open_handler,
|
||||
auth,
|
||||
"alknet/tty".to_string(),
|
||||
"alk/tty".to_string(),
|
||||
);
|
||||
let env = handler(json!({}), test_context("open-once-1")).await;
|
||||
match env.result {
|
||||
@@ -1065,13 +1065,13 @@ mod tests {
|
||||
spawned_clone.store(true, Ordering::SeqCst);
|
||||
tokio::spawn(async {})
|
||||
});
|
||||
let auth = AuthContext::anonymous(b"alknet/call");
|
||||
let auth = AuthContext::anonymous(b"alk/call");
|
||||
let handler = make_open_handler_stream(
|
||||
manager.clone(),
|
||||
policy,
|
||||
open_handler,
|
||||
auth,
|
||||
"alknet/tty".to_string(),
|
||||
"alk/tty".to_string(),
|
||||
);
|
||||
let mut stream = handler(json!({}), test_context("open-stream-1"));
|
||||
let env = stream.next().await.expect("one envelope");
|
||||
@@ -1095,14 +1095,9 @@ mod tests {
|
||||
let manager = make_manager().await;
|
||||
let policy = super::super::policy::default_policy();
|
||||
let open_handler: OpenHandler = Arc::new(|_input, _conn, _auth| tokio::spawn(async {}));
|
||||
let auth = AuthContext::anonymous(b"alknet/call");
|
||||
let handler = make_open_handler_sink(
|
||||
manager,
|
||||
policy,
|
||||
open_handler,
|
||||
auth,
|
||||
"alknet/tty".to_string(),
|
||||
);
|
||||
let auth = AuthContext::anonymous(b"alk/call");
|
||||
let handler =
|
||||
make_open_handler_sink(manager, policy, open_handler, auth, "alk/tty".to_string());
|
||||
let publish_stream: crate::registry::registration::PublishStream =
|
||||
Box::pin(futures::stream::empty());
|
||||
let env = handler(json!({}), test_context("open-sink-1"), publish_stream).await;
|
||||
@@ -1127,7 +1122,7 @@ mod tests {
|
||||
AccessControl::default(),
|
||||
None,
|
||||
)
|
||||
.with_channel_open(ChannelOpenSpec::new("alknet/tty"));
|
||||
.with_channel_open(ChannelOpenSpec::new("alk/tty"));
|
||||
let spawned = Arc::new(AtomicBool::new(false));
|
||||
let spawned_clone = Arc::clone(&spawned);
|
||||
let open_handler: OpenHandler = Arc::new(move |_input, _conn, _auth| {
|
||||
@@ -1139,7 +1134,7 @@ mod tests {
|
||||
spec,
|
||||
open_handler,
|
||||
&mut registry,
|
||||
AuthContext::anonymous(b"alknet/call"),
|
||||
AuthContext::anonymous(b"alk/call"),
|
||||
)
|
||||
.expect("register");
|
||||
assert!(registry.registration("channels/tty/sub").is_some());
|
||||
@@ -1170,7 +1165,7 @@ mod tests {
|
||||
AccessControl::default(),
|
||||
None,
|
||||
)
|
||||
.with_channel_open(ChannelOpenSpec::new("alknet/tty"));
|
||||
.with_channel_open(ChannelOpenSpec::new("alk/tty"));
|
||||
let spawned = Arc::new(AtomicBool::new(false));
|
||||
let spawned_clone = Arc::clone(&spawned);
|
||||
let open_handler: OpenHandler = Arc::new(move |_input, _conn, _auth| {
|
||||
@@ -1182,7 +1177,7 @@ mod tests {
|
||||
spec,
|
||||
open_handler,
|
||||
&mut registry,
|
||||
AuthContext::anonymous(b"alknet/call"),
|
||||
AuthContext::anonymous(b"alk/call"),
|
||||
)
|
||||
.expect("register");
|
||||
let mut stream =
|
||||
@@ -1212,14 +1207,14 @@ mod tests {
|
||||
AccessControl::default(),
|
||||
None,
|
||||
)
|
||||
.with_channel_open(ChannelOpenSpec::new("alknet/tty"));
|
||||
.with_channel_open(ChannelOpenSpec::new("alk/tty"));
|
||||
let open_handler: OpenHandler = Arc::new(|_input, _conn, _auth| tokio::spawn(async {}));
|
||||
let mut registry = OperationRegistry::new();
|
||||
core.register_openable(
|
||||
spec,
|
||||
open_handler,
|
||||
&mut registry,
|
||||
AuthContext::anonymous(b"alknet/call"),
|
||||
AuthContext::anonymous(b"alk/call"),
|
||||
)
|
||||
.expect("register");
|
||||
assert!(registry.registration("channels/tty/pub").is_some());
|
||||
@@ -1249,7 +1244,7 @@ mod tests {
|
||||
spec,
|
||||
open_handler,
|
||||
&mut registry,
|
||||
AuthContext::anonymous(b"alknet/call"),
|
||||
AuthContext::anonymous(b"alk/call"),
|
||||
);
|
||||
assert!(result.is_err());
|
||||
assert!(result.unwrap_err().contains("channel_open marker"));
|
||||
@@ -1261,7 +1256,7 @@ mod tests {
|
||||
let policy: Arc<dyn ChannelLifecyclePolicy> =
|
||||
Arc::new(super::super::policy::PerIdentityChannelPolicy::new(0));
|
||||
let open_handler: OpenHandler = Arc::new(|_input, _conn, _auth| tokio::spawn(async {}));
|
||||
let auth = AuthContext::anonymous(b"alknet/call");
|
||||
let auth = AuthContext::anonymous(b"alk/call");
|
||||
let opener_id = Identity {
|
||||
id: "alice".to_string(),
|
||||
scopes: vec![],
|
||||
@@ -1272,7 +1267,7 @@ mod tests {
|
||||
&policy,
|
||||
&open_handler,
|
||||
&auth,
|
||||
"alknet/tty",
|
||||
"alk/tty",
|
||||
json!({}),
|
||||
opener_id.id.clone(),
|
||||
opener_id,
|
||||
|
||||
@@ -29,7 +29,7 @@ pub const CHUNK_HEADER_LEN: usize = 8;
|
||||
/// so the demux can always resync by reading the next 8-byte header.
|
||||
pub const MAX_CHUNK_LEN: u32 = 16 * 1024 * 1024;
|
||||
|
||||
/// A chunk channel ID of 0 is pre-negotiated as `alknet/call` (ADR-036).
|
||||
/// A chunk channel ID of 0 is pre-negotiated as `alk/call` (ADR-036).
|
||||
/// Both sides know `channel_id = 0` is routed to the `CallAdapter`
|
||||
/// without an explicit open op exchange.
|
||||
pub const CHANNEL_ID_ZERO: u32 = 0;
|
||||
|
||||
Reference in new issue
Block a user