-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,279 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
mod analyze; | ||
mod compose_v1; | ||
mod v1; | ||
|
||
pub use analyze::{analyze_data_proxy, AnalyzeError, AnalyzeResult}; | ||
pub use compose_v1::{compose_data_proxy as compose_data_proxy_v1, ComposeError, ComposeResult}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,34 @@ | ||
use thiserror::Error; | ||
|
||
use crate::proxy::Proxy; | ||
|
||
pub enum AnalyzeError {} | ||
#[derive(Debug, Clone, Error, PartialEq, Eq)] | ||
pub enum AnalyzeError { | ||
#[error("unknown proxy version")] | ||
UnknownVersion, | ||
#[error("invalid JSON, proxy or plugin format")] | ||
InvalidEncoding, | ||
#[error(r#"duplicated plugin name "{0}""#)] | ||
DuplicateName(String), | ||
#[error(r#"plugin "{0}" required by "{1}" not found"#)] | ||
PluginNotFound(String, String), | ||
#[error(r#"unknown access point: "{0}""#)] | ||
UnknownAccessPoint(String), | ||
#[error(r#"expect plugin "{0}" to have a UDP access point = {1}, but it does not"#)] | ||
UnexpectedUdpAccessPoint(String, bool), | ||
#[error("too complicated")] | ||
TooComplicated, | ||
#[error(r#"invalid plugin: "{0}""#)] | ||
InvalidPlugin(String), | ||
#[error(r#"unused plugin: "{0}""#)] | ||
UnusedPlugin(String), | ||
} | ||
|
||
pub type AnalyzeResult<T> = Result<T, AnalyzeError>; | ||
|
||
pub fn analyze_data_proxy(name: String, proxy: &[u8]) -> AnalyzeResult<Proxy> { | ||
todo!() | ||
pub fn analyze_data_proxy(name: String, proxy: &[u8], version: u16) -> AnalyzeResult<Proxy> { | ||
if version != 0 { | ||
return Err(AnalyzeError::UnknownVersion); | ||
} | ||
super::v1::analyzer::analyze(name, proxy) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.