@@ -4,11 +4,10 @@ use std::{
44 net:: { SocketAddrV4 , SocketAddrV6 } ,
55 path:: PathBuf ,
66 sync:: atomic:: { AtomicBool , Ordering } ,
7- time:: { Duration , Instant } ,
87} ;
98
109use clap:: Parser ;
11- use iroh:: { endpoint:: BindError , Endpoint , Watcher } ;
10+ use iroh:: { endpoint:: BindError , Endpoint } ;
1211use iroh_content_discovery:: protocol:: ALPN ;
1312use iroh_content_tracker:: {
1413 io:: {
@@ -43,22 +42,6 @@ macro_rules! log {
4342 } ;
4443}
4544
46- /// Wait until the endpoint has figured out it's own DERP region.
47- async fn await_relay_region ( endpoint : & Endpoint ) -> anyhow:: Result < ( ) > {
48- let t0 = Instant :: now ( ) ;
49- loop {
50- let addr = endpoint. node_addr ( ) . initialized ( ) . await ;
51- if addr. relay_url ( ) . is_some ( ) {
52- break ;
53- }
54- if t0. elapsed ( ) > Duration :: from_secs ( 10 ) {
55- anyhow:: bail!( "timeout waiting for DERP region" ) ;
56- }
57- tokio:: time:: sleep ( Duration :: from_millis ( 50 ) ) . await ;
58- }
59- Ok ( ( ) )
60- }
61-
6245async fn create_endpoint (
6346 key : iroh:: SecretKey ,
6447 ipv4_addr : Option < SocketAddrV4 > ,
@@ -112,8 +95,8 @@ async fn server(args: Args) -> anyhow::Result<()> {
11295 create_endpoint ( key. clone ( ) , options. ipv4_bind_addr , options. ipv6_bind_addr ) . await ?;
11396 let db = Tracker :: new ( options, endpoint. clone ( ) ) ?;
11497 db. dump ( ) . await ?;
115- await_relay_region ( & endpoint) . await ? ;
116- let addr = endpoint. node_addr ( ) . initialized ( ) . await ;
98+ endpoint. online ( ) . await ;
99+ let addr = endpoint. node_addr ( ) ;
117100 println ! ( "tracker addr: {}\n " , addr. node_id) ;
118101 info ! ( "listening on {:?}" , addr) ;
119102 // let db2 = db.clone();
@@ -169,7 +152,7 @@ pub async fn load_secret_key(key_path: PathBuf) -> anyhow::Result<iroh::SecretKe
169152 let secret_key = SecretKey :: from_bytes ( & kp. private . to_bytes ( ) ) ;
170153 Ok ( secret_key)
171154 } else {
172- let secret_key = SecretKey :: generate ( rand:: rngs :: OsRng ) ;
155+ let secret_key = SecretKey :: generate ( & mut rand:: rng ( ) ) ;
173156 let ckey = ssh_key:: private:: Ed25519Keypair {
174157 public : secret_key. public ( ) . public ( ) . into ( ) ,
175158 private : secret_key. secret ( ) . into ( ) ,
0 commit comments