Compare commits

..

3 Commits

Author SHA1 Message Date
_ b05a87cc9c use `config_local_dir` 2021-12-16 21:47:12 +00:00
_ 354a74aeaa vendor my fork of `directories`.
I'll swap back to the crates.io version if `config_local_dir` is merged
upstream, or if it times out I'll fork it.
2021-12-16 21:46:25 +00:00
_ d9fd0fd29d 🚧 wip: working on avalanche idea to make MACs easier for humans to read 2021-12-16 20:51:44 +00:00
8 changed files with 50 additions and 6 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "vendored/directories"]
path = vendored/directories
url = git@github.com:ReactorScram/directories-rs.git

2
Cargo.lock generated
View File

@ -35,8 +35,6 @@ checksum = "06821ea598337a8412cf47c5b71c3bc694a7f0aed188ac28b836fab164a2c202"
[[package]]
name = "directories"
version = "4.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210"
dependencies = [
"dirs-sys",
]

View File

@ -13,7 +13,7 @@ version = "0.1.6"
[dependencies]
configparser = "3.0.0"
directories = "4.0.1"
directories = { path = "vendored/directories" }
mac_address = "1.1.2"
rand = "0.8.4"
thiserror = "1.0.30"

40
src/avalanche.rs Normal file
View File

@ -0,0 +1,40 @@
type Mac = [u8; 6];
pub fn debug () {
for input in [
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 1],
] {
assert_eq! (unmix (mix (input)), input);
}
println! ("Passed");
}
// NOT intended for any cryptography or security. This is TRIVIALLY reversible.
// It's just to make it easier for humans to tell apart MACs where only a couple
// numbers differ.
fn mix (i: Mac) -> Mac {
[
i [0] ^ i [5],
i [1] ^ i [4],
i [2] ^ i [3],
i [3],
i [4],
i [5],
]
}
fn unmix (i: Mac) -> Mac {
[
i [0] ^ i [5],
i [1] ^ i [4],
i [2] ^ i [3],
i [3],
i [4],
i [5],
]
}

View File

@ -165,7 +165,7 @@ fn load_config_file () -> ConfigFile {
if let Some (proj_dirs) = find_project_dirs () {
let mut ini = Ini::new_cs ();
let path = proj_dirs.config_dir ().join ("client.ini");
let path = proj_dirs.config_local_dir ().join ("client.ini");
if ini.load (&path).is_ok () {
let map_ref = ini.get_map_ref ();
if let Some (x) = map_ref.get ("nicknames") {

View File

@ -1,6 +1,7 @@
use prelude::*;
pub mod app_common;
mod avalanche;
mod client;
mod ip;
pub mod message;
@ -31,6 +32,7 @@ async fn async_main () -> Result <(), AppError> {
Some ("--version") => println! ("lookaround v{}", LOOKAROUND_VERSION),
Some ("client") => client::client (args).await?,
Some ("config") => config (),
Some ("debug-avalanche") => avalanche::debug (),
Some ("find-nick") => client::find_nick (args).await?,
Some ("my-ips") => my_ips ()?,
Some ("server") => server::server (args).await?,
@ -42,7 +44,7 @@ async fn async_main () -> Result <(), AppError> {
fn config () {
if let Some (proj_dirs) = ProjectDirs::from ("", "ReactorScram", "LookAround") {
println! ("Using config dir {:?}", proj_dirs.config_dir ());
println! ("Using config dir {:?}", proj_dirs.config_local_dir ());
}
else {
println! ("Can't detect config dir.");

View File

@ -41,7 +41,7 @@ fn configure <I: Iterator <Item=String>> (mut args: I) -> Result <Params, AppErr
if let Some (proj_dirs) = find_project_dirs () {
let mut ini = Ini::new_cs ();
let path = proj_dirs.config_dir ().join ("server.ini");
let path = proj_dirs.config_local_dir ().join ("server.ini");
if ini.load (&path).is_ok () {
if let Some (x) = ini.get ("server", "nickname") {
nickname = x;

1
vendored/directories Submodule

@ -0,0 +1 @@
Subproject commit 6b95e6319cb69933c07dba98e6af26d7145e0bd9