mirror of
https://forgejo.ellis.link/continuwuation/continuwuity/
synced 2026-10-23 13:42:27 +00:00
style: Use string literals instead of u8s
This commit is contained in:
1 parent
959370169a
commit
68d018bd37
2 files changed
+25
-21
No files matched your search
+11
-12
@@ -372,25 +372,24 @@ pub struct Config {
|
||||
|
||||
/// The source to use for discovering the real connecting client IP.
|
||||
///
|
||||
/// Takes the number of any of the following options:
|
||||
/// Takes any of the following options:
|
||||
///
|
||||
/// 0 - Use the IP address of the TCP connection
|
||||
/// 1 - `Cf-Connecting-Ip` header
|
||||
/// 2 - `CloudFront-Viewer-Address` header
|
||||
/// 3 - `Fly-Client-IP` header
|
||||
/// 4 - rightmost value of the `X-Forwarded-For` header
|
||||
/// 5 - `True-Client-Ip` header
|
||||
/// 6 - `X-Envoy-External-Address` header
|
||||
/// 7 - `X-Real-Ip` header
|
||||
/// cf_connecting_ip - `Cf-Connecting-Ip` header
|
||||
/// cloudfront_viewer_address - `CloudFront-Viewer-Address` header
|
||||
/// fly_client_ip - `Fly-Client-IP` header
|
||||
/// x_forwarded_for - rightmost value of the `X-Forwarded-For` header
|
||||
/// true_client_ip - `True-Client-Ip` header
|
||||
/// x_envoy_external_address - `X-Envoy-External-Address` header
|
||||
/// x_real_ip - `X-Real-Ip` header
|
||||
///
|
||||
/// Only change this from `0` if you are certain only your reverse proxy
|
||||
/// Only set this if you are certain only your reverse proxy
|
||||
/// will send the expected header. There is no "is the connecting IP allowed
|
||||
/// to set this header" check; if the header selected is present, it is
|
||||
/// used.
|
||||
///
|
||||
/// default: 0
|
||||
/// Defaults to the IP address actually making the connection.
|
||||
#[serde(default)]
|
||||
pub request_ip_source: u8,
|
||||
pub request_ip_source: Option<String>,
|
||||
|
||||
/// Max request size for file uploads in bytes. Defaults to 20MB.
|
||||
/// Also limits incoming federated media.
|
||||
|
||||
+14
-9
@@ -48,15 +48,20 @@ pub(crate) fn build(services: &Arc<Services>) -> Result<(Router, Guard)> {
|
||||
))]
|
||||
let layers = layers.layer(compression_layer(server));
|
||||
|
||||
let client_ip_layer = match services.config.request_ip_source {
|
||||
| 1 => ClientIpSource::CfConnectingIp,
|
||||
| 2 => ClientIpSource::CloudFrontViewerAddress,
|
||||
| 3 => ClientIpSource::FlyClientIp,
|
||||
| 4 => ClientIpSource::RightmostXForwardedFor,
|
||||
| 5 => ClientIpSource::TrueClientIp,
|
||||
| 6 => ClientIpSource::XEnvoyExternalAddress,
|
||||
| 7 => ClientIpSource::XRealIp,
|
||||
| _ => ClientIpSource::ConnectInfo,
|
||||
let client_ip_layer = match services
|
||||
.config
|
||||
.request_ip_source
|
||||
.as_ref()
|
||||
.map(AsRef::as_ref)
|
||||
{
|
||||
| Some("cf_connecting_ip") => ClientIpSource::CfConnectingIp,
|
||||
| Some("cloudfront_viewer_address") => ClientIpSource::CloudFrontViewerAddress,
|
||||
| Some("fly_client_ip") => ClientIpSource::FlyClientIp,
|
||||
| Some("x_forwarded_for") => ClientIpSource::RightmostXForwardedFor,
|
||||
| Some("true_client_ip") => ClientIpSource::TrueClientIp,
|
||||
| Some("x_envoy_external_address") => ClientIpSource::XEnvoyExternalAddress,
|
||||
| Some("x_real_ip") => ClientIpSource::XRealIp,
|
||||
| None | Some(_) => ClientIpSource::ConnectInfo,
|
||||
};
|
||||
|
||||
let services_ = services.clone();
|
||||
|
||||
Reference in new issue
Block a user