mirror of
https://github.com/rosenpass/rosenpass.git
synced 2025-12-05 20:40:02 -08:00
feat: Disallow unknown fields in rosenpass and rp configuration
This commit is contained in:
@@ -3,11 +3,6 @@ secret_key = "rp-a-secret-key"
|
|||||||
listen = ["127.0.0.1:9999"]
|
listen = ["127.0.0.1:9999"]
|
||||||
verbosity = "Verbose"
|
verbosity = "Verbose"
|
||||||
|
|
||||||
[api]
|
|
||||||
listen_path = []
|
|
||||||
listen_fd = []
|
|
||||||
stream_fd = []
|
|
||||||
|
|
||||||
[[peers]]
|
[[peers]]
|
||||||
public_key = "rp-b-public-key"
|
public_key = "rp-b-public-key"
|
||||||
endpoint = "127.0.0.1:9998"
|
endpoint = "127.0.0.1:9998"
|
||||||
|
|||||||
@@ -3,11 +3,6 @@ secret_key = "rp-b-secret-key"
|
|||||||
listen = ["127.0.0.1:9998"]
|
listen = ["127.0.0.1:9998"]
|
||||||
verbosity = "Verbose"
|
verbosity = "Verbose"
|
||||||
|
|
||||||
[api]
|
|
||||||
listen_path = []
|
|
||||||
listen_fd = []
|
|
||||||
stream_fd = []
|
|
||||||
|
|
||||||
[[peers]]
|
[[peers]]
|
||||||
public_key = "rp-a-public-key"
|
public_key = "rp-a-public-key"
|
||||||
endpoint = "127.0.0.1:9999"
|
endpoint = "127.0.0.1:9999"
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use crate::app_server::AppServer;
|
|||||||
|
|
||||||
/// Configuration options for the Rosenpass API
|
/// Configuration options for the Rosenpass API
|
||||||
#[derive(Debug, Serialize, Deserialize, Default, Clone, PartialEq, Eq)]
|
#[derive(Debug, Serialize, Deserialize, Default, Clone, PartialEq, Eq)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct ApiConfig {
|
pub struct ApiConfig {
|
||||||
/// Where in the file-system to create the unix socket the rosenpass API will be listening for
|
/// Where in the file-system to create the unix socket the rosenpass API will be listening for
|
||||||
/// connections on
|
/// connections on
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ fn empty_api_config() -> crate::api::config::ApiConfig {
|
|||||||
///
|
///
|
||||||
/// i.e. configuration for the `rosenpass exchange` and `rosenpass exchange-config` commands
|
/// i.e. configuration for the `rosenpass exchange` and `rosenpass exchange-config` commands
|
||||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Rosenpass {
|
pub struct Rosenpass {
|
||||||
// TODO: Raise error if secret key or public key alone is set during deserialization
|
// TODO: Raise error if secret key or public key alone is set during deserialization
|
||||||
// SEE: https://github.com/serde-rs/serde/issues/2793
|
// SEE: https://github.com/serde-rs/serde/issues/2793
|
||||||
@@ -75,6 +76,7 @@ pub struct Rosenpass {
|
|||||||
|
|
||||||
/// Public key and secret key locations.
|
/// Public key and secret key locations.
|
||||||
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
|
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Keypair {
|
pub struct Keypair {
|
||||||
/// path to the public key file
|
/// path to the public key file
|
||||||
pub public_key: PathBuf,
|
pub public_key: PathBuf,
|
||||||
@@ -102,6 +104,7 @@ impl Keypair {
|
|||||||
///
|
///
|
||||||
/// - TODO: replace this type with [`log::LevelFilter`], also see <https://github.com/rosenpass/rosenpass/pull/246>
|
/// - TODO: replace this type with [`log::LevelFilter`], also see <https://github.com/rosenpass/rosenpass/pull/246>
|
||||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Copy, Clone)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Copy, Clone)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
pub enum Verbosity {
|
pub enum Verbosity {
|
||||||
Quiet,
|
Quiet,
|
||||||
Verbose,
|
Verbose,
|
||||||
@@ -109,6 +112,7 @@ pub enum Verbosity {
|
|||||||
|
|
||||||
/// The protocol version to be used by a peer.
|
/// The protocol version to be used by a peer.
|
||||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Copy, Clone, Default)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Copy, Clone, Default)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
pub enum ProtocolVersion {
|
pub enum ProtocolVersion {
|
||||||
#[default]
|
#[default]
|
||||||
V02,
|
V02,
|
||||||
@@ -117,6 +121,7 @@ pub enum ProtocolVersion {
|
|||||||
|
|
||||||
/// Configuration data for a single Rosenpass peer
|
/// Configuration data for a single Rosenpass peer
|
||||||
#[derive(Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct RosenpassPeer {
|
pub struct RosenpassPeer {
|
||||||
/// path to the public key of the peer
|
/// path to the public key of the peer
|
||||||
pub public_key: PathBuf,
|
pub public_key: PathBuf,
|
||||||
@@ -152,6 +157,7 @@ pub struct RosenpassPeer {
|
|||||||
|
|
||||||
/// Information for supplying exchanged keys directly to WireGuard
|
/// Information for supplying exchanged keys directly to WireGuard
|
||||||
#[derive(Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct WireGuard {
|
pub struct WireGuard {
|
||||||
/// Name of the WireGuard interface to supply with pre-shared keys generated by the Rosenpass
|
/// Name of the WireGuard interface to supply with pre-shared keys generated by the Rosenpass
|
||||||
/// key exchange
|
/// key exchange
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use crate::key::WG_B64_LEN;
|
|||||||
/// a directory for storing public keys and optionally an IP address and port of the endpoint,
|
/// a directory for storing public keys and optionally an IP address and port of the endpoint,
|
||||||
/// for how long the connection should be kept alive and a list of allowed IPs for the peer.
|
/// for how long the connection should be kept alive and a list of allowed IPs for the peer.
|
||||||
#[derive(Default, Deserialize)]
|
#[derive(Default, Deserialize)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct ExchangePeer {
|
pub struct ExchangePeer {
|
||||||
/// Directory where public keys are stored
|
/// Directory where public keys are stored
|
||||||
pub public_keys_dir: PathBuf,
|
pub public_keys_dir: PathBuf,
|
||||||
@@ -31,6 +32,7 @@ pub struct ExchangePeer {
|
|||||||
|
|
||||||
/// Options for the exchange operation of the `rp` binary.
|
/// Options for the exchange operation of the `rp` binary.
|
||||||
#[derive(Default, Deserialize)]
|
#[derive(Default, Deserialize)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct ExchangeOptions {
|
pub struct ExchangeOptions {
|
||||||
/// Whether the cli output should be verbose.
|
/// Whether the cli output should be verbose.
|
||||||
pub verbose: bool,
|
pub verbose: bool,
|
||||||
|
|||||||
Reference in New Issue
Block a user