-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
1 parent
1889c8b
commit 0e46b63
Showing
13 changed files
with
338 additions
and
53 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
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,6 +1,7 @@ | ||
mod parse; | ||
mod service; | ||
mod toml; | ||
mod utils_verifier; | ||
|
||
pub use { | ||
self::toml::ConfigToml, | ||
|
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
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,31 @@ | ||
// functions to verify the startup arguments as correct | ||
use std::net::SocketAddr; | ||
use url::Url; | ||
|
||
pub(crate) fn verify_sock_addr(arg_val: &str) -> Result<(), String> { | ||
match arg_val.parse::<SocketAddr>() { | ||
Ok(_addr) => Ok(()), | ||
Err(_) => Err(format!( | ||
"Could not parse \"{}\" as a valid socket address (with port).", | ||
arg_val | ||
)), | ||
} | ||
} | ||
|
||
pub(crate) fn verify_target_url(arg_val: &str) -> Result<(), String> { | ||
let url = match Url::parse(arg_val) { | ||
Ok(addr) => addr, | ||
Err(_) => return Err(format!("Could not parse \"{}\" as a valid url.", arg_val)), | ||
}; | ||
|
||
match url.scheme() { | ||
"http" => (), | ||
"https" => (), | ||
_ => return Err("Invalid scheme".to_string()), | ||
}; | ||
|
||
if url.cannot_be_a_base() { | ||
return Err("Invalid scheme".to_string()); | ||
} | ||
Ok(()) | ||
} |
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
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,5 @@ | ||
#[derive(PartialEq, Eq, Debug, Clone)] | ||
pub enum DoHMethod { | ||
Get, | ||
Post, | ||
} |
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,46 @@ | ||
//////////////////////////////// | ||
// Constant Values for Config // | ||
//////////////////////////////// | ||
// Cannot override by config.toml | ||
pub const UDP_BUFFER_SIZE: usize = 2048; // TODO: バッファサイズめちゃ適当 | ||
pub const UDP_CHANNEL_CAPACITY: usize = 1024; // TODO: channelキャパシティめちゃ適当 | ||
pub const MAX_CONNECTIONS: usize = 128; // TODO: 最大接続数(UDP+TCP)めちゃ適当 | ||
pub const TIMEOUT_SEC: u64 = 10; | ||
|
||
// pub const CREDENTIAL_USERNAME_FIELD: &str = "username"; | ||
// pub const CREDENTIAL_API_KEY_FIELD: &str = "password"; | ||
// pub const CREDENTIAL_CLIENT_ID_FIELD: &str = "client_id"; | ||
|
||
pub const MIN_TTL: u32 = 10; // TTL for overridden records (plugin) | ||
|
||
//////////////////////////////// | ||
// Default Values for Config // | ||
//////////////////////////////// | ||
// Can override by specifying values in config.toml | ||
pub const LISTEN_ADDRESSES: &[&str] = &["127.0.0.1:50053", "[::1]:50053"]; | ||
|
||
pub const BOOTSTRAP_DNS: &[&str] = &["1.1.1.1:53"]; | ||
pub const REBOOTSTRAP_PERIOD_MIN: u64 = 60; | ||
pub const DOH_TARGET_URL: &[&str] = &["https://dns.google/dns-query"]; | ||
|
||
pub const MAX_CACHE_SIZE: usize = 16384; | ||
|
||
/////////////////////////////// | ||
// Constant Values for Proxy // | ||
/////////////////////////////// | ||
// Cannot override below by config.toml | ||
pub const ODOH_CONFIG_PATH: &str = "/.well-known/odohconfigs"; // client | ||
pub const ENDPOINT_LOGIN_PATH: &str = "/tokens"; // client::credential | ||
pub const ENDPOINT_REFRESH_PATH: &str = "/refresh"; // client::credential | ||
pub const ENDPOINT_JWKS_PATH: &str = "/jwks"; // client::credential | ||
|
||
// pub const CREDENTIAL_REFRESH_BEFORE_EXPIRATION_IN_SECS: i64 = 600; // refresh 10 minutes before expiration // proxy | ||
// pub const CREDENTIAL_REFRESH_MARGIN: i64 = 10; // at least 10 secs must be left to refresh // client::credential | ||
// pub const CREDENTIAL_CHECK_PERIOD_SECS: u64 = 60; // proxy | ||
// // every 60 secs, token is checked. then if the refresh condition is satisfied, refresh. | ||
// // this is to rapidly recover from the hibernation of PC on which this is working. (at most 60 secs is needed for recovery) | ||
// pub const ENDPOINT_RELOGIN_WAITING_SEC: u64 = 10; // proxy | ||
// pub const MAX_LOGIN_ATTEMPTS: usize = 5; // proxy | ||
|
||
pub const HEALTHCHECK_TARGET_FQDN: &str = "dns.google."; // client | ||
pub const HEALTHCHECK_TARGET_ADDR: &str = "8.8.8.8"; // client |
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,5 @@ | ||
pub use anyhow::{anyhow, bail, ensure, Context, Result}; | ||
// use std::io; | ||
// use thiserror::Error; | ||
|
||
// pub type Result<T> = std::result::Result<T, RpxyError>; |
Oops, something went wrong.