nix/ec-node: auto-bootstrap web bridge from local control peers
This commit is contained in:
parent
2778715304
commit
c9996dd5ad
4 changed files with 236 additions and 4 deletions
|
|
@ -450,6 +450,10 @@ struct WtPublishArgs {
|
|||
/// Gossip peers to connect to for control announcements (repeatable).
|
||||
#[arg(long)]
|
||||
gossip_peer: Vec<String>,
|
||||
/// Optional path to write this publisher's control endpoint address JSON.
|
||||
/// Useful for bootstrapping local control bridges without manual peer copy/paste.
|
||||
#[arg(long)]
|
||||
control_endpoint_addr_out: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
|
|
@ -4853,6 +4857,8 @@ async fn wt_publish(args: WtPublishArgs) -> Result<()> {
|
|||
let discovery = parse_discovery(args.discovery.as_deref())?;
|
||||
let endpoint = ec_iroh::build_endpoint(secret, discovery).await?;
|
||||
let gossip_peers = parse_gossip_peers(args.gossip_peer.clone());
|
||||
let endpoint_addr_json =
|
||||
serde_json::to_string(&endpoint.addr()).unwrap_or_else(|_| endpoint.id().to_string());
|
||||
|
||||
let announcement = build_control_announcement(
|
||||
args.name.clone(),
|
||||
|
|
@ -4874,8 +4880,33 @@ async fn wt_publish(args: WtPublishArgs) -> Result<()> {
|
|||
.await
|
||||
{
|
||||
Ok(stop_tx) => {
|
||||
eprintln!("control endpoint id: {}", endpoint.id());
|
||||
eprintln!("control endpoint addr: {}", endpoint_addr_json);
|
||||
|
||||
if let Some(path) = args.control_endpoint_addr_out.as_ref() {
|
||||
if let Some(parent) = path.parent() {
|
||||
fs::create_dir_all(parent).with_context(|| {
|
||||
format!(
|
||||
"failed to create control endpoint addr parent dir: {}",
|
||||
parent.display()
|
||||
)
|
||||
})?;
|
||||
}
|
||||
fs::write(path, format!("{endpoint_addr_json}\n")).with_context(|| {
|
||||
format!(
|
||||
"failed to write control endpoint addr file: {}",
|
||||
path.display()
|
||||
)
|
||||
})?;
|
||||
tracing::info!(
|
||||
path = %path.display(),
|
||||
"wrote control endpoint addr file"
|
||||
);
|
||||
}
|
||||
|
||||
tracing::info!(
|
||||
endpoint = %endpoint.id(),
|
||||
endpoint_addr = %endpoint_addr_json,
|
||||
stream = %args.name,
|
||||
"control announce enabled"
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue