remnawave 2.2.4

Rust SDK for Remnawave API - A comprehensive client library for interacting with Remnawave services
Documentation
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
use crate::api::types::users::{InternalSquad, LastConnectedNode};
use crate::types::{TrafficLimitStrategy, UserStatus};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, fmt};
use uuid::Uuid;

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum SubscriptionClientType {
    Stash,
    SingBox,
    #[serde(rename = "singbox-legacy")]
    SingBoxLegacy,
    Mihomo,
    Json,
    #[serde(rename = "v2ray-Json")]
    V2RayJson,
    Clash,
}

impl fmt::Display for SubscriptionClientType {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        let s = serde_plain::to_string(self).unwrap();
        write!(f, "{s}")
    }
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum SubscriptionTemplateType {
    XrayJson,
    XrayBase64,
    Mihomo,
    Stash,
    Clash,
    Singbox,
}

impl fmt::Display for SubscriptionTemplateType {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        let s = serde_plain::to_string(self).unwrap();
        write!(f, "{s}")
    }
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct SubscriptionUser {
    pub short_uuid: String,
    pub days_left: usize,
    pub traffic_used: String,
    pub traffic_limit: String,
    pub lifetime_traffic_used: String,
    pub lifetime_traffic_used_bytes: String,
    pub traffic_limit_bytes: String,
    pub traffic_used_bytes: String,
    pub username: String,
    pub expires_at: DateTime<Utc>,
    pub is_active: bool,
    pub user_status: UserStatus,
    pub traffic_limit_strategy: TrafficLimitStrategy,
    pub tag: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct HappConfig {
    pub crypto_link: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct RawHost {
    pub address: Option<String>,
    pub alpn: Option<String>,
    pub fingerprint: Option<String>,
    pub host: Option<String>,
    pub network: Option<String>,
    pub password: HostPasswords,
    pub path: Option<String>,
    pub public_key: Option<String>,
    pub port: Option<u16>,
    pub protocol: Option<String>,
    pub remark: Option<String>,
    pub short_id: Option<String>,
    pub sni: Option<String>,
    pub spider_x: Option<String>,
    pub tls: Option<String>,
    pub header_type: Option<String>,
    pub additional_params: Option<AdditionalParams>,
    pub x_http_extra_params: Option<HashMap<String, serde_json::Value>>,
    pub server_description: Option<String>,
    pub flow: Option<String>,
    pub allow_insecure: Option<bool>,
    pub shuffle_host: Option<bool>,
    pub mihomo_x25519: Option<bool>,
    #[serde(rename = "mldsa65Verify")]
    pub mldsa_65_verify: Option<String>,
    pub encryption: Option<String>,
    pub protocol_options: Option<ProtocolOptions>,
    #[serde(rename = "muxParams")]
    pub mux_params: Option<serde_json::Value>,
    #[serde(rename = "sockoptParams")]
    pub sockopt_params: Option<serde_json::Value>,
    #[serde(rename = "dbData")]
    pub db_data: Option<RawHostDbData>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct AdditionalParams {
    pub mode: Option<String>,
    pub heartbeat_period: Option<usize>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ProtocolOptions {
    pub ss: Option<SsOptions>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct SsOptions {
    pub method: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct HostPasswords {
    #[serde(rename = "trojanPassword")]
    pub trojan: String,
    #[serde(rename = "vlessPassword")]
    pub vless: String,
    #[serde(rename = "ssPassword")]
    pub ss: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct RawHostDbData {
    pub raw_inbound: serde_json::Value,
    pub inbound_tag: String,
    pub uuid: Uuid,
    pub config_profile_uuid: Option<Uuid>,
    pub config_profile_inbound_uuid: Option<Uuid>,
    pub is_disabled: bool,
    pub view_position: i32,
    pub remark: String,
    pub is_hidden: bool,
    pub tag: Option<String>,
    pub vless_route_id: Option<i32>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct RawSubscriptionUser {
    pub uuid: Uuid,
    pub short_uuid: String,
    pub username: String,
    pub status: UserStatus,
    pub used_traffic_bytes: u64,
    pub lifetime_used_traffic_bytes: u64,
    pub traffic_limit_bytes: i64,
    pub traffic_limit_strategy: TrafficLimitStrategy,
    pub sub_last_user_agent: Option<String>,
    pub sub_last_opened_at: Option<DateTime<Utc>>,
    pub expire_at: DateTime<Utc>,
    pub online_at: Option<DateTime<Utc>>,
    pub sub_revoked_at: Option<DateTime<Utc>>,
    pub last_traffic_reset_at: Option<DateTime<Utc>>,
    pub trojan_password: String,
    pub vless_uuid: Uuid,
    pub ss_password: String,
    pub description: Option<String>,
    pub tag: Option<String>,
    pub telegram_id: Option<i64>,
    pub email: Option<String>,
    pub hwid_device_limit: Option<i32>,
    pub first_connected_at: Option<DateTime<Utc>>,
    pub last_triggered_threshold: i32,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
    pub active_internal_squads: Vec<InternalSquad>,
    pub external_squad_uuid: Option<Uuid>,
    pub subscription_url: String,
    pub last_connected_node: Option<LastConnectedNode>,
    pub happ: HappConfig,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct ConvertedUserInfo {
    pub days_left: f64,
    pub traffic_limit: String,
    pub traffic_used: String,
    pub lifetime_traffic_used: String,
    pub is_hwid_limited: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Subscription {
    pub is_found: bool,
    pub user: SubscriptionUser,
    pub links: Vec<String>,
    pub ss_conf_links: HashMap<String, String>,
    pub subscription_url: String,
    pub happ: Option<HappConfig>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct GetSubscriptionInfoResponseDto {
    pub response: Subscription,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct GetRawSubscriptionByShortUuidResponseDto {
    pub response: RawSubscriptionResponse,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct RawSubscriptionResponse {
    pub user: RawSubscriptionUser,
    pub converted_user_info: ConvertedUserInfo,
    pub headers: HashMap<String, String>,
    pub raw_hosts: Vec<RawHost>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct GetAllSubscriptionsResponseDto {
    pub response: AllSubscriptionsResponse,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct AllSubscriptionsResponse {
    pub subscriptions: Vec<BasicSubscription>,
    pub total: usize,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct BasicSubscription {
    pub is_found: bool,
    pub user: BasicSubscriptionUser,
    pub links: Vec<String>,
    pub ss_conf_links: HashMap<String, String>,
    pub subscription_url: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct BasicSubscriptionUser {
    pub short_uuid: String,
    pub days_left: usize,
    pub traffic_used: String,
    pub traffic_limit: String,
    pub username: String,
    pub expires_at: DateTime<Utc>,
    pub is_active: bool,
    pub user_status: UserStatus,
    pub traffic_limit_strategy: TrafficLimitStrategy,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct GetSubscriptionByUsernameResponseDto {
    pub response: UsernameSubscriptionResponse,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct GetSubscriptionByShortUuidResponseDto {
    pub response: ShortUuidSubscriptionResponse,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct ShortUuidSubscriptionResponse {
    pub is_found: bool,
    pub user: SubscriptionUser,
    pub links: Vec<String>,
    pub ss_conf_links: HashMap<String, String>,
    pub subscription_url: String,
    pub happ: HappConfig,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct GetSubscriptionByUuidResponseDto {
    pub response: UuidSubscriptionResponse,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct UuidSubscriptionResponse {
    pub is_found: bool,
    pub user: SubscriptionUser,
    pub links: Vec<String>,
    pub ss_conf_links: HashMap<String, String>,
    pub subscription_url: String,
    pub happ: HappConfig,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct UsernameSubscriptionResponse {
    pub is_found: bool,
    pub user: SubscriptionUser,
    pub links: Vec<String>,
    pub ss_conf_links: HashMap<String, String>,
    pub subscription_url: String,
    pub happ: HappConfig,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct GetTemplatesResponseDto {
    pub response: TemplatesListResponse,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct TemplatesListResponse {
    pub total: usize,
    pub templates: Vec<TemplateSummary>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct TemplateSummary {
    pub uuid: Uuid,
    pub name: String,
    pub template_type: SubscriptionTemplateType,
    pub template_json: Option<serde_json::Value>,
    pub encoded_template_yaml: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct GetTemplateResponseDto {
    pub response: TemplateSummary,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct UpdateTemplateRequestDto {
    pub uuid: Uuid,
    pub name: String,
    pub template_json: Option<serde_json::Value>,
    pub encoded_template_yaml: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct UpdateTemplateResponseDto {
    pub response: TemplateSummary,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct DeleteSubscriptionTemplateResponse {
    pub is_deleted: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct DeleteSubscriptionTemplateResponseDto {
    pub response: DeleteSubscriptionTemplateResponse,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct CreateSubscriptionTemplateRequestDto {
    pub name: String,
    pub template_type: SubscriptionTemplateType,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct CreateSubscriptionTemplateResponseDto {
    pub response: TemplateSummary,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct SubscriptionResponseRuleHeaderModification {
    pub key: String,
    pub value: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum SubscriptionResponseRuleConditionOperator {
    Equals,
    NotEquals,
    Contains,
    NotContains,
    StartsWith,
    NotStartsWith,
    EndsWith,
    NotEndsWith,
    Regex,
    NotRegex,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct SubscriptionResponseRuleCondition {
    pub header_name: String,
    pub operator: SubscriptionResponseRuleConditionOperator,
    pub value: String,
    pub case_sensitive: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum SubscriptionResponseRuleOperator {
    And,
    Or,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum SubscriptionResponseRuleType {
    XrayJson,
    XrayBase64,
    Mihomo,
    Stash,
    Clash,
    Singbox,
    Browser,
    Block,
    StatusCode404,
    StatusCode451,
    SocketDrop,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct SubscriptionResponseRuleModifications {
    pub headers: Option<Vec<SubscriptionResponseRuleHeaderModification>>,
    pub subscription_template: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct SubscriptionResponseRule {
    pub name: String,
    pub description: Option<String>,
    pub enabled: bool,
    pub operator: SubscriptionResponseRuleOperator,
    pub conditions: Vec<SubscriptionResponseRuleCondition>,
    pub response_type: SubscriptionResponseRuleType,
    pub response_modifications: Option<SubscriptionResponseRuleModifications>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct SubscriptionResponseRulesConfig {
    pub version: String,
    pub rules: Vec<SubscriptionResponseRule>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct GetSubscriptionSettingsResponseDto {
    pub response: SubscriptionSettings,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct UpdateSubscriptionSettingsRequestDto {
    pub uuid: Uuid,
    pub profile_title: String,
    pub support_link: String,
    pub profile_update_interval: usize,
    pub is_profile_webpage_url_enabled: bool,
    pub serve_json_at_base_subscription: bool,
    pub add_username_to_base_subscription: bool,
    pub is_show_custom_remarks: bool,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub happ_announce: Option<Option<String>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub happ_routing: Option<Option<String>>,
    pub expired_users_remarks: Vec<String>,
    pub limited_users_remarks: Vec<String>,
    pub disabled_users_remarks: Vec<String>,
    pub custom_response_headers: Option<std::collections::HashMap<String, String>>,
    pub randomize_hosts: bool,
    pub response_rules: Option<SubscriptionResponseRulesConfig>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct UpdateSubscriptionSettingsResponseDto {
    pub response: SubscriptionSettings,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct SubscriptionSettings {
    pub uuid: Uuid,
    pub profile_title: String,
    pub support_link: String,
    pub profile_update_interval: usize,
    pub is_profile_webpage_url_enabled: bool,
    pub serve_json_at_base_subscription: bool,
    pub add_username_to_base_subscription: bool,
    pub is_show_custom_remarks: bool,
    pub happ_announce: Option<String>,
    pub happ_routing: Option<String>,
    pub expired_users_remarks: Vec<String>,
    pub limited_users_remarks: Vec<String>,
    pub disabled_users_remarks: Vec<String>,
    pub custom_response_headers: Option<std::collections::HashMap<String, String>>,
    pub randomize_hosts: bool,
    pub response_rules: Option<SubscriptionResponseRulesConfig>,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
}