orinium_browser/platform/network/
config.rs

1//! ネットワーク層の設定。タイムアウト、キャッシュ、ユーザーエージェント。
2
3use std::time::Duration;
4
5/// ネットワーク層全体の設定
6#[derive(Debug, Clone)]
7pub struct NetworkConfig {
8    /// User-Agent文字列
9    pub user_agent: String,
10
11    /// タイムアウト設定
12    pub connect_timeout: Duration,
13    pub read_timeout: Duration,
14
15    /// キャッシュを有効化するか
16    pub enable_cache: bool,
17
18    /// Cookie管理を有効化するか
19    pub enable_cookies: bool,
20
21    /// TLS証明書の検証を有効化するか
22    pub verify_tls: bool,
23
24    /// プロキシ設定
25    pub proxies: Vec<ProxyConfig>,
26
27    /// 最大同時接続数
28    pub max_connections: usize,
29
30    /// リダイレクトを自動フォローするか
31    pub follow_redirects: bool,
32
33    /// WebSocketを有効化するか
34    pub enable_websocket: bool,
35}
36
37#[allow(dead_code)]
38#[derive(Debug, Clone)]
39pub enum ProxyType {
40    Http,
41    Https,
42    Socks5,
43}
44
45#[allow(dead_code)]
46#[derive(Debug, Clone)]
47pub struct ProxyConfig {
48    pub proxy_type: String,
49    pub host: String,
50    pub port: u16,
51    pub username: Option<String>,
52    pub password: Option<String>,
53}
54
55#[allow(dead_code)]
56#[derive(Debug, Clone, Default)]
57pub struct ProxySettings {
58    pub proxies: Vec<ProxyConfig>, // 複数種類を保持できる
59}
60
61impl Default for NetworkConfig {
62    fn default() -> Self {
63        Self {
64            user_agent: String::from(
65                "OrinionBrowser/0.1 (+https://github.com/Orinas-github/Orinium-browser)",
66            ),
67            connect_timeout: Duration::from_secs(10),
68            read_timeout: Duration::from_secs(30),
69            enable_cache: true,
70            enable_cookies: true,
71            verify_tls: true,
72            proxies: vec![],
73            max_connections: 100,
74            follow_redirects: true,
75            enable_websocket: true,
76        }
77    }
78}