rustfs_config/constants/protocols.rs
1// Copyright 2024 RustFS Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Protocol server configuration constants
16
17/// Default FTP server bind address (non-encrypted)
18pub const DEFAULT_FTP_ADDRESS: &str = "0.0.0.0:8021";
19
20/// Default FTPS server bind address (FTP over TLS)
21pub const DEFAULT_FTPS_ADDRESS: &str = "0.0.0.0:8022";
22
23/// Default FTP passive ports range (optional)
24pub const DEFAULT_FTP_PASSIVE_PORTS: Option<&str> = None;
25
26/// Default FTPS passive ports range (optional)
27pub const DEFAULT_FTPS_PASSIVE_PORTS: Option<&str> = None;
28
29/// Default FTP external IP (auto-detected)
30pub const DEFAULT_FTP_EXTERNAL_IP: Option<&str> = None;
31
32/// Default FTPS external IP (auto-detected)
33pub const DEFAULT_FTPS_EXTERNAL_IP: Option<&str> = None;
34
35/// Environment variable names
36pub const ENV_FTP_ENABLE: &str = "RUSTFS_FTP_ENABLE";
37pub const ENV_FTP_ADDRESS: &str = "RUSTFS_FTP_ADDRESS";
38pub const ENV_FTP_PASSIVE_PORTS: &str = "RUSTFS_FTP_PASSIVE_PORTS";
39pub const ENV_FTP_EXTERNAL_IP: &str = "RUSTFS_FTP_EXTERNAL_IP";
40
41pub const ENV_FTPS_ENABLE: &str = "RUSTFS_FTPS_ENABLE";
42pub const ENV_FTPS_ADDRESS: &str = "RUSTFS_FTPS_ADDRESS";
43pub const ENV_FTPS_TLS_ENABLED: &str = "RUSTFS_FTPS_TLS_ENABLED";
44pub const ENV_FTPS_CERTS_DIR: &str = "RUSTFS_FTPS_CERTS_DIR";
45pub const ENV_FTPS_CA_FILE: &str = "RUSTFS_FTPS_CA_FILE";
46pub const ENV_FTPS_PASSIVE_PORTS: &str = "RUSTFS_FTPS_PASSIVE_PORTS";
47pub const ENV_FTPS_EXTERNAL_IP: &str = "RUSTFS_FTPS_EXTERNAL_IP";
48
49/// Default WebDAV server bind address
50pub const DEFAULT_WEBDAV_ADDRESS: &str = "0.0.0.0:8080";
51
52/// WebDAV environment variable names
53pub const ENV_WEBDAV_ENABLE: &str = "RUSTFS_WEBDAV_ENABLE";
54pub const ENV_WEBDAV_ADDRESS: &str = "RUSTFS_WEBDAV_ADDRESS";
55pub const ENV_WEBDAV_TLS_ENABLED: &str = "RUSTFS_WEBDAV_TLS_ENABLED";
56pub const ENV_WEBDAV_CERTS_DIR: &str = "RUSTFS_WEBDAV_CERTS_DIR";
57pub const ENV_WEBDAV_CA_FILE: &str = "RUSTFS_WEBDAV_CA_FILE";
58pub const ENV_WEBDAV_MAX_BODY_SIZE: &str = "RUSTFS_WEBDAV_MAX_BODY_SIZE";
59pub const ENV_WEBDAV_REQUEST_TIMEOUT: &str = "RUSTFS_WEBDAV_REQUEST_TIMEOUT";
60pub const ENV_WEBDAV_MAX_CONNECTIONS: &str = "RUSTFS_WEBDAV_MAX_CONNECTIONS";
61
62/// Default SFTP server bind address.
63pub const DEFAULT_SFTP_ADDRESS: &str = "0.0.0.0:2222";
64
65/// Default for SFTP host-key directory. None means no default. Operators
66/// must set RUSTFS_SFTP_HOST_KEY_DIR explicitly when SFTP is enabled.
67pub const DEFAULT_SFTP_HOST_KEY_DIR: Option<&str> = None;
68
69/// SFTP environment variable names.
70pub const ENV_SFTP_ENABLE: &str = "RUSTFS_SFTP_ENABLE";
71pub const ENV_SFTP_ADDRESS: &str = "RUSTFS_SFTP_ADDRESS";
72pub const ENV_SFTP_HOST_KEY_DIR: &str = "RUSTFS_SFTP_HOST_KEY_DIR";
73pub const ENV_SFTP_HOST_KEY_RELOAD_ENABLE: &str = "RUSTFS_SFTP_HOST_KEY_RELOAD_ENABLE";
74pub const ENV_SFTP_HOST_KEY_RELOAD_INTERVAL: &str = "RUSTFS_SFTP_HOST_KEY_RELOAD_INTERVAL";
75pub const ENV_SFTP_IDLE_TIMEOUT: &str = "RUSTFS_SFTP_IDLE_TIMEOUT";
76/// S3 multipart part size in bytes. Default DEFAULT_SFTP_PART_SIZE (16 MiB).
77/// Valid range 5 MiB to 5 GiB (S3 protocol bounds), enforced at startup.
78///
79/// The per-upload size ceiling is part_size * 10_000 (the S3 parts cap),
80/// so the default caps single uploads at 160 GiB. Deployments expecting
81/// larger single files must raise this: 64 MiB -> 640 GiB, 128 MiB ->
82/// 1.25 TiB, 512 MiB -> 5 TiB (S3 object max). Rename is not affected;
83/// multipart_copy scales the per-part size dynamically and handles up
84/// to the 5 TiB S3 object limit regardless of this setting.
85pub const ENV_SFTP_PART_SIZE: &str = "RUSTFS_SFTP_PART_SIZE";
86pub const ENV_SFTP_READ_ONLY: &str = "RUSTFS_SFTP_READ_ONLY";
87pub const ENV_SFTP_BANNER: &str = "RUSTFS_SFTP_BANNER";
88/// Optional environment variable. If RUSTFS_SFTP_HANDLES_PER_SESSION
89/// is not set in the process environment, the server uses the default
90/// of 64 handles per session and emits no warning. If set, the value
91/// must be in the inclusive range 8 to 1024. Out-of-range values fall
92/// back to the default of 64 with a warn-level log naming the
93/// requested value and the bounds.
94///
95/// Caps the maximum number of simultaneously-open SFTP handles per
96/// session. A handle is the server-side identifier returned by
97/// SSH_FXP_OPEN and SSH_FXP_OPENDIR. One client typically uses one
98/// handle per file in flight plus one per directory listing.
99/// Operators running clients with deep pipelining may raise this.
100pub const ENV_SFTP_HANDLES_PER_SESSION: &str = "RUSTFS_SFTP_HANDLES_PER_SESSION";
101
102/// Optional environment variable. If RUSTFS_SFTP_BACKEND_OP_TIMEOUT_SECS
103/// is not set in the process environment, the server uses the default
104/// of 60 seconds and emits no warning. If set, the value must be in
105/// the inclusive range 5 to 600 seconds. Out-of-range values fall
106/// back to the default with a warn-level log naming the requested
107/// value and the bounds.
108///
109/// Bounds every storage backend call issued by the SFTP driver. A
110/// backend that does not respond within this many seconds returns
111/// Failure to the client and emits a warn log naming the backend
112/// method. This catches a backend that accepted the request and never
113/// returned a body, which the SSH keepalive cannot detect because the
114/// transport itself remains live.
115pub const ENV_SFTP_BACKEND_OP_TIMEOUT_SECS: &str = "RUSTFS_SFTP_BACKEND_OP_TIMEOUT_SECS";
116
117/// Optional environment variable. If RUSTFS_SFTP_READ_CACHE_WINDOW_BYTES
118/// is not set in the process environment, the server uses a 4 MiB
119/// default and emits no warning. If set, the value must be in the
120/// inclusive range MAX_READ_LEN (256 KiB) to 64 MiB. Out-of-range
121/// values fall back to the default with a warn-level log naming the
122/// requested value and the bounds.
123///
124/// Per-handle byte window the SFTP read path fetches in one backend
125/// call on a cache miss. Subsequent FXP_READs within that window are
126/// served from the buffer without a backend round trip. For
127/// sequential downloads the backend round-trip count drops by
128/// window_bytes / MAX_READ_LEN. Random-access workloads should set
129/// the window equal to MAX_READ_LEN to opt out of read-ahead.
130pub const ENV_SFTP_READ_CACHE_WINDOW_BYTES: &str = "RUSTFS_SFTP_READ_CACHE_WINDOW_BYTES";
131
132/// Optional environment variable. If
133/// RUSTFS_SFTP_READ_CACHE_TOTAL_MEM_BYTES is not set in the process
134/// environment, the server uses a 256 MiB default and emits no
135/// warning. If set, the value must be at least 16 MiB. Below-min
136/// values fall back to the default with a warn-level log naming the
137/// requested value and the bound.
138///
139/// Process-wide ceiling on cumulative read cache memory across every
140/// live SFTP handle. Once the accumulator plus a new window would
141/// exceed this value, the populate call on the per-handle cache is
142/// skipped. The read still completes from the freshly-fetched bytes
143/// without storing them in the cache, at the cost of one backend
144/// call per FXP_READ. High-concurrency deployments expecting many
145/// parallel downloads should raise this in step with the per-session
146/// handle cap.
147pub const ENV_SFTP_READ_CACHE_TOTAL_MEM_BYTES: &str = "RUSTFS_SFTP_READ_CACHE_TOTAL_MEM_BYTES";
148
149/// Default idle session timeout in seconds.
150pub const DEFAULT_SFTP_IDLE_TIMEOUT: u64 = 600;
151
152/// Default SFTP host key hot reload enabled state.
153pub const DEFAULT_SFTP_HOST_KEY_RELOAD_ENABLE: bool = false;
154
155/// Default SFTP host key hot reload interval in seconds.
156pub const DEFAULT_SFTP_HOST_KEY_RELOAD_INTERVAL: u64 = 30;
157
158/// Default S3 multipart upload part size in bytes (16 MiB).
159///
160/// The per-upload size ceiling is part_size * 10_000 (the S3 parts cap),
161/// so the default gives a 160 GiB single-upload limit. Deployments that
162/// expect single files larger than this must raise part_size:
163/// 64 MiB -> 640 GiB, 128 MiB -> 1.25 TiB, 512 MiB -> 5 TiB (S3 max).
164/// The minimum is 5 MiB and the maximum is 5 GiB (S3 protocol bounds).
165pub const DEFAULT_SFTP_PART_SIZE: u64 = 16_777_216;
166
167/// Default read-only mode (disabled).
168pub const DEFAULT_SFTP_READ_ONLY: bool = false;
169
170/// Default SSH identification string (no version disclosure).
171pub const DEFAULT_SFTP_BANNER: &str = "SSH-2.0-RustFS";