-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The exit root server now signs and encrypts exit server lists to send back to clients. Contracts that have been processed already are added to a cache which is automatically updated every 5 minutes from the rpc server with the current list of exits.
- Loading branch information
Showing
8 changed files
with
217 additions
and
34 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
[clarity_private_key] | ||
'0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f1e' | ||
|
||
[wg_private_key] | ||
'0NZdyxzjnMEyEMn2PA+oal+nEbkp/sK1xC486Tqys3E=' |
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 +1,59 @@ | ||
use std::{fs::File, io::Read}; | ||
use lazy_static::lazy_static; | ||
use althea_types::WgKey; | ||
use clarity::PrivateKey; | ||
use log::error; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::DEVELOPMENT; | ||
|
||
///Struct containing settings for Exit root server | ||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub struct ConfigStruct { | ||
pub clarity_private_key: PrivateKey, | ||
pub wg_private_key: WgKey, | ||
} | ||
|
||
impl ConfigStruct { | ||
pub fn load(path: String) -> Option<ConfigStruct> { | ||
let mut config_toml = String::new(); | ||
|
||
let mut file = match File::open(path) { | ||
Ok(file) => file, | ||
Err(_) => { | ||
error!("Could not find config file. Using default!"); | ||
return None; | ||
} | ||
}; | ||
|
||
file.read_to_string(&mut config_toml) | ||
.unwrap_or_else(|err| panic!("Error while reading config: [{}]", err)); | ||
|
||
let res = toml::from_str(&config_toml).unwrap(); | ||
Some(res) | ||
} | ||
} | ||
|
||
/// loads the exit root server config, broken out here so that | ||
/// we can easily verify that the config is valid before starting | ||
pub fn load_config() -> ConfigStruct { | ||
// change the config name based on our development status | ||
let file_name = if DEVELOPMENT || cfg!(test) { | ||
"config.toml" | ||
} else { | ||
"/etc/exit_root_server.toml" | ||
}; | ||
let config_structs = ConfigStruct::load(file_name.to_string()); | ||
if let Some(conf) = config_structs { | ||
conf | ||
} else { | ||
panic!( | ||
"Can not find configuration file! for filename {:?}", | ||
file_name | ||
); | ||
} | ||
} | ||
|
||
lazy_static! { | ||
pub static ref CONFIG: ConfigStruct = load_config(); | ||
} |
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