lints
This commit is contained in:
parent
4ffe259ad1
commit
1c576876ef
@ -18,22 +18,13 @@ pub enum ConnectionState {
|
|||||||
}
|
}
|
||||||
impl ConnectionState {
|
impl ConnectionState {
|
||||||
pub fn is_disconnected(&self) -> bool {
|
pub fn is_disconnected(&self) -> bool {
|
||||||
match *self {
|
matches!(*self, Self::Disconnected)
|
||||||
Self::Disconnected => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pub fn is_connected(&self) -> bool {
|
pub fn is_connected(&self) -> bool {
|
||||||
match *self {
|
matches!(*self, Self::Connected(_, _))
|
||||||
Self::Connected(_, _) => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pub fn is_retrying(&self) -> bool {
|
pub fn is_retrying(&self) -> bool {
|
||||||
match *self {
|
matches!(*self, Self::Retrying(_, _))
|
||||||
Self::Retrying(_, _) => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,13 +13,12 @@ mod command_processor;
|
|||||||
mod settings;
|
mod settings;
|
||||||
mod ui;
|
mod ui;
|
||||||
|
|
||||||
|
#[allow(clippy::all)]
|
||||||
pub mod veilid_client_capnp {
|
pub mod veilid_client_capnp {
|
||||||
include!(concat!(env!("OUT_DIR"), "/proto/veilid_client_capnp.rs"));
|
include!(concat!(env!("OUT_DIR"), "/proto/veilid_client_capnp.rs"));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_command_line<'a>(
|
fn parse_command_line(default_config_path: &OsStr) -> Result<clap::ArgMatches, clap::Error> {
|
||||||
default_config_path: &'a OsStr,
|
|
||||||
) -> Result<clap::ArgMatches<'a>, clap::Error> {
|
|
||||||
let matches = App::new("veilid-cli")
|
let matches = App::new("veilid-cli")
|
||||||
.version("0.1")
|
.version("0.1")
|
||||||
.about("Veilid Console Client")
|
.about("Veilid Console Client")
|
||||||
|
@ -158,13 +158,14 @@ impl veilid_server::Server for VeilidServerImpl {
|
|||||||
|
|
||||||
// --- Client API Server-Side ---------------------------------
|
// --- Client API Server-Side ---------------------------------
|
||||||
|
|
||||||
|
type ClientApiAllFuturesJoinHandle =
|
||||||
|
async_std::task::JoinHandle<Result<Vec<()>, Box<(dyn std::error::Error + 'static)>>>;
|
||||||
|
|
||||||
struct ClientApiInner {
|
struct ClientApiInner {
|
||||||
veilid_api: veilid_core::VeilidAPI,
|
veilid_api: veilid_core::VeilidAPI,
|
||||||
registration_map: Rc<RefCell<RegistrationMap>>,
|
registration_map: Rc<RefCell<RegistrationMap>>,
|
||||||
stop: Eventual,
|
stop: Eventual,
|
||||||
join_handle: Option<
|
join_handle: Option<ClientApiAllFuturesJoinHandle>,
|
||||||
async_std::task::JoinHandle<Result<Vec<()>, Box<(dyn std::error::Error + 'static)>>>,
|
|
||||||
>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ClientApi {
|
pub struct ClientApi {
|
||||||
@ -283,10 +284,11 @@ impl ClientApi {
|
|||||||
let registration_map2 = registration_map1.clone();
|
let registration_map2 = registration_map1.clone();
|
||||||
async_std::task::spawn_local(request.send().promise.map(move |r| match r {
|
async_std::task::spawn_local(request.send().promise.map(move |r| match r {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
if let Some(ref mut s) = registration_map2
|
if let Some(ref mut s) =
|
||||||
.borrow_mut()
|
registration_map2.borrow_mut().registrations.get_mut(&id)
|
||||||
.registrations
|
{
|
||||||
.get_mut(&id) { s.requests_in_flight -= 1; }
|
s.requests_in_flight -= 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
debug!("Got error: {:?}. Dropping registation.", e);
|
debug!("Got error: {:?}. Dropping registation.", e);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
mod client_api;
|
mod client_api;
|
||||||
mod settings;
|
mod settings;
|
||||||
|
|
||||||
|
#[allow(clippy::all)]
|
||||||
pub mod veilid_client_capnp {
|
pub mod veilid_client_capnp {
|
||||||
include!(concat!(env!("OUT_DIR"), "/proto/veilid_client_capnp.rs"));
|
include!(concat!(env!("OUT_DIR"), "/proto/veilid_client_capnp.rs"));
|
||||||
}
|
}
|
||||||
|
@ -276,13 +276,13 @@ pub struct Logging {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct HTTPS {
|
pub struct Https {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub listen_address: NamedSocketAddrs,
|
pub listen_address: NamedSocketAddrs,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct HTTP {
|
pub struct Http {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub listen_address: NamedSocketAddrs,
|
pub listen_address: NamedSocketAddrs,
|
||||||
}
|
}
|
||||||
@ -290,12 +290,12 @@ pub struct HTTP {
|
|||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct Application {
|
pub struct Application {
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
pub https: HTTPS,
|
pub https: Https,
|
||||||
pub http: HTTP,
|
pub http: Http,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct UDP {
|
pub struct Udp {
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
pub socket_pool_size: u32,
|
pub socket_pool_size: u32,
|
||||||
pub listen_address: NamedSocketAddrs,
|
pub listen_address: NamedSocketAddrs,
|
||||||
@ -303,7 +303,7 @@ pub struct UDP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct TCP {
|
pub struct Tcp {
|
||||||
pub connect: bool,
|
pub connect: bool,
|
||||||
pub listen: bool,
|
pub listen: bool,
|
||||||
pub max_connections: u32,
|
pub max_connections: u32,
|
||||||
@ -312,7 +312,7 @@ pub struct TCP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct WS {
|
pub struct Ws {
|
||||||
pub connect: bool,
|
pub connect: bool,
|
||||||
pub listen: bool,
|
pub listen: bool,
|
||||||
pub max_connections: u32,
|
pub max_connections: u32,
|
||||||
@ -322,7 +322,7 @@ pub struct WS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct WSS {
|
pub struct Wss {
|
||||||
pub connect: bool,
|
pub connect: bool,
|
||||||
pub listen: bool,
|
pub listen: bool,
|
||||||
pub max_connections: u32,
|
pub max_connections: u32,
|
||||||
@ -333,21 +333,21 @@ pub struct WSS {
|
|||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct Protocol {
|
pub struct Protocol {
|
||||||
pub udp: UDP,
|
pub udp: Udp,
|
||||||
pub tcp: TCP,
|
pub tcp: Tcp,
|
||||||
pub ws: WS,
|
pub ws: Ws,
|
||||||
pub wss: WSS,
|
pub wss: Wss,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct TLS {
|
pub struct Tls {
|
||||||
pub certificate_path: PathBuf,
|
pub certificate_path: PathBuf,
|
||||||
pub private_key_path: PathBuf,
|
pub private_key_path: PathBuf,
|
||||||
pub connection_initial_timeout: u64,
|
pub connection_initial_timeout: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct RPC {
|
pub struct Rpc {
|
||||||
pub concurrency: u32,
|
pub concurrency: u32,
|
||||||
pub queue_size: u32,
|
pub queue_size: u32,
|
||||||
pub max_timestamp_behind: Option<u64>,
|
pub max_timestamp_behind: Option<u64>,
|
||||||
@ -357,7 +357,7 @@ pub struct RPC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct DHT {
|
pub struct Dht {
|
||||||
pub resolve_node_timeout: Option<u64>,
|
pub resolve_node_timeout: Option<u64>,
|
||||||
pub resolve_node_count: u32,
|
pub resolve_node_count: u32,
|
||||||
pub resolve_node_fanout: u32,
|
pub resolve_node_fanout: u32,
|
||||||
@ -388,13 +388,13 @@ pub struct Network {
|
|||||||
pub node_id: veilid_core::DHTKey,
|
pub node_id: veilid_core::DHTKey,
|
||||||
pub node_id_secret: veilid_core::DHTKeySecret,
|
pub node_id_secret: veilid_core::DHTKeySecret,
|
||||||
pub bootstrap: Vec<ParsedURL>,
|
pub bootstrap: Vec<ParsedURL>,
|
||||||
pub rpc: RPC,
|
pub rpc: Rpc,
|
||||||
pub dht: DHT,
|
pub dht: Dht,
|
||||||
pub upnp: bool,
|
pub upnp: bool,
|
||||||
pub natpmp: bool,
|
pub natpmp: bool,
|
||||||
pub address_filter: bool,
|
pub address_filter: bool,
|
||||||
pub restricted_nat_retries: u32,
|
pub restricted_nat_retries: u32,
|
||||||
pub tls: TLS,
|
pub tls: Tls,
|
||||||
pub application: Application,
|
pub application: Application,
|
||||||
pub protocol: Protocol,
|
pub protocol: Protocol,
|
||||||
pub leases: Leases,
|
pub leases: Leases,
|
||||||
|
@ -16,9 +16,7 @@ use std::str::FromStr;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use veilid_core::xx::SingleShotEventual;
|
use veilid_core::xx::SingleShotEventual;
|
||||||
|
|
||||||
fn parse_command_line<'a>(
|
fn parse_command_line(default_config_path: &OsStr) -> Result<clap::ArgMatches, clap::Error> {
|
||||||
default_config_path: &'a OsStr,
|
|
||||||
) -> Result<clap::ArgMatches<'a>, clap::Error> {
|
|
||||||
let matches = App::new("veilid-server")
|
let matches = App::new("veilid-server")
|
||||||
.version("0.1")
|
.version("0.1")
|
||||||
.about("Veilid Server")
|
.about("Veilid Server")
|
||||||
@ -158,10 +156,7 @@ pub async fn main() -> Result<(), String> {
|
|||||||
settingsrw.logging.file.level = settings::LogLevel::Trace;
|
settingsrw.logging.file.level = settings::LogLevel::Trace;
|
||||||
}
|
}
|
||||||
if matches.is_present("attach") {
|
if matches.is_present("attach") {
|
||||||
settingsrw.auto_attach = match matches.value_of("attach") {
|
settingsrw.auto_attach = !matches!(matches.value_of("attach"), Some("false"));
|
||||||
Some("false") => false,
|
|
||||||
_ => true,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
if matches.occurrences_of("bootstrap") != 0 {
|
if matches.occurrences_of("bootstrap") != 0 {
|
||||||
let bootstrap = match matches.value_of("bootstrap") {
|
let bootstrap = match matches.value_of("bootstrap") {
|
||||||
@ -284,18 +279,10 @@ pub async fn main() -> Result<(), String> {
|
|||||||
// Handle state changes on main thread for capnproto rpc
|
// Handle state changes on main thread for capnproto rpc
|
||||||
let capi2 = capi.clone();
|
let capi2 = capi.clone();
|
||||||
let capi_jh = async_std::task::spawn_local(async move {
|
let capi_jh = async_std::task::spawn_local(async move {
|
||||||
loop {
|
while let Ok(change) = receiver.recv().await {
|
||||||
let change = match receiver.recv().await {
|
if let Some(c) = capi2.borrow_mut().as_mut().cloned() {
|
||||||
Ok(change) => change,
|
c.handle_state_change(change);
|
||||||
Err(_) => {
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let c = match capi2.borrow_mut().as_mut() {
|
|
||||||
Some(some_capi) => some_capi.clone(),
|
|
||||||
None => continue,
|
|
||||||
};
|
|
||||||
c.handle_state_change(change);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -315,11 +302,8 @@ pub async fn main() -> Result<(), String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stop the client api if we have one
|
// Stop the client api if we have one
|
||||||
match capi.borrow_mut().as_mut().cloned() {
|
if let Some(c) = capi.borrow_mut().as_mut().cloned() {
|
||||||
Some(some_capi) => {
|
c.stop().await;
|
||||||
some_capi.stop().await;
|
|
||||||
}
|
|
||||||
None => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shut down Veilid API
|
// Shut down Veilid API
|
||||||
|
Loading…
Reference in New Issue
Block a user