pub const MAX_PEER_MESSAGE_PAYLOAD: usize = 256 * 1024;
pub const MAX_PEER_READ_BUF: usize = 512 * 1024;
pub const MAX_DHT_DATAGRAM: usize = 8192;
pub const MAX_EXTENDED_PAYLOAD: usize = 64 * 1024;
pub const MAX_METADATA_BYTES: usize = 10 * 1024 * 1024;
pub const MAX_TORRENT_FILE_BYTES: usize = 64 * 1024 * 1024;
pub const MIN_PIECE_LENGTH: u32 = 16 * 1024;
pub const MAX_PIECE_LENGTH: u32 = 16 * 1024 * 1024;
pub const MAX_TORRENT_CONTENT_BYTES: u64 = 1 << 40;
pub const MAX_TRACKER_HTTP_RESPONSE: usize = 1024 * 1024;
pub const MAX_HTTP_HEADER_SLACK: usize = 64 * 1024;
#[derive(Debug, Clone, Copy)]
pub struct DecodeLimits {
pub max_depth: usize,
pub max_bytes: usize,
pub max_items: usize,
}
impl DecodeLimits {
pub const NETWORK: Self = Self {
max_depth: 24,
max_bytes: 64 * 1024,
max_items: 4096,
};
pub const TORRENT_FILE: Self = Self {
max_depth: 32,
max_bytes: MAX_TORRENT_FILE_BYTES,
max_items: 65_536,
};
pub const LOCAL_SIDECAR: Self = Self {
max_depth: 16,
max_bytes: 4 * 1024 * 1024,
max_items: 1_048_576,
};
pub const METADATA: Self = Self {
max_depth: 32,
max_bytes: MAX_METADATA_BYTES,
max_items: 65_536,
};
pub const TRACKER: Self = Self {
max_depth: 16,
max_bytes: MAX_TRACKER_HTTP_RESPONSE,
max_items: 8_192,
};
}