diff --git a/appmgr/src/config/mod.rs b/appmgr/src/config/mod.rs index bf017b682..fe13386a4 100644 --- a/appmgr/src/config/mod.rs +++ b/appmgr/src/config/mod.rs @@ -1,7 +1,6 @@ use std::collections::{BTreeMap, BTreeSet}; use std::time::Duration; -use bollard::container::KillContainerOptions; use color_eyre::eyre::eyre; use futures::future::{BoxFuture, FutureExt}; use indexmap::IndexSet; @@ -13,7 +12,6 @@ use rpc_toolkit::command; use serde_json::Value; use tracing::instrument; -use crate::action::docker::DockerAction; use crate::context::RpcContext; use crate::db::model::CurrentDependencyInfo; use crate::db::util::WithRevision; diff --git a/appmgr/src/config/spec.rs b/appmgr/src/config/spec.rs index da7b6481c..992cdb7e7 100644 --- a/appmgr/src/config/spec.rs +++ b/appmgr/src/config/spec.rs @@ -1869,12 +1869,14 @@ impl fmt::Display for TorKeyPointer { #[serde(tag = "target")] pub enum SystemPointerSpec {} impl fmt::Display for SystemPointerSpec { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "SYSTEM: {}", match *self {}) + fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + // write!(f, "SYSTEM: {}", match *self {}) + Ok(()) } } impl SystemPointerSpec { - async fn deref(&self, db: &mut Db) -> Result { + async fn deref(&self, _db: &mut Db) -> Result { + #[allow(unreachable_code)] Ok(match *self {}) } } @@ -1898,7 +1900,7 @@ impl ValueSpec for SystemPointerSpec { } async fn update( &self, - ctx: &RpcContext, + _ctx: &RpcContext, db: &mut Db, _manifest: &Manifest, _config_overrides: &BTreeMap, @@ -1907,9 +1909,10 @@ impl ValueSpec for SystemPointerSpec { *value = self.deref(db).await?; Ok(()) } - fn pointers(&self, value: &Value) -> Result, NoMatchWithPath> { + fn pointers(&self, _value: &Value) -> Result, NoMatchWithPath> { let mut pointers = BTreeSet::new(); pointers.insert(ValueSpecPointer::System(self.clone())); + #[allow(unreachable_code)] Ok(pointers) } fn requires(&self, _id: &PackageId, _value: &Value) -> bool { @@ -1919,256 +1922,3 @@ impl ValueSpec for SystemPointerSpec { false } } - -#[cfg(test)] -mod test { - use rand::SeedableRng; - - use super::*; - - #[test] - fn test_config() { - let spec = serde_json::json!({ - "randomEnum": { - "name": "Random Enum", - "type": "enum", - "default": "null", - "description": "This is not even real.", - "changeWarning": "Be careful chnaging this!", - "values": [ - "null", - "option1", - "option2", - "option3" - ] - }, - "testnet": { - "name": "Testnet", - "type": "boolean", - "description": "determines whether your node is running ontestnet or mainnet", - "changeWarning": "Chain will have to resync!", - "default": false - }, - "favoriteNumber": { - "name": "Favorite Number", - "type": "number", - "integral": false, - "description": "Your favorite number of all time", - "changeWarning": "Once you set this number, it can never be changed without severe consequences.", - "nullable": false, - "default": 7, - "range": "(-100,100]" - }, - "secondaryNumbers": { - "name": "Unlucky Numbers", - "type": "list", - "subtype": "number", - "description": "Numbers that you like but are not your top favorite.", - "spec": { - "type": "number", - "integral": false, - "range": "[-100,200)" - }, - "range": "[0,10]", - "default": [ - 2, - 3 - ] - }, - "rpcsettings": { - "name": "RPC Settings", - "type": "object", - "description": "rpc username and password", - "changeWarning": "Adding RPC users gives them special permissions on your node.", - "nullable": false, - "nullByDefault": false, - "spec": { - "laws": { - "name": "Laws", - "type": "object", - "description": "the law of the realm", - "nullable": true, - "nullByDefault": true, - "spec": { - "law1": { - "name": "First Law", - "type": "string", - "description": "the first law", - "nullable": true - }, - "law2": { - "name": "Second Law", - "type": "string", - "description": "the second law", - "nullable": true - } - } - }, - "rulemakers": { - "name": "Rule Makers", - "type": "list", - "subtype": "object", - "description": "the people who make the rules", - "range": "[0,2]", - "default": [], - "spec": { - "type": "object", - "spec": { - "rulemakername": { - "name": "Rulemaker Name", - "type": "string", - "description": "the name of the rule maker", - "nullable": false, - "default": { - "charset": "a-g,2-9", - "len": 12 - } - }, - "rulemakerip": { - "name": "Rulemaker IP", - "type": "string", - "description": "the ip of the rule maker", - "nullable": false, - "default": "192.168.1.0", - "pattern": "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$", - "patternDescription": "may only contain numbers and periods" - } - } - } - }, - "rpcuser": { - "name": "RPC Username", - "type": "string", - "description": "rpc username", - "nullable": false, - "default": "defaultrpcusername", - "pattern": "^[a-zA-Z]+$", - "patternDescription": "must contain only letters." - }, - "rpcpass": { - "name": "RPC User Password", - "type": "string", - "description": "rpc password", - "nullable": false, - "default": { - "charset": "a-z,A-Z,2-9", - "len": 20 - } - } - } - }, - "advanced": { - "name": "Advanced", - "type": "object", - "description": "Advanced settings", - "nullable": false, - "nullByDefault": false, - "spec": { - "notifications": { - "name": "Notification Preferences", - "type": "list", - "subtype": "enum", - "description": "how you want to be notified", - "range": "[1,3]", - "default": [ - "email" - ], - "spec": { - "type": "enum", - "values": [ - "email", - "text", - "call", - "push", - "webhook" - ] - } - } - } - }, - "bitcoinNode": { - "name": "Bitcoin Node Settings", - "type": "union", - "description": "The node settings", - "default": "internal", - "tag": { - "id": "type", - "name": "Type", - "variantNames": {} - }, - "Variant": { - "internal": { - "lan-address": { - "name": "LAN Address", - "type": "pointer", - "subtype": "package", - "target": "lan-address", - "package-id": "bitcoind", - "description": "the lan address" - } - }, - "external": { - "public-domain": { - "name": "Public Domain", - "type": "string", - "description": "the public address of the node", - "nullable": false, - "default": "bitcoinnode.com", - "pattern": ".*", - "patternDescription": "anything" - } - } - } - }, - "port": { - "name": "Port", - "type": "number", - "integral": true, - "description": "the default port for your Bitcoin node. default: 8333, testnet: 18333, regtest: 18444", - "nullable": true, - "default": 8333, - "range": "[0, 9999]", - "units": "m/s" - }, - "maxconnections": { - "name": "Max Connections", - "type": "string", - "description": "the maximum number of commections allowed to your Bitcoin node", - "nullable": true - }, - "rpcallowip": { - "name": "RPC Allowed IPs", - "type": "list", - "subtype": "string", - "description": "external ip addresses that are authorized to access your Bitcoin node", - "changeWarning": "Any IP you allow here will have RPC access to your Bitcoin node.", - "range": "[1,10]", - "default": [ - "192.168.1.1" - ], - "spec": { - "type": "string", - "pattern": "((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|((^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$)|(^[a-z2-7]{16}\\.onion$)|(^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$))", - "patternDescription": "must be a valid ipv4, ipv6, or domain name" - } - }, - "rpcauth": { - "name": "RPC Auth", - "type": "list", - "subtype": "string", - "description": "api keys that are authorized to access your Bitcoin node.", - "range": "[0,*)", - "default": [], - "spec": { - "type": "string" - } - } - }); - let spec: ConfigSpec = serde_json::from_value(spec).unwrap(); - spec.validate(todo!()).unwrap(); - let config = spec - .gen(&mut rand::rngs::StdRng::from_entropy(), &None) - .unwrap(); - spec.matches(&config).unwrap(); - } -} diff --git a/appmgr/src/dependencies.rs b/appmgr/src/dependencies.rs index bc47af862..466140776 100644 --- a/appmgr/src/dependencies.rs +++ b/appmgr/src/dependencies.rs @@ -110,9 +110,7 @@ impl DependencyError { | (_, DependencyError::HealthChecksFailed { failures }) => { DependencyError::HealthChecksFailed { failures } } - (DependencyError::Transitive, _) | (_, DependencyError::Transitive) => { - DependencyError::Transitive - } + (DependencyError::Transitive, _) => DependencyError::Transitive, } } #[instrument(skip(ctx, db))] diff --git a/appmgr/src/install/mod.rs b/appmgr/src/install/mod.rs index 989cb9223..18e521978 100644 --- a/appmgr/src/install/mod.rs +++ b/appmgr/src/install/mod.rs @@ -126,8 +126,8 @@ pub async fn install( match pde.take() { Some(PackageDataEntry::Installed { installed, - manifest: _manifest, static_files, + .. }) => { *pde = Some(PackageDataEntry::Updating { install_progress: progress.clone(), @@ -367,7 +367,7 @@ async fn cli_install( } else { let params = match (target.split_once("@"), version_spec) { (Some((pkg, v)), None) => serde_json::json!({ "id": pkg, "version-spec": v }), - (Some((pkg, v)), Some(_)) => { + (Some(_), Some(_)) => { return Err(crate::Error::new( eyre!("Invalid package id {}", target), ErrorKind::InvalidRequest, diff --git a/appmgr/src/migration.rs b/appmgr/src/migration.rs index a01825141..9209f77ab 100644 --- a/appmgr/src/migration.rs +++ b/appmgr/src/migration.rs @@ -1,6 +1,6 @@ use color_eyre::eyre::eyre; use emver::VersionRange; -use futures::{Future, FutureExt, TryFutureExt}; +use futures::{Future, FutureExt}; use indexmap::IndexMap; use patch_db::HasModel; use serde::{Deserialize, Serialize}; diff --git a/appmgr/src/net/nginx.rs b/appmgr/src/net/nginx.rs index bf1e69847..247d8761a 100644 --- a/appmgr/src/net/nginx.rs +++ b/appmgr/src/net/nginx.rs @@ -152,7 +152,6 @@ impl NginxControllerInner { match self.interfaces.get_mut(&package) { None => { let info = PackageNetInfo { - _ip: ipv4, interfaces: interface_map, }; self.interfaces.insert(package, info); @@ -225,7 +224,6 @@ impl NginxControllerInner { } } struct PackageNetInfo { - _ip: Ipv4Addr, interfaces: BTreeMap, } pub struct InterfaceMetadata { diff --git a/appmgr/src/net/ssl.rs b/appmgr/src/net/ssl.rs index 675634945..a59926fde 100644 --- a/appmgr/src/net/ssl.rs +++ b/appmgr/src/net/ssl.rs @@ -1,5 +1,5 @@ use std::cmp::Ordering; -use std::path::{Path, PathBuf}; +use std::path::Path; use color_eyre::eyre::eyre; use futures::FutureExt; diff --git a/appmgr/src/s9pk/header.rs b/appmgr/src/s9pk/header.rs index d2964eb95..4d6011d47 100644 --- a/appmgr/src/s9pk/header.rs +++ b/appmgr/src/s9pk/header.rs @@ -115,6 +115,7 @@ impl TableOfContents { ) }) } + #[allow(dead_code)] fn as_opt(fs: FileSection) -> Option { if fs.position | fs.length == 0 { // 0/0 is not a valid file section diff --git a/appmgr/src/static_server.rs b/appmgr/src/static_server.rs index d3950004c..fc86bc51a 100644 --- a/appmgr/src/static_server.rs +++ b/appmgr/src/static_server.rs @@ -105,7 +105,7 @@ fn server_error() -> Response { } async fn file_send( _valid_session: HasValidSession, - ctx: &RpcContext, + _ctx: &RpcContext, path: impl AsRef, ) -> Result, Error> { // Serve a file by asynchronously reading it by chunks using tokio-util crate. diff --git a/rpc-toolkit b/rpc-toolkit index bd1a1b8a3..b4d19d71e 160000 --- a/rpc-toolkit +++ b/rpc-toolkit @@ -1 +1 @@ -Subproject commit bd1a1b8a31fc9cf30a6faafd67874cc53b9a50e8 +Subproject commit b4d19d71e03990ef192587b4d4bf87fd801af601