Make every Config type implement Eq.
Doing this is necessary for reconfiguration support, and will help a lot with testing, too.
This commit is contained in:
parent
e7fdf05f50
commit
40ff7113d4
|
@ -32,7 +32,7 @@ pub mod dir {
|
||||||
///
|
///
|
||||||
/// This type is immutable once constructed. To create an object of this type,
|
/// This type is immutable once constructed. To create an object of this type,
|
||||||
/// use [`ClientAddrConfigBuilder`].
|
/// use [`ClientAddrConfigBuilder`].
|
||||||
#[derive(Debug, Clone, Builder, Deserialize)]
|
#[derive(Debug, Clone, Builder, Deserialize, Eq, PartialEq)]
|
||||||
#[builder(build_fn(error = "ConfigBuildError"))]
|
#[builder(build_fn(error = "ConfigBuildError"))]
|
||||||
pub struct ClientAddrConfig {
|
pub struct ClientAddrConfig {
|
||||||
/// Should we allow attempts to make Tor connections to local addresses?
|
/// Should we allow attempts to make Tor connections to local addresses?
|
||||||
|
@ -72,7 +72,7 @@ impl ClientAddrConfig {
|
||||||
/// Configuration for where information should be stored on disk.
|
/// Configuration for where information should be stored on disk.
|
||||||
///
|
///
|
||||||
/// This section is for read/write storage.
|
/// This section is for read/write storage.
|
||||||
#[derive(Deserialize, Debug, Clone, Builder)]
|
#[derive(Deserialize, Debug, Clone, Builder, Eq, PartialEq)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
#[builder(build_fn(error = "ConfigBuildError"))]
|
#[builder(build_fn(error = "ConfigBuildError"))]
|
||||||
pub struct StorageConfig {
|
pub struct StorageConfig {
|
||||||
|
@ -135,7 +135,7 @@ impl From<StorageConfig> for StorageConfigBuilder {
|
||||||
///
|
///
|
||||||
/// Finally, you can get fine-grained control over the members of a a
|
/// Finally, you can get fine-grained control over the members of a a
|
||||||
/// TorClientConfig using [`TorClientConfigBuilder`].
|
/// TorClientConfig using [`TorClientConfigBuilder`].
|
||||||
#[derive(Clone, Debug, Builder)]
|
#[derive(Clone, Debug, Builder, Eq, PartialEq)]
|
||||||
#[builder(build_fn(error = "ConfigBuildError"))]
|
#[builder(build_fn(error = "ConfigBuildError"))]
|
||||||
pub struct TorClientConfig {
|
pub struct TorClientConfig {
|
||||||
/// Information about the Tor network we want to connect to.
|
/// Information about the Tor network we want to connect to.
|
||||||
|
|
|
@ -13,7 +13,7 @@ use tor_config::ConfigBuildError;
|
||||||
pub(crate) const ARTI_DEFAULTS: &str = concat!(include_str!("./arti_defaults.toml"),);
|
pub(crate) const ARTI_DEFAULTS: &str = concat!(include_str!("./arti_defaults.toml"),);
|
||||||
|
|
||||||
/// Structure to hold our logging configuration options
|
/// Structure to hold our logging configuration options
|
||||||
#[derive(Deserialize, Debug, Clone, Builder)]
|
#[derive(Deserialize, Debug, Clone, Builder, Eq, PartialEq)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
#[non_exhaustive] // TODO(nickm) remove public elements when I revise this.
|
#[non_exhaustive] // TODO(nickm) remove public elements when I revise this.
|
||||||
#[builder(build_fn(error = "ConfigBuildError"))]
|
#[builder(build_fn(error = "ConfigBuildError"))]
|
||||||
|
@ -59,7 +59,7 @@ impl From<LoggingConfig> for LoggingConfigBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configuration for one or more proxy listeners.
|
/// Configuration for one or more proxy listeners.
|
||||||
#[derive(Deserialize, Debug, Clone, Builder)]
|
#[derive(Deserialize, Debug, Clone, Builder, Eq, PartialEq)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
#[builder(build_fn(error = "ConfigBuildError"))]
|
#[builder(build_fn(error = "ConfigBuildError"))]
|
||||||
pub struct ProxyConfig {
|
pub struct ProxyConfig {
|
||||||
|
@ -108,7 +108,7 @@ impl From<ProxyConfig> for ProxyConfigBuilder {
|
||||||
///
|
///
|
||||||
/// NOTE: These are NOT the final options or their final layout.
|
/// NOTE: These are NOT the final options or their final layout.
|
||||||
/// Expect NO stability here.
|
/// Expect NO stability here.
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone, Eq, PartialEq)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct ArtiConfig {
|
pub struct ArtiConfig {
|
||||||
/// Configuration for proxy listeners
|
/// Configuration for proxy listeners
|
||||||
|
|
|
@ -15,7 +15,7 @@ use std::time::Duration;
|
||||||
///
|
///
|
||||||
/// This type is immutable once constructed. To build one, use
|
/// This type is immutable once constructed. To build one, use
|
||||||
/// [`PathConfigBuilder`], or deserialize it from a string.
|
/// [`PathConfigBuilder`], or deserialize it from a string.
|
||||||
#[derive(Debug, Clone, Builder, Deserialize)]
|
#[derive(Debug, Clone, Builder, Deserialize, Eq, PartialEq)]
|
||||||
#[builder(build_fn(error = "ConfigBuildError"))]
|
#[builder(build_fn(error = "ConfigBuildError"))]
|
||||||
pub struct PathConfig {
|
pub struct PathConfig {
|
||||||
/// Set the length of a bit-prefix for a default IPv4 subnet-family.
|
/// Set the length of a bit-prefix for a default IPv4 subnet-family.
|
||||||
|
@ -80,7 +80,7 @@ impl From<PathConfig> for PathConfigBuilder {
|
||||||
///
|
///
|
||||||
/// This type is immutable once constructd. To create an object of this
|
/// This type is immutable once constructd. To create an object of this
|
||||||
/// type, use [`CircuitTimingBuilder`].
|
/// type, use [`CircuitTimingBuilder`].
|
||||||
#[derive(Debug, Clone, Builder, Deserialize)]
|
#[derive(Debug, Clone, Builder, Deserialize, Eq, PartialEq)]
|
||||||
#[builder(build_fn(error = "ConfigBuildError"))]
|
#[builder(build_fn(error = "ConfigBuildError"))]
|
||||||
pub struct CircuitTiming {
|
pub struct CircuitTiming {
|
||||||
/// How long after a circuit has first been used should we give
|
/// How long after a circuit has first been used should we give
|
||||||
|
@ -170,7 +170,7 @@ impl From<CircuitTiming> for CircuitTimingBuilder {
|
||||||
/// this type, use [`CircMgrConfigBuilder`], or deserialize it from a
|
/// this type, use [`CircMgrConfigBuilder`], or deserialize it from a
|
||||||
/// string. (Arti generally uses Toml for configuration, but you can
|
/// string. (Arti generally uses Toml for configuration, but you can
|
||||||
/// use other formats if you prefer.)
|
/// use other formats if you prefer.)
|
||||||
#[derive(Debug, Clone, Builder, Default)]
|
#[derive(Debug, Clone, Builder, Default, Eq, PartialEq)]
|
||||||
#[builder(build_fn(error = "ConfigBuildError"))]
|
#[builder(build_fn(error = "ConfigBuildError"))]
|
||||||
pub struct CircMgrConfig {
|
pub struct CircMgrConfig {
|
||||||
/// Override the default required distance for two relays to share
|
/// Override the default required distance for two relays to share
|
||||||
|
|
|
@ -24,12 +24,12 @@ use serde::Deserialize;
|
||||||
/// These variables are implemented using the `directories` crate, and
|
/// These variables are implemented using the `directories` crate, and
|
||||||
/// so should use appropriate system-specific overrides under the
|
/// so should use appropriate system-specific overrides under the
|
||||||
/// hood.
|
/// hood.
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
pub struct CfgPath(PathInner);
|
pub struct CfgPath(PathInner);
|
||||||
|
|
||||||
/// Inner implementation of CfgPath
|
/// Inner implementation of CfgPath
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
enum PathInner {
|
enum PathInner {
|
||||||
/// A path that should be expanded from a string using ShellExpand.
|
/// A path that should be expanded from a string using ShellExpand.
|
||||||
|
|
|
@ -13,7 +13,7 @@ use tor_netdoc::doc::authcert::{AuthCert, AuthCertKeyIds};
|
||||||
// Note that we do *not* set serde(deny_unknown_fields)] on this structure:
|
// Note that we do *not* set serde(deny_unknown_fields)] on this structure:
|
||||||
// we want our authorities format to be future-proof against adding new info
|
// we want our authorities format to be future-proof against adding new info
|
||||||
// about each authority.
|
// about each authority.
|
||||||
#[derive(Deserialize, Debug, Clone, Builder)]
|
#[derive(Deserialize, Debug, Clone, Builder, Eq, PartialEq)]
|
||||||
pub struct Authority {
|
pub struct Authority {
|
||||||
/// A memorable nickname for this authority.
|
/// A memorable nickname for this authority.
|
||||||
#[builder(setter(into))]
|
#[builder(setter(into))]
|
||||||
|
|
|
@ -26,7 +26,7 @@ use serde::Deserialize;
|
||||||
///
|
///
|
||||||
/// This type is immutable once constructed. To make one, use
|
/// This type is immutable once constructed. To make one, use
|
||||||
/// [`NetworkConfigBuilder`], or deserialize it from a string.
|
/// [`NetworkConfigBuilder`], or deserialize it from a string.
|
||||||
#[derive(Deserialize, Debug, Clone, Builder)]
|
#[derive(Deserialize, Debug, Clone, Builder, Eq, PartialEq)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
#[builder(build_fn(validate = "Self::validate", error = "ConfigBuildError"))]
|
#[builder(build_fn(validate = "Self::validate", error = "ConfigBuildError"))]
|
||||||
pub struct NetworkConfig {
|
pub struct NetworkConfig {
|
||||||
|
@ -103,7 +103,7 @@ impl NetworkConfigBuilder {
|
||||||
///
|
///
|
||||||
/// This type is immutable once constructed. To make one, use
|
/// This type is immutable once constructed. To make one, use
|
||||||
/// [`DownloadScheduleConfigBuilder`], or deserialize it from a string.
|
/// [`DownloadScheduleConfigBuilder`], or deserialize it from a string.
|
||||||
#[derive(Deserialize, Debug, Clone, Builder)]
|
#[derive(Deserialize, Debug, Clone, Builder, Eq, PartialEq)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
#[builder(build_fn(error = "ConfigBuildError"))]
|
#[builder(build_fn(error = "ConfigBuildError"))]
|
||||||
pub struct DownloadScheduleConfig {
|
pub struct DownloadScheduleConfig {
|
||||||
|
@ -172,7 +172,7 @@ impl From<DownloadScheduleConfig> for DownloadScheduleConfigBuilder {
|
||||||
/// To create an object of this type, use [`DirMgrConfigBuilder`], or
|
/// To create an object of this type, use [`DirMgrConfigBuilder`], or
|
||||||
/// deserialize it from a string. (Arti generally uses Toml for
|
/// deserialize it from a string. (Arti generally uses Toml for
|
||||||
/// configuration, but you can use other formats if you prefer.)
|
/// configuration, but you can use other formats if you prefer.)
|
||||||
#[derive(Debug, Clone, Builder)]
|
#[derive(Debug, Clone, Builder, Eq, PartialEq)]
|
||||||
#[builder(build_fn(error = "ConfigBuildError"))]
|
#[builder(build_fn(error = "ConfigBuildError"))]
|
||||||
pub struct DirMgrConfig {
|
pub struct DirMgrConfig {
|
||||||
/// Location to use for storing and reading current-format
|
/// Location to use for storing and reading current-format
|
||||||
|
|
|
@ -25,7 +25,7 @@ use std::net::SocketAddr;
|
||||||
// Note that we do *not* set serde(deny_unknown_fields) on this
|
// Note that we do *not* set serde(deny_unknown_fields) on this
|
||||||
// structure: we want our fallback directory configuration format to
|
// structure: we want our fallback directory configuration format to
|
||||||
// be future-proof against adding new info about each fallback.
|
// be future-proof against adding new info about each fallback.
|
||||||
#[derive(Debug, Clone, Deserialize, Builder)]
|
#[derive(Debug, Clone, Deserialize, Builder, Eq, PartialEq)]
|
||||||
#[builder(build_fn(validate = "FallbackDirBuilder::validate", error = "ConfigBuildError"))]
|
#[builder(build_fn(validate = "FallbackDirBuilder::validate", error = "ConfigBuildError"))]
|
||||||
pub struct FallbackDir {
|
pub struct FallbackDir {
|
||||||
/// RSA identity for the directory relay
|
/// RSA identity for the directory relay
|
||||||
|
|
|
@ -142,7 +142,7 @@ impl Lifetime {
|
||||||
/// These are used to describe current settings for the Tor network,
|
/// These are used to describe current settings for the Tor network,
|
||||||
/// current weighting parameters for path selection, and so on. They're
|
/// current weighting parameters for path selection, and so on. They're
|
||||||
/// encoded with a space-separated K=V format.
|
/// encoded with a space-separated K=V format.
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default, Eq, PartialEq)]
|
||||||
pub struct NetParams<T> {
|
pub struct NetParams<T> {
|
||||||
/// Map from keys to values.
|
/// Map from keys to values.
|
||||||
params: HashMap<String, T>,
|
params: HashMap<String, T>,
|
||||||
|
|
Loading…
Reference in New Issue