mirror of
https://gitlab.com/fabinfra/fabaccess/sute.git
synced 2025-03-11 22:21:52 +01:00
Adds session code
This commit is contained in:
parent
4a9dd734f8
commit
85a53cf9f2
316
Cargo.lock
generated
316
Cargo.lock
generated
@ -19,16 +19,10 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
version = "0.3.6"
|
||||
name = "anyhow"
|
||||
version = "1.0.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
||||
checksum = "bf8dcb5b4bbaa28653b647d8c77bd4ed40183b48882e130c1f1ffb73de069fd7"
|
||||
|
||||
[[package]]
|
||||
name = "async-channel"
|
||||
@ -152,12 +146,6 @@ version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.55.1"
|
||||
@ -188,17 +176,6 @@ version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
|
||||
[[package]]
|
||||
name = "blake2b_simd"
|
||||
version = "0.5.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"arrayvec",
|
||||
"constant_time_eq",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "blocking"
|
||||
version = "1.0.2"
|
||||
@ -355,55 +332,6 @@ dependencies = [
|
||||
"cache-padded",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "constant_time_eq"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cfg-if 0.1.10",
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_users",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "2.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10",
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_users",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "discard"
|
||||
version = "1.0.4"
|
||||
@ -438,12 +366,6 @@ dependencies = [
|
||||
"instant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fnv"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.7"
|
||||
@ -568,17 +490,6 @@ dependencies = [
|
||||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.1.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.0"
|
||||
@ -674,17 +585,6 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linefeed"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28715d08e35c6c074f9ae6b2e6a2420bac75d050c66ecd669d7d5b98e2caa036"
|
||||
dependencies = [
|
||||
"dirs 1.0.5",
|
||||
"mortal",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.11"
|
||||
@ -700,22 +600,6 @@ version = "2.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
|
||||
|
||||
[[package]]
|
||||
name = "mortal"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "998fd6a991497275567703b6f435e27958b633878ec991f5734b96dd46675e9f"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libc",
|
||||
"nix",
|
||||
"smallstr",
|
||||
"terminfo",
|
||||
"unicode-normalization",
|
||||
"unicode-width",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nb-connect"
|
||||
version = "1.0.2"
|
||||
@ -726,19 +610,6 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cc",
|
||||
"cfg-if 0.1.10",
|
||||
"libc",
|
||||
"void",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "5.1.2"
|
||||
@ -789,44 +660,6 @@ version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
||||
|
||||
[[package]]
|
||||
name = "phf"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12"
|
||||
dependencies = [
|
||||
"phf_shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_codegen"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815"
|
||||
dependencies = [
|
||||
"phf_generator",
|
||||
"phf_shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_generator"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526"
|
||||
dependencies = [
|
||||
"phf_shared",
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_shared"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7"
|
||||
dependencies = [
|
||||
"siphasher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project"
|
||||
version = "1.0.1"
|
||||
@ -872,12 +705,6 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
version = "1.0.4"
|
||||
@ -938,57 +765,6 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
"rand_pcg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_pcg"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.57"
|
||||
@ -1004,17 +780,6 @@ dependencies = [
|
||||
"redox_syscall",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"redox_syscall",
|
||||
"rust-argon2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.4.2"
|
||||
@ -1043,18 +808,6 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-argon2"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"blake2b_simd",
|
||||
"constant_time_eq",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "1.1.0"
|
||||
@ -1092,12 +845,6 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "siphasher"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa8f3741c7372e75519bd9346068370c9cdaabcc1f9599cbcf2a2719352286b7"
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.2"
|
||||
@ -1110,21 +857,6 @@ version = "2.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cc9c640a4adbfbcc11ffb95efe5aa7af7309e002adab54b185507dbf2377b99"
|
||||
|
||||
[[package]]
|
||||
name = "smallstr"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e922794d168678729ffc7e07182721a14219c65814e66e91b839a272fe5ae4f"
|
||||
dependencies = [
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252"
|
||||
|
||||
[[package]]
|
||||
name = "smol"
|
||||
version = "1.2.4"
|
||||
@ -1159,6 +891,7 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
name = "sute"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"capnp",
|
||||
"capnp-futures",
|
||||
"capnp-rpc",
|
||||
@ -1168,7 +901,6 @@ dependencies = [
|
||||
"futures-signals",
|
||||
"futures-util",
|
||||
"libc",
|
||||
"linefeed",
|
||||
"rsasl",
|
||||
"signal-hook",
|
||||
"slog",
|
||||
@ -1198,19 +930,6 @@ dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "terminfo"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76971977e6121664ec1b960d1313aacfa75642adc93b9d4d53b247bd4cb1747e"
|
||||
dependencies = [
|
||||
"dirs 2.0.2",
|
||||
"fnv",
|
||||
"nom",
|
||||
"phf",
|
||||
"phf_codegen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termion"
|
||||
version = "1.5.5"
|
||||
@ -1250,12 +969,6 @@ dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117"
|
||||
|
||||
[[package]]
|
||||
name = "tui"
|
||||
version = "0.11.0"
|
||||
@ -1269,15 +982,6 @@ dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977"
|
||||
dependencies = [
|
||||
"tinyvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.6.0"
|
||||
@ -1320,24 +1024,12 @@ version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
|
||||
|
||||
[[package]]
|
||||
name = "void"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
|
||||
[[package]]
|
||||
name = "waker-fn"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.9.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
||||
|
||||
[[package]]
|
||||
name = "wepoll-sys"
|
||||
version = "3.0.1"
|
||||
|
@ -31,7 +31,7 @@ slog = { version = "2.5", features = ["max_level_debug"] }
|
||||
libc = "0.2"
|
||||
rsasl = "0.2.3"
|
||||
|
||||
linefeed = "0.6"
|
||||
anyhow = "1.0"
|
||||
|
||||
[build-dependencies]
|
||||
capnpc = "0.13"
|
||||
|
@ -9,7 +9,6 @@ use std::sync::{Arc, Mutex};
|
||||
use std::thread;
|
||||
|
||||
use smol::Task;
|
||||
use smol::net::TcpStream;
|
||||
|
||||
use tui::backend::{Backend, TermionBackend};
|
||||
use tui::Terminal;
|
||||
@ -29,6 +28,7 @@ mod input;
|
||||
mod util;
|
||||
mod ui;
|
||||
mod schema;
|
||||
mod session;
|
||||
mod commands;
|
||||
|
||||
use banner::BANNER;
|
||||
@ -64,13 +64,6 @@ fn main() -> Result<(), io::Error> {
|
||||
let lex = smol::LocalExecutor::new();
|
||||
|
||||
let resize = util::Resize::new()?;
|
||||
let stream_f = async move {
|
||||
TcpStream::connect(server).await.unwrap()
|
||||
};
|
||||
|
||||
let stream = smol::block_on(lex.run(stream_f));
|
||||
|
||||
let (rpc_future, api) = schema::bootstrap(log.clone(), stream);
|
||||
|
||||
let app = app::Sute::new(resize, log.clone(), drain.clone(), Some(api));
|
||||
|
||||
|
@ -28,51 +28,4 @@ impl API {
|
||||
Authentication::new(moretmp.get_auth().unwrap())
|
||||
})
|
||||
}
|
||||
|
||||
///// Authenticate to the server. Returns true on success, false on error
|
||||
//async fn authenticate(&mut self) -> Result<bool, io::Error> {
|
||||
// let mut sasl = SASL::new().unwrap();
|
||||
// let plain = std::ffi::CString::new("PLAIN").unwrap();
|
||||
// let mut sess = sasl.client_start(&plain).unwrap();
|
||||
// sess.set_property(rsasl::Property::GSASL_AUTHID, b"testuser");
|
||||
// sess.set_property(rsasl::Property::GSASL_PASSWORD, b"testpass");
|
||||
|
||||
// if let rsasl::Step::Done(data) = sess.step(&[]).unwrap() {
|
||||
// self.send_authentication_request("PLAIN", Some(&data)).await;
|
||||
// } else {
|
||||
// println!("Sasl said moar data");
|
||||
// }
|
||||
|
||||
// Ok(self.receive_challenge().await?)
|
||||
//}
|
||||
|
||||
//fn send_authentication_request(&mut self, mech: &str, init: Option<&[u8]>) -> impl Future<Output=()> {
|
||||
// let mut outer = capnp::message::Builder::new_default();
|
||||
// let mut builder = outer.init_root::<connection_capnp::message::Builder>()
|
||||
// .init_auth()
|
||||
// .init_request();
|
||||
// builder.set_mechanism(mech);
|
||||
|
||||
// if let Some(data) = init {
|
||||
// builder.init_initial_response().set_initial(data);
|
||||
// }
|
||||
|
||||
// let stream = self.stream.clone();
|
||||
// capnp_futures::serialize::write_message(stream, outer).map(|r| r.unwrap())
|
||||
//}
|
||||
|
||||
//async fn receive_challenge(&mut self) -> Result<bool, io::Error> {
|
||||
// let message = capnp_futures::serialize::read_message(&mut self.stream, capnp::message::ReaderOptions::default()).await.unwrap().unwrap();
|
||||
// let m = message.get_root::<connection_capnp::message::Reader>().unwrap();
|
||||
|
||||
// if let Ok(connection_capnp::message::Which::Auth(Ok(r))) = m.which() {
|
||||
// if let Ok(auth_capnp::auth_message::Outcome(Ok(r))) = r.which() {
|
||||
// if let Ok(auth_capnp::outcome::Result::Successful) = r.get_result() {
|
||||
// return Ok(true);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// return Ok(false);
|
||||
//}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use smol::net::TcpStream;
|
||||
|
||||
use capnp_rpc::twoparty;
|
||||
use capnp_rpc::RpcSystem;
|
||||
use capnp_rpc::rpc_twoparty_capnp;
|
||||
use capnp_rpc::rpc_twoparty_capnp::Side;
|
||||
|
||||
mod auth_capnp {
|
||||
include!(concat!(env!("OUT_DIR"), "/schema/auth_capnp.rs"));
|
||||
@ -25,15 +25,13 @@ pub use api::API;
|
||||
mod authentication;
|
||||
pub use authentication::Authentication;
|
||||
|
||||
pub fn bootstrap(log: Logger, stream: TcpStream) -> (impl Future, API) {
|
||||
debug!(log, "Bootstrapping API…");
|
||||
|
||||
pub fn bootstrap(log: Logger, stream: TcpStream) -> (RpcSystem<Side>, API) {
|
||||
let network = Box::new(twoparty::VatNetwork::new(stream.clone(), stream,
|
||||
rpc_twoparty_capnp::Side::Client, Default::default()));
|
||||
Side::Client, Default::default()));
|
||||
|
||||
let mut rpc = RpcSystem::new(network, None);
|
||||
let client: connection_capnp::bootstrap::Client
|
||||
= rpc.bootstrap(rpc_twoparty_capnp::Side::Server);
|
||||
= rpc.bootstrap(Side::Server);
|
||||
|
||||
return (rpc, API::new(log, client));
|
||||
}
|
||||
|
31
src/session.rs
Normal file
31
src/session.rs
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
use capnp_rpc::RpcSystem;
|
||||
use capnp_rpc::rpc_twoparty_capnp::Side;
|
||||
|
||||
use smol::net::TcpStream;
|
||||
use smol::net::AsyncToSocketAddrs;
|
||||
|
||||
use slog::Logger;
|
||||
|
||||
use crate::schema::{bootstrap, API, Authentication};
|
||||
|
||||
pub struct Session {
|
||||
bootstrap: API,
|
||||
authenticate: Option<Authentication>,
|
||||
vat: Option<RpcSystem<Side>>,
|
||||
}
|
||||
|
||||
impl Session {
|
||||
async fn connect<A: AsyncToSocketAddrs>(log: Logger, addr: A) -> Result<Session> {
|
||||
let stream = TcpStream::connect(addr).await?;
|
||||
let (rpc_system, api) = bootstrap(log, stream);
|
||||
|
||||
Ok(Session {
|
||||
bootstrap: api,
|
||||
authenticate: None,
|
||||
vat: Some(rpc_system),
|
||||
})
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user