Skip to main content

kulfi_utils/
lib.rs

1extern crate self as kulfi_utils;
2
3pub mod dot_kulfi;
4pub mod get_endpoint;
5mod get_stream;
6mod graceful;
7pub mod http;
8mod http_connection_manager;
9mod http_to_peer;
10mod peer_to_http;
11mod ping;
12pub mod protocol;
13pub mod secret;
14mod tcp;
15mod udp;
16mod utils;
17mod utils_iroh;
18
19pub use get_endpoint::get_endpoint;
20pub use get_stream::{PeerStreamSenders, get_stream};
21pub use graceful::Graceful;
22pub use http::ProxyResult;
23pub use http_connection_manager::{HttpConnectionManager, HttpConnectionPool, HttpConnectionPools};
24pub use http_to_peer::{http_to_peer, http_to_peer_non_streaming};
25pub use peer_to_http::peer_to_http;
26pub use ping::{PONG, ping};
27pub use protocol::{APNS_IDENTITY, Protocol, ProtocolHeader};
28pub use secret::{
29    ID52_FILE, SECRET_KEY_FILE, generate_and_save_key, generate_secret_key, get_secret_key,
30    read_or_create_key,
31};
32pub use tcp::{peer_to_tcp, pipe_tcp_stream_over_iroh, tcp_to_peer};
33pub use udp::{peer_to_udp, read_framed_datagram, udp_to_peer, write_framed_datagram};
34pub use utils::mkdir;
35pub use utils_iroh::{
36    accept_bi, accept_bi_any, accept_bi_with, get_remote_id52, global_iroh_endpoint, next_json,
37    next_string,
38};
39
40// Deprecated helper functions - use kulfi_id52 directly
41pub use utils::{id52_to_public_key, public_key_to_id52};
42
43/// IDMap stores the fastn port and the endpoint for every identity
44///
45/// why is it a Vec and not a HasMap? the incoming requests contain the first few characters of id
46/// and not the full id. the reason for this is we want to use <id>.localhost.direct as well, and
47/// subdomain can be max 63 char long, and our ids are 64 chars. if we use <id>.kulfi, then this
48/// will not be a problem. we still do prefix match instead of exact match just to be sure.
49///
50/// since the number of identities will be small, a prefix match is probably going to be the same
51/// speed as the hash map exact lookup.
52pub type IDMap = std::sync::Arc<tokio::sync::Mutex<Vec<(String, (u16, iroh::endpoint::Endpoint))>>>;
53
54pub const ACK: &str = "ack";