1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
use crate::types::util::MimeType;
// use chrono::Duration;
/// Configuration read from a configuration file
#[derive(Serialize, Deserialize, Debug, AddGetter)]
pub struct Configuration {
#[serde(rename = "ipfs-api-url")]
#[get]
/// The URL of the API
api_url: String,
#[serde(rename = "ipfs-api-port")]
#[get]
/// The Port of the API
api_port: u16,
#[serde(rename = "app-port")]
#[get]
/// The Port of the App itself
app_port: u16,
#[serde(rename = "autoserve-chains")]
#[get]
/// Whether to automatically "ipfs pin" chain objects
autoserve_chains: bool,
#[serde(rename = "autoserve-text-posts")]
#[get]
/// Whether to automatically "ipfs pin" foreign posts if their content is text
autoserve_text_posts: bool,
#[serde(rename = "serve-blocked")]
#[get]
/// Whether to serve content/chains from blocked profiles
serve_blocked: bool,
#[serde(rename = "autoserve-followed")]
#[get]
/// Whether to automatically "ipfs pin" followed profiles
autoserve_followed: bool,
#[serde(rename = "max-autoload-per-post")]
#[get]
/// Default amount of bytes which are loaded for each post
max_autoload_per_post: usize,
#[serde(rename = "autoserve-blacklist")]
#[get]
/// List of Mimetypes which should not be served
autoserve_blacklist: Vec<MimeType>,
#[serde(rename = "autoserve-whitelist")]
#[get]
/// List of Mimetypes which can be served
autoserve_whitelist: Vec<MimeType>,
// #[serde(rename = "merge-timeout")]
// #[get]
// /// Timeout before merge should be attempted
// merge_timeout: Duration,
//
/// Name under which to provide the local device. E.G.
/// Some("/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY")
///
/// If none, one will be generated and set
#[serde(rename = "device_name")]
#[get]
device_name: Option<String>,
/// Key to sign stuff that comes from this device.
///
/// Create by using `ipfs key gen <name>`
#[serde(rename = "device_key")]
#[get]
device_key: Option<String>,
/// Devices for the profile
/// E.G:
/// ["/ipfs/QmVrLsEDn27sScp3k23sgZNefVTjSAL3wpgW1iWPi4MgoY"]
#[serde(rename = "devices")]
#[get]
devices: Vec<String>,
}
impl Default for Configuration {
fn default() -> Self {
Configuration {
api_url : String::from("127.0.0.1"),
api_port : 5001,
app_port : 5002,
autoserve_chains : true,
autoserve_text_posts : true,
serve_blocked : false,
autoserve_followed : true,
max_autoload_per_post : 1024 * 1024,
autoserve_blacklist : Vec::new(),
autoserve_whitelist : Vec::new(),
// merge_timeout : Duration::minutes(15),
device_name : None,
device_key : None,
devices : Vec::new(),
}
}
}
|