1use crate::acl::HttpRequestMethod;
4use std::net::{IpAddr, SocketAddr};
5use std::ops::RangeInclusive;
6
7use thiserror::Error;
8
9#[non_exhaustive]
13#[derive(Clone, Debug, Eq, Hash, PartialEq, Error)]
14pub enum AddError {
15 #[error("The HTTP method `{0:?}` is already allowed.")]
17 AlreadyAllowedMethod(HttpRequestMethod),
18 #[error("The HTTP method `{0:?}` is already denied.")]
20 AlreadyDeniedMethod(HttpRequestMethod),
21 #[error("The host `{0}` is already allowed.")]
23 AlreadyAllowedHost(String),
24 #[error("The host `{0}` is already denied.")]
26 AlreadyDeniedHost(String),
27 #[error("The port range `{0:?}` is already allowed.")]
29 AlreadyAllowedPortRange(RangeInclusive<u16>),
30 #[error("The port range `{0:?}` is already denied.")]
32 AlreadyDeniedPortRange(RangeInclusive<u16>),
33 #[error("The IP range `{0:?}` is already allowed.")]
35 AlreadyAllowedIpRange(RangeInclusive<IpAddr>),
36 #[error("The IP range `{0:?}` is already denied.")]
38 AlreadyDeniedIpRange(RangeInclusive<IpAddr>),
39 #[error(
42 "The IP range `{0:?}` is not a global IP range, and non-global IP ranges are not allowed."
43 )]
44 NonGlobalIpRange(RangeInclusive<IpAddr>),
45 #[error("The header `{0}` is already allowed.")]
47 AlreadyAllowedHeader(String, Option<String>),
48 #[error("The header `{0}` is already denied.")]
50 AlreadyDeniedHeader(String, Option<String>),
51 #[error("The URL path `{0}` is already allowed.")]
53 AlreadyAllowedUrlPath(String),
54 #[error("The URL path `{0}` is already denied.")]
56 AlreadyDeniedUrlPath(String),
57 #[error("The static DNS mapping for `{0}`-`{1}` is already present.")]
59 AlreadyPresentStaticDnsMapping(String, SocketAddr),
60 #[error("The trusted static DNS mapping for `{0}`-`{1}` is already present.")]
62 AlreadyPresentTrustedStaticDnsMapping(String, SocketAddr),
63 #[error("The entity `{0}` is not allowed or denied because it is invalid.")]
65 InvalidEntity(String),
66 #[error("The entity `{0}` is not unique.")]
68 NotUnique(String),
69 #[error("The entity `{0}` overlaps with another.")]
71 Overlaps(String),
72 #[error("The entity `{0}` is both allowed and denied.")]
74 BothAllowedAndDenied(String),
75 #[error("An error occurred: `{0}`")]
77 Error(String),
78}