X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fprinter.rs;h=933603ccc440d65a3af97578b92875f8e9e5f5c8;hb=c49b9c568cbde2bb7d24726deaa66da11a9d8aab;hp=0d928b0328b1fa21f46621d8c216ccd3a9d5475d;hpb=ddbb43272597ab9d0d12ad37528c8450f903d525;p=dnsseed-rust diff --git a/src/printer.rs b/src/printer.rs index 0d928b0..933603c 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -11,12 +11,16 @@ pub enum Stat { HeaderCount(u64), NewConnection, ConnectionClosed, + V4RoutingTableSize(usize), + V6RoutingTableSize(usize), } struct Stats { lines: LinkedList, header_count: u64, connection_count: u64, + v4_table_size: usize, + v6_table_size: usize, } pub struct Printer { @@ -29,6 +33,8 @@ impl Printer { lines: LinkedList::new(), header_count: 0, connection_count: 0, + v4_table_size: 0, + v6_table_size: 0, })); let thread_arc = Arc::clone(&stats); std::thread::spawn(move || { @@ -83,6 +89,10 @@ impl Printer { ).as_bytes()).expect("stdout broken?"); } + out.write_all(format!( + "\nBGP Routing Table: {} v4 paths, {} v6 paths\n", + stats.v4_table_size, stats.v6_table_size).as_bytes()).expect("stdout broken?"); + out.write_all(b"\nCommands:\n").expect("stdout broken?"); out.write_all(b"q: quit\n").expect("stdout broken?"); out.write_all(format!( @@ -93,6 +103,7 @@ impl Printer { store.get_u64(U64Setting::WasGoodTimeout) ).as_bytes()).expect("stdout broken?"); out.write_all(b"a x: Scan node x\n").expect("stdout broken?"); + out.write_all(b"b x: BGP Lookup IP x\n").expect("stdout broken?"); out.write_all(b"\x1b[s").expect("stdout broken?"); // Save cursor position and provide a blank line before cursor out.write_all(b"\x1b[;H\x1b[2K").expect("stdout broken?"); out.write_all(b"Most recent log:\n").expect("stdout broken?"); @@ -113,7 +124,7 @@ impl Printer { } else { stats.lines.push_back(line); } - if stats.lines.len() > 50 { + if stats.lines.len() > 75 { stats.lines.pop_front(); } } @@ -123,6 +134,8 @@ impl Printer { Stat::HeaderCount(c) => self.stats.lock().unwrap().header_count = c, Stat::NewConnection => self.stats.lock().unwrap().connection_count += 1, Stat::ConnectionClosed => self.stats.lock().unwrap().connection_count -= 1, + Stat::V4RoutingTableSize(c) => self.stats.lock().unwrap().v4_table_size = c, + Stat::V6RoutingTableSize(c) => self.stats.lock().unwrap().v6_table_size = c, } } }