config: domain
This commit is contained in:
parent
557cfa4a55
commit
8e8766617a
4 changed files with 22 additions and 6 deletions
|
|
@ -5,6 +5,9 @@ listen: 127.0.0.1:8504
|
|||
# Mesozoa relays accepted traffic to this address
|
||||
pass: 127.0.0.1:8000
|
||||
|
||||
# Domain to set the cookies
|
||||
domain: 127.0.0.1
|
||||
|
||||
# Duration (in seconds) of validity of a challenge
|
||||
challenge-timeout: 3600
|
||||
# PoW difficulty
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ pub struct Config {
|
|||
pub pass_addr: SocketAddr,
|
||||
pub default_action: Action,
|
||||
pub challenge_timeout: u64,
|
||||
pub domain: String,
|
||||
pub policy_groups: Vec<Vec<Policy>>,
|
||||
}
|
||||
|
||||
|
|
@ -40,6 +41,10 @@ impl Config {
|
|||
.expect("Missing default action in config"),
|
||||
)
|
||||
.expect("Invalid default action"),
|
||||
domain: config_doc["domain"]
|
||||
.as_str()
|
||||
.expect("Missing domain in config")
|
||||
.to_string(),
|
||||
policy_groups: config_doc["policy-groups"]
|
||||
.as_vec()
|
||||
.expect("Missing policies in config")
|
||||
|
|
|
|||
16
src/main.rs
16
src/main.rs
|
|
@ -37,7 +37,7 @@ macro_rules! mk_static {
|
|||
async fn main() {
|
||||
let cli: cli::Cli = argp::parse_args_or_exit(argp::DEFAULT);
|
||||
|
||||
let config = config::Config::from_file(&cli.config);
|
||||
let config = &*mk_static!(config::Config, config::Config::from_file(&cli.config));
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
|
|
@ -47,8 +47,8 @@ async fn main() {
|
|||
Vec<CompiledPolicies>,
|
||||
config
|
||||
.policy_groups
|
||||
.into_iter()
|
||||
.map(CompiledPolicies::new)
|
||||
.iter()
|
||||
.map(|policy| CompiledPolicies::new(policy))
|
||||
.collect()
|
||||
);
|
||||
|
||||
|
|
@ -197,7 +197,15 @@ async fn main() {
|
|||
.write_all(challenge_cookie.as_bytes())
|
||||
.await
|
||||
.unwrap();
|
||||
client_stream.write_all(b"; domain=127.0.0.1; path=/; max-age=3600; samesite=strict\r\n").await.unwrap();
|
||||
client_stream.write_all(b"; domain=").await.unwrap();
|
||||
client_stream
|
||||
.write_all(config.domain.as_bytes())
|
||||
.await
|
||||
.unwrap();
|
||||
client_stream
|
||||
.write_all(b"; path=/; max-age=3600; samesite=strict\r\n")
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
client_stream.write_all(b"\r\n").await.unwrap();
|
||||
client_stream
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ pub struct Policy {
|
|||
|
||||
pub struct CompiledPolicies {
|
||||
pub first_line_regex_set: RegexSet,
|
||||
pub policies: Vec<Policy>,
|
||||
pub policies: &'static [Policy],
|
||||
}
|
||||
|
||||
impl CompiledPolicies {
|
||||
pub fn new(policies: Vec<Policy>) -> Self {
|
||||
pub fn new(policies: &'static [Policy]) -> Self {
|
||||
let mut first_line_regexes = Vec::new();
|
||||
|
||||
for policy in policies.iter() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue