chiark / gitweb /
wip optiona nnd config parser
[hippotat.git] / src / config.rs
1 // Copyright 2021 Ian Jackson and contributors to Hippotat
2 // SPDX-License-Identifier: AGPL-3.0-or-later
3 // There is NO WARRANTY.
4
5 use crate::prelude::*;
6
7 #[derive(StructOpt,Debug)]
8 pub struct Opts {
9   /// Default config file or directory
10   ///
11   /// Look for `main.cfg`, `config.d` and `secrets.d` here.
12   ///
13   /// Or if this is a file, just read that file.
14   #[structopt(long, default_value="/etc/hippotat")]
15   pub config: PathBuf,
16   
17   /// Read this in addition, after the other config files
18   #[structopt(long, multiple=true, number_of_values=1)]
19   pub extra_config: Vec<PathBuf>,
20 }
21
22 pub struct CidrString(pub String);
23
24 pub struct InstanceConfig {
25   // Exceptional settings
26   pub server:                       String,
27   pub secret:                       String,
28   pub ipif:                         String,
29
30   // Capped settings:
31   pub max_batch_down:               u32,
32   pub max_queue_time:               Duration,
33   pub http_timeout:                 Duration,
34
35   // Ordinary settings:
36   pub target_requests_outstanding:  u32,
37   pub addrs:                        Vec<IpAddr>,
38   pub vnetwork:                     Vec<CidrString>,
39   pub vaddr:                        Vec<IpAddr>,
40   pub vrelay:                       IpAddr,
41   pub port:                         u16,
42   pub mtu:                          u32,
43   pub ifname_server:                String,
44   pub ifname_client:                String,
45
46   // Ordinary settings, used by server only:
47   pub max_clock_skew:               Duration,
48
49   // Ordinary settings, used by client only:
50   pub http_timeout_grace:           Duration,
51   pub max_requests_outstanding:     u32,
52   pub max_batch_up:                 u32,
53   pub http_retry:                   Duration,
54   pub url:                          Uri,
55   pub vroutes:                      Vec<CidrString>,
56 }