summaryrefslogtreecommitdiff
path: root/src/subscription.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/subscription.rs')
-rw-r--r--src/subscription.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/subscription.rs b/src/subscription.rs
index df5b318..8abcb1c 100644
--- a/src/subscription.rs
+++ b/src/subscription.rs
@@ -1,4 +1,4 @@
-use crate::model::{Entry, Trojan, display_text};
+use crate::model::{Entry, EntryStatus, Trojan, display_text};
use anyhow::{Result, anyhow, bail, ensure};
use async_trait::async_trait;
use base64::{Engine, engine::general_purpose};
@@ -191,7 +191,7 @@ fn parse_entry(raw: &str) -> Entry {
let mut entry = Entry {
id: Uuid::new_v4().to_string(),
name: "Invalid entry".into(),
- status: "invalid".into(),
+ status: EntryStatus::Invalid,
explanation: None,
connection: None,
};
@@ -205,7 +205,7 @@ fn parse_entry(raw: &str) -> Entry {
entry.name = display_text(&decode(label)?);
}
if url.scheme() != "trojan" {
- entry.status = "unsupported".into();
+ entry.status = EntryStatus::Unsupported;
bail!("Only Trojan TCP + TLS connections are supported");
}
ensure!(
@@ -276,7 +276,7 @@ fn parse_entry(raw: &str) -> Entry {
"allowInsecure" if value == "0" || value == "false" => {}
"headerType" if value == "none" => {}
_ => {
- entry.status = "unsupported".into();
+ entry.status = EntryStatus::Unsupported;
bail!("Unsupported transport, TLS, or connection option");
}
}
@@ -296,7 +296,7 @@ fn parse_entry(raw: &str) -> Entry {
})();
match result {
Ok(connection) => {
- entry.status = "supported".into();
+ entry.status = EntryStatus::Supported;
entry.connection = Some(connection);
}
Err(error) => entry.explanation = Some(error.to_string()),