"Inferior" mode
This commit is contained in:
parent
051843b832
commit
0ad4f7fe56
|
@ -20,7 +20,7 @@ structopt = "0.3.14"
|
||||||
tungstenite = "0.13.0"
|
tungstenite = "0.13.0"
|
||||||
tokio-tungstenite = "0.14.0"
|
tokio-tungstenite = "0.14.0"
|
||||||
|
|
||||||
tokio = { version = "1.10.0", features = ["io-util", "macros", "sync", "net", "rt", "rt-multi-thread", "time"] }
|
tokio = { version = "1.10.0", features = ["io-std", "io-util", "macros", "sync", "net", "rt", "rt-multi-thread", "time"] }
|
||||||
tokio-util = "0.6.7"
|
tokio-util = "0.6.7"
|
||||||
|
|
||||||
tracing = "0.1.14"
|
tracing = "0.1.14"
|
||||||
|
|
|
@ -36,6 +36,9 @@ struct ServerConfig {
|
||||||
#[structopt(short = "s", long = "socket")]
|
#[structopt(short = "s", long = "socket")]
|
||||||
sockets: Vec<PathBuf>,
|
sockets: Vec<PathBuf>,
|
||||||
|
|
||||||
|
#[structopt(long)]
|
||||||
|
inferior: bool,
|
||||||
|
|
||||||
#[structopt(long)]
|
#[structopt(long)]
|
||||||
debt_reporter: bool,
|
debt_reporter: bool,
|
||||||
}
|
}
|
||||||
|
@ -88,6 +91,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let ds = Cap::new(&Actor::create_and_start(syndicate::name!("dataspace"), Dataspace::new()));
|
let ds = Cap::new(&Actor::create_and_start(syndicate::name!("dataspace"), Dataspace::new()));
|
||||||
|
|
||||||
|
if config.inferior {
|
||||||
|
let ds = Arc::clone(&ds);
|
||||||
|
Actor::new().boot(syndicate::name!("parent"),
|
||||||
|
|t| run_io_relay(t,
|
||||||
|
relay::Input::Bytes(Box::pin(tokio::io::stdin())),
|
||||||
|
relay::Output::Bytes(Box::pin(tokio::io::stdout())),
|
||||||
|
ds));
|
||||||
|
}
|
||||||
|
|
||||||
let gateway = Cap::guard(&Actor::create_and_start(
|
let gateway = Cap::guard(&Actor::create_and_start(
|
||||||
syndicate::name!("gateway"),
|
syndicate::name!("gateway"),
|
||||||
syndicate::entity(Arc::clone(&ds)).on_asserted(handle_resolve)));
|
syndicate::entity(Arc::clone(&ds)).on_asserted(handle_resolve)));
|
||||||
|
@ -160,18 +173,26 @@ impl Entity<()> for ExitListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn run_io_relay(
|
||||||
|
t: &mut Activation,
|
||||||
|
i: relay::Input,
|
||||||
|
o: relay::Output,
|
||||||
|
initial_ref: Arc<Cap>,
|
||||||
|
) -> ActorResult {
|
||||||
|
let exit_listener = t.state.create(ExitListener);
|
||||||
|
t.state.add_exit_hook(&exit_listener);
|
||||||
|
relay::TunnelRelay::run(t, i, o, Some(initial_ref), None);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn run_connection(
|
fn run_connection(
|
||||||
ac: ActorRef,
|
ac: ActorRef,
|
||||||
i: relay::Input,
|
i: relay::Input,
|
||||||
o: relay::Output,
|
o: relay::Output,
|
||||||
gateway: Arc<Cap>,
|
initial_ref: Arc<Cap>,
|
||||||
) -> ActorResult {
|
) -> ActorResult {
|
||||||
Activation::for_actor(&ac, Account::new(syndicate::name!("start-session")), |t| {
|
Activation::for_actor(&ac, Account::new(syndicate::name!("start-session")),
|
||||||
let exit_listener = t.state.create(ExitListener);
|
|t| run_io_relay(t, i, o, initial_ref))
|
||||||
t.state.add_exit_hook(&exit_listener);
|
|
||||||
relay::TunnelRelay::run(t, i, o, Some(gateway), None);
|
|
||||||
Ok(())
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn detect_protocol(
|
async fn detect_protocol(
|
||||||
|
|
Loading…
Reference in New Issue