use std::sync::Arc;
use crate::Error;
#[derive(Debug, Clone)]
#[derive(serde::Deserialize)]
#[serde(tag = "type")]
pub(crate) enum Proxy {
#[serde(rename = "ss")]
Shadowsocks {
server: Arc<str>,
port: u16,
password: Arc<str>,
cipher: Arc<str>,
},
#[serde(other)]
Unknown,
}
#[derive(Debug, Clone)]
#[derive(serde::Deserialize)]
pub(crate) struct Config {
pub(crate) proxies: Vec<Proxy>,
}
impl Config {
#[inline]
pub(crate) fn parse(s: &str) -> Result<Self, Error> {
serde_saphyr::from_str(s).map_err(|_| Error::Parse)
}
}