mirror of
https://gitlab.com/fabinfra/fabaccess/sute.git
synced 2025-03-12 22:51:50 +01:00
Status
This commit is contained in:
parent
85a53cf9f2
commit
8dc2a156bb
10
src/app.rs
10
src/app.rs
@ -10,7 +10,7 @@ use futures_signals::signal::{Mutable, Signal, MutableSignalCloned, MutableLockM
|
|||||||
use termion::event::Key;
|
use termion::event::Key;
|
||||||
|
|
||||||
use crate::input::Inputs;
|
use crate::input::Inputs;
|
||||||
use crate::schema::{API, Authentication};
|
use crate::session::Session;
|
||||||
use crate::commands::{CommandParser, Commands};
|
use crate::commands::{CommandParser, Commands};
|
||||||
|
|
||||||
use smol::future::FutureExt;
|
use smol::future::FutureExt;
|
||||||
@ -42,7 +42,7 @@ pub struct Sute<'a, S> {
|
|||||||
|
|
||||||
signal: S,
|
signal: S,
|
||||||
inputs: Inputs,
|
inputs: Inputs,
|
||||||
api: Option<API>,
|
session: Option<Session>,
|
||||||
log: Logger,
|
log: Logger,
|
||||||
cmds: CommandParser<'a>,
|
cmds: CommandParser<'a>,
|
||||||
|
|
||||||
@ -52,13 +52,13 @@ pub struct Sute<'a, S> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, S: Unpin> Sute<'a, S> {
|
impl<'a, S: Unpin> Sute<'a, S> {
|
||||||
pub fn new(signal: S, log: Logger, drain: Arc<LogDrain<'a>>, api: Option<API>) -> Self {
|
pub fn new(signal: S, log: Logger, drain: Arc<LogDrain<'a>>, session: Option<Session>) -> Self {
|
||||||
let inputs = Inputs::new();
|
let inputs = Inputs::new();
|
||||||
let state = Mutable::new(SuteState::new());
|
let state = Mutable::new(SuteState::new());
|
||||||
let cmds = CommandParser::new();
|
let cmds = CommandParser::new();
|
||||||
let future = None;
|
let future = None;
|
||||||
|
|
||||||
Self { state, signal, inputs, api, log, cmds, drain, future }
|
Self { state, signal, inputs, session, log, cmds, drain, future }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_cmd(&mut self, cmdline: String) {
|
fn run_cmd(&mut self, cmdline: String) {
|
||||||
@ -73,7 +73,7 @@ impl<'a, S: Unpin> Sute<'a, S> {
|
|||||||
if u.is_none() || p.is_none() {
|
if u.is_none() || p.is_none() {
|
||||||
error!(self.log, "authenticate <user> <pass>");
|
error!(self.log, "authenticate <user> <pass>");
|
||||||
} else {
|
} else {
|
||||||
if let Some(mut api) = self.api.clone() {
|
if let Some(mut api) = self.session.as_ref().map(|s| s.bootstrap.clone()) {
|
||||||
let log2 = self.log.clone();
|
let log2 = self.log.clone();
|
||||||
info!(self.log, "Going for an auth trip");
|
info!(self.log, "Going for an auth trip");
|
||||||
|
|
||||||
|
@ -65,7 +65,12 @@ fn main() -> Result<(), io::Error> {
|
|||||||
|
|
||||||
let resize = util::Resize::new()?;
|
let resize = util::Resize::new()?;
|
||||||
|
|
||||||
let app = app::Sute::new(resize, log.clone(), drain.clone(), Some(api));
|
let session_f = session::Session::connect(log.clone(), server);
|
||||||
|
|
||||||
|
let mut session = smol::block_on(session_f).unwrap();
|
||||||
|
let rpc_future = session.vat.take().unwrap();
|
||||||
|
|
||||||
|
let app = app::Sute::new(resize, log.clone(), drain.clone(), Some(session));
|
||||||
|
|
||||||
let app_state = app.get_state();
|
let app_state = app.get_state();
|
||||||
let mut ui_state = ui::UIState::new(app_state, drain);
|
let mut ui_state = ui::UIState::new(app_state, drain);
|
||||||
|
@ -9,12 +9,15 @@ use capnp_rpc::twoparty;
|
|||||||
use capnp_rpc::RpcSystem;
|
use capnp_rpc::RpcSystem;
|
||||||
use capnp_rpc::rpc_twoparty_capnp::Side;
|
use capnp_rpc::rpc_twoparty_capnp::Side;
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
mod auth_capnp {
|
mod auth_capnp {
|
||||||
include!(concat!(env!("OUT_DIR"), "/schema/auth_capnp.rs"));
|
include!(concat!(env!("OUT_DIR"), "/schema/auth_capnp.rs"));
|
||||||
}
|
}
|
||||||
|
#[allow(dead_code)]
|
||||||
mod connection_capnp {
|
mod connection_capnp {
|
||||||
include!(concat!(env!("OUT_DIR"), "/schema/connection_capnp.rs"));
|
include!(concat!(env!("OUT_DIR"), "/schema/connection_capnp.rs"));
|
||||||
}
|
}
|
||||||
|
#[allow(dead_code)]
|
||||||
mod api_capnp {
|
mod api_capnp {
|
||||||
include!(concat!(env!("OUT_DIR"), "/schema/api_capnp.rs"));
|
include!(concat!(env!("OUT_DIR"), "/schema/api_capnp.rs"));
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,13 @@ use slog::Logger;
|
|||||||
use crate::schema::{bootstrap, API, Authentication};
|
use crate::schema::{bootstrap, API, Authentication};
|
||||||
|
|
||||||
pub struct Session {
|
pub struct Session {
|
||||||
bootstrap: API,
|
pub bootstrap: API,
|
||||||
authenticate: Option<Authentication>,
|
authenticate: Option<Authentication>,
|
||||||
vat: Option<RpcSystem<Side>>,
|
pub vat: Option<RpcSystem<Side>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Session {
|
impl Session {
|
||||||
async fn connect<A: AsyncToSocketAddrs>(log: Logger, addr: A) -> Result<Session> {
|
pub async fn connect<A: AsyncToSocketAddrs>(log: Logger, addr: A) -> Result<Session> {
|
||||||
let stream = TcpStream::connect(addr).await?;
|
let stream = TcpStream::connect(addr).await?;
|
||||||
let (rpc_system, api) = bootstrap(log, stream);
|
let (rpc_system, api) = bootstrap(log, stream);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user